Bodoconsult.Core.Typography
Autor: Bodoconsult EDV-Dienstleistungen GmbH Robert Leisner
Nuget package
https://www.nuget.org/packages/Bodoconsult.Core.Typography/
Github repository
https://github.com/RobertLeisner/Bodoconsult.Core.Typography
About the library Bodoconsult.Core.Typography
What does the library
Bodoconsult.Core.Typography is a base class containing properties and methods around typographic settings for paper reports and / or charts. The itention of this library is to store a complete typographic set of properties outside the app in an adjustable JSON file and to read it from there if needed.
The library contains three predefined typographic sets for common use cases in the classes called DefaultTypographyPageHeader, CompactTypographyPageHeader and ElegantTypographyPageHeader. The default paper format is DIN A4 portrait.
DefaultTypographyPageHeader is a typographic style set for a normal paper report. It is a compromiss between use of space and elegance.
CompactTypographyPageHeader is a typographic style set for compact paper report intended to get as much information as possible on a given paper format.
ElegantTypographyPageHeader is a typograhic style set preferring elegance over use of space. It needs more pages of paper per given information to print.
How to use the library
The source code contain NUnit test classes, the following source code is extracted from. The samples below show the most helpful use cases for the library.
Basic usage
var t = new ElegantTypographyPageHeader("Cambria", "Cambria", "Cambria")
{
LogoPath = @"C:\bodoconsult\Logos\logo.jpg"
};
t.SetMargins();
Customizing a typographic set
var t = new ElegantTypographyPageHeader("Cambria", "Cambria", "Cambria")
{
LogoPath = @"C:\bodoconsult\Logos\logo.jpg",
FontSize = 12,
};
t.SetMargins();
Creating your user-defined typographic set
The following example shows the implementation of a user-defined typographic set.
/// <summary>
/// Provides your user-defined typograph based on sans serif fonts at default. See non-default constructor to change fonts
/// </summary>
public class UserDefinedTypographyPageHeader : TypographyBase
{
/// <summary>
/// Default ctor. Sets font names to Calibri
/// </summary>
public UserDefinedTypographyPageHeader()
{
BaseConstructor("Calibri", "Calibri", "Calibri");
}
/// <summary>
/// Ctor to set font names
/// </summary>
/// <param name="primaryFontname">Font name for text</param>
/// <param name="secondaryFontName">Font name for headings</param>
/// <param name="thirdFontName">Font name for titles</param>
public UserDefinedTypographyPageHeader(string primaryFontname, string secondaryFontName, string thirdFontName)
{
BaseConstructor(primaryFontname, secondaryFontName, thirdFontName);
}
private void BaseConstructor(string primaryFontname, string secondaryFontName, string thirdFontName)
{
// Default page DIN A4
PageHeight = 29.4;
PageWidth = 21.0;
FontName = primaryFontname;
FontSize = 11;
SmallFontSize = FontSize - 2;
ExtraSmallFontSize = SmallFontSize - 2;
LogoPath = @"C:\bodoconsult\Logos\logo.jpg";
HeadingFontName = secondaryFontName;
HeadingFontSize5 = FontSize;
HeadingFontSize4 = HeadingFontSize5;
HeadingFontSize3 = HeadingFontSize4;
HeadingFontSize2 = HeadingFontSize3;
HeadingFontSize1 = HeadingFontSize2 + 2;
LineHeight = 0.5;
ColumnDividerWidth = 0.5;
ColumnWidth = 2.0;
ColumnCount = 6;
DotsPerInch = 300;
LogoWidth = 2 * ColumnWidth + ColumnDividerWidth;
TitleFontName = thirdFontName;
SubTitleFontName = thirdFontName;
TitleFontSize = HeadingFontSize1 + 4;
SubTitleFontSize = HeadingFontSize1 + 2;
MarginLeftFactor = 2.5;
MarginRightFactor = 2.5;
MarginTopFactor = 3;
MarginBottomFactor = 2;
SetMargins();
PageFooterHeight = 0.5;
PageHeaderHeight = 1.5;
PageHeaderMargin = 1.5;
PageFooterMargin = ColumnDividerWidth;
ChartStyle = new ChartStyle
{
FontName = FontName,
TitleFontName = HeadingFontName,
FontSize = (float)FontSize,
Width = GetPixelWidth(6),
Height = GetPixelHeight(6),
PaperColor = Color.White
};
TableBodyBackground = Color.White;
TableHeaderBackground = Color.White;
TableBodyUnborderedBackground = Color.Transparent;
TableHeaderUnborderedBackground = Color.Transparent;
TableCornerRadius = 0.3;
TableBorderWidth = 0.05;
TableBorderColor = Color.FromArgb(178, 204, 255);
}
}
About us
Bodoconsult http://www.bodoconsult.de is a Munich based software company from Germany.
Robert Leisner is senior software developer at Bodoconsult. See his profile on http://www.bodoconsult.de/Curriculum_vitae_Robert_Leisner.pdf.
Licence for the library Bodoconsult.Core.Typography
The MIT License (MIT) for Bodoconsult.Core.Typography
Copyright (c) 2015 - 2020 Bodoconsult EDV-Dienstleistungen GmbH, Vaterstetten (Germany)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.