Show / Hide Table of Contents

Class FontMetrics

Simple font metrics class, independent of graphics subsystems and installed fonts.

Inheritance
object
FontMetrics
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Codecrete.SwissQRBill.Generator.Canvas
Assembly: Codecrete.SwissQRBill.Core.dll
Syntax
public class FontMetrics

Constructors

| Edit this page View Source

FontMetrics(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
string fontFamilyList

The font families, separated by comma (syntax as in CSS).

Properties

| Edit this page View Source

FirstFontFamily

Gets the first font family (from the font family list).

Declaration
public string FirstFontFamily { get; }
Property Value
Type Description
string

The first font family name.

| Edit this page View Source

FontFamilyList

Gets the font family list (comma separated, same syntax as for CSS).

Declaration
public string FontFamilyList { get; }
Property Value
Type Description
string

The font family list, comma separated.

Methods

| Edit this page View Source

Ascender(int)

Gets the distance between the baseline and the top of tallest letter.

Declaration
public double Ascender(int fontSize)
Parameters
Type Name Description
int fontSize

The font size (in pt).

Returns
Type Description
double

The distance (in mm).

| Edit this page View Source

Descender(int)

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
int fontSize

The font size (in pt).

Returns
Type Description
double

The distance (in mm).

| Edit this page View Source

LineHeight(int)

Gets the distance between the baselines of two consecutive text lines.

Declaration
public double LineHeight(int fontSize)
Parameters
Type Name Description
int fontSize

The font size (in pt).

Returns
Type Description
double

The distance (in mm).

| Edit this page View Source

SplitLines(string, double, int)

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
string text

The text to split into lines.

double maxLength

The maximum line length (in pt).

int fontSize

The font size (in pt).

Returns
Type Description
string[]

The resulting array of text lines.

| Edit this page View Source

TextWidth(string, int, bool)

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
string text

The text to measure.

int fontSize

The font size (in pt).

bool isBold

The flag indicating if the text is in bold or regular weight.

Returns
Type Description
double

The text's width (in mm).

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX