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 : ITextMeasurerRemarks
The text is split into runs of one script; each run is shaped in the direction of its first strong character.
- Implements
Constructors
| Name | Description |
|---|---|
| FontFaceTextMeasurer(FontFace, FontFace?, FontFace?, FontFace?, string?) | Initializes a new instance of the FontFaceTextMeasurer class. |
| FontFaceTextMeasurer(FontFace, FontFace?, string?) | Initializes a new instance of the FontFaceTextMeasurer class. |
| FontFaceTextMeasurer(SceneFontCollection) | Initializes a new instance of the FontFaceTextMeasurer class that measures the text with the fonts of a collection. |
FontFaceTextMeasurer overloads
FontFaceTextMeasurer(FontFace, FontFace?, FontFace?, FontFace?, string?)
FontFaceTextMeasurer.csInitializes a new instance of the FontFaceTextMeasurer class.
public FontFaceTextMeasurer(FontFace regular, FontFace? bold, FontFace? italic, FontFace? boldItalic, string? fontFamily = null)Parameters
regularFontFace- The face of the regular text, loaded with
FontLoader. boldFontFace?- The face of the bold text, or
nullto measure bold text withregular. italicFontFace?- The face of the italic text, or
nullto measure italic text withregular. boldItalicFontFace?- The face of the bold italic text, or
nullto measure it withbold, thenitalic, thenregular. fontFamilystring?- The CSS
font-familyof the text, ornullfor the family name ofregular.
Remarks
The measurer has no FontFaceTextMeasurer.Fonts: each renderer draws the text with its own fonts. Use FontFaceTextMeasurer so the renderers draw with the fonts that measure.
FontFaceTextMeasurer(FontFace, FontFace?, string?)
FontFaceTextMeasurer.csInitializes a new instance of the FontFaceTextMeasurer class.
Parameters
regularFontFace- The face of the regular text, loaded with
FontLoader. boldFontFace?- The face of the bold text, or
nullto measure bold text withregular. fontFamilystring?- The CSS
font-familyof the text, ornullfor the family name ofregular.
FontFaceTextMeasurer(SceneFontCollection)
FontFaceTextMeasurer.csInitializes a new instance of the FontFaceTextMeasurer class that measures the text with the fonts of a collection.
public FontFaceTextMeasurer(SceneFontCollection fonts)Parameters
fontsSceneFontCollection- The fonts. A chart or a diagram sets them as the fonts of its scene, so the renderers draw the text with them.
Remarks
The family of a text is SceneFont.Family, or SceneFontCollection.DefaultFamily. The characters its face does not have are measured with the face that draws them (SceneFontCollection). The ascent and the descent are the ones of the face of the family.
Properties
| Name | Description |
|---|---|
| FontFamily | Gets the font family the measured text is drawn with, as a CSS font-family value. |
| Fonts | Gets the fonts the text is measured with, or null when the measurer was created from faces of Meziantou.Framework.Fonts. |
FontFamily
FontFaceTextMeasurer.csGets the fonts the text is measured with, or null when the measurer was created from faces of Meziantou.Framework.Fonts.
public SceneFontCollection? Fonts { get; }Property value
Methods
| Name | Description |
|---|---|
| Measure(string, SceneFont) | Measures a line of text. |
| Measure(string, SceneFont, double, double) | Measures a line of text with a letter spacing and a word spacing (SceneText.LetterSpacing, SceneText.WordSpacing), as the renderers draw it. |
Measure overloads
Measure(string, SceneFont)
FontFaceTextMeasurer.csMeasures a line of text.
public TextMetrics Measure(string text, SceneFont font)Measure(string, SceneFont, double, double)
FontFaceTextMeasurer.csMeasures a line of text with a letter spacing and a word spacing (SceneText.LetterSpacing, SceneText.WordSpacing), as the renderers draw it.
public TextMetrics Measure(string text, SceneFont font, double letterSpacing, double wordSpacing)Parameters
textstring- The text, on one line.
fontSceneFont- The size, the weight and the style of the font.
letterSpacingdouble- The space added after each character, in pixels.
wordSpacingdouble- The space added after each space (U+0020 and U+00A0), in pixels.
Returns
TextMetrics The dimensions of the text: its width includes the spacing.
Remarks
With a letter spacing, the text is shaped without its optional ligatures, and the spacing is added after each cluster of glyphs (a character with its marks, a ligature the script requires), as the renderers draw it.