Class FontMetrics
Simple font metrics class, independent of graphics subsystems and installed fonts.
Inheritance
Inherited Members
Namespace: Codecrete.SwissQRBill.Generator.Canvas
Assembly: Codecrete.SwissQRBill.Core.dll
Syntax
public class FontMetrics
Constructors
| Improve this Doc View SourceFontMetrics(String)
Initializes a new instance for the given list of font families.
If more than one family is specified, the first family is used for metrics.
Declaration
public FontMetrics(string fontFamilyList)
Parameters
Type | Name | Description |
---|---|---|
System.String | fontFamilyList | The font families, separated by comma (syntax as in CSS). |
Properties
| Improve this Doc View SourceFirstFontFamily
Gets the first font family (from the font family list).
Declaration
public string FirstFontFamily { get; }
Property Value
Type | Description |
---|---|
System.String | The first font family name. |
FontFamilyList
Gets the font family list (comma separated, same syntax as for CSS).
Declaration
public string FontFamilyList { get; }
Property Value
Type | Description |
---|---|
System.String | The font family list, comma separated. |
Methods
| Improve this Doc View SourceAscender(Int32)
Gets the distance between the baseline and the top of tallest letter.
Declaration
public double Ascender(int fontSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | fontSize | The font size (in pt). |
Returns
Type | Description |
---|---|
System.Double | The distance (in mm). |
Descender(Int32)
Gets the distance between the baseline and the bottom of letter extending the farthest below the baseline.
Declaration
public double Descender(int fontSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | fontSize | The font size (in pt). |
Returns
Type | Description |
---|---|
System.Double | The distance (in mm). |
LineHeight(Int32)
Gets the distance between the baselines of two consecutive text lines.
Declaration
public double LineHeight(int fontSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | fontSize | The font size (in pt). |
Returns
Type | Description |
---|---|
System.Double | The distance (in mm). |
SplitLines(String, Double, Int32)
Splits the text into lines.
The text is split such that no line is wider the specified maximum width. If possible, the text is split at whitespace characters. If a word is wider than the specified maximum width, the word is split and put onto two or more lines. The text is always split at newlines.
Declaration
public string[] SplitLines(string text, double maxLength, int fontSize)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to split into lines. |
System.Double | maxLength | The maximum line length (in pt). |
System.Int32 | fontSize | The font size (in pt). |
Returns
Type | Description |
---|---|
System.String[] | The resulting array of text lines. |
TextWidth(String, Int32, Boolean)
Returns the width of the specified text for the specified font size.
Declaration
public double TextWidth(string text, int fontSize, bool isBold)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to measure. |
System.Int32 | fontSize | The font size (in pt). |
System.Boolean | isBold | The flag indicating if the text is in bold or regular weight. |
Returns
Type | Description |
---|---|
System.Double | The text's width (in mm). |