FontFaceTextMeasurer Class

Measures text by shaping it with a font of Meziantou.Framework.Fonts: every script, ligatures, kerning and the advances of the font are taken into account.

public sealed class FontFaceTextMeasurer : ITextMeasurer

Remarks

The text is split into runs of one script; each run is shaped in the direction of its first strong character.

Implements

Constructors

NameDescription
FontFaceTextMeasurer(FontFace, FontFace?, string?)Initializes a new instance of the FontFaceTextMeasurer class.

FontFaceTextMeasurer(FontFace, FontFace?, string?)

FontFaceTextMeasurer.cs

Initializes a new instance of the FontFaceTextMeasurer class.

public FontFaceTextMeasurer(FontFace regular, FontFace? bold = null, string? fontFamily = null)

Parameters

regular FontFace
The face of the regular text, loaded with FontLoader.
bold FontFace?
The face of the bold text, or null to measure bold text with regular.
fontFamily string?
The CSS font-family of the text, or null for the family name of regular.

Properties

NameDescription
FontFamilyGets the font family the measured text is drawn with, as a CSS font-family value.

Gets the font family the measured text is drawn with, as a CSS font-family value.

public string FontFamily { get; }

Property value

string

Methods

NameDescription
Measure(string, ChartFont)Measures a line of text.

Measure(string, ChartFont)

FontFaceTextMeasurer.cs

Measures a line of text.

public TextMetrics Measure(string text, ChartFont font)

Parameters

text string
The text, on one line.
font ChartFont
The size and the weight of the font.

Returns

TextMetrics The dimensions of the text.