ImageTextMeasurer Class

Measures the texts of a scene with the fonts of Meziantou.Framework.Imaging: the widths are the ones TextLayout draws.

public sealed class ImageTextMeasurer : ITextMeasurer
Implements

Constructors

NameDescription
ImageTextMeasurer(Font, Font?)Initializes a new instance of the ImageTextMeasurer class.
ImageTextMeasurer(Font, Font?, Font?, Font?)Initializes a new instance of the ImageTextMeasurer class.
ImageTextMeasurer(SceneFontCollection)Initializes a new instance of the ImageTextMeasurer class that measures the texts with the fonts of a collection.

ImageTextMeasurer overloads

ImageTextMeasurer(Font, Font?)

ImageTextMeasurer.cs

Initializes a new instance of the ImageTextMeasurer class.

public ImageTextMeasurer(Font regular, Font? bold = null)
Parameters
regular Font
The font of the regular texts.
bold Font?
The font of the bold texts, or null for regular.

ImageTextMeasurer(Font, Font?, Font?, Font?)

ImageTextMeasurer.cs

Initializes a new instance of the ImageTextMeasurer class.

public ImageTextMeasurer(Font regular, Font? bold, Font? italic, Font? boldItalic)
Parameters
regular Font
The font of the regular texts.
bold Font?
The font of the bold texts, or null for regular.
italic Font?
The font of the italic texts, or null for regular.
boldItalic Font?
The font of the bold italic texts, or null for bold, then italic, then regular.

ImageTextMeasurer(SceneFontCollection)

ImageTextMeasurer.cs

Initializes a new instance of the ImageTextMeasurer class that measures the texts with the fonts of a collection.

public ImageTextMeasurer(SceneFontCollection fonts)
Parameters
fonts SceneFontCollection
The fonts. A chart or a diagram sets them as the fonts of its scene, so the renderers draw the texts 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. The ascent and the descent are the ones of the face of the family.

Properties

NameDescription
FontFamilyGets the family of the texts: the family name of the regular font, or the families of ImageTextMeasurer.Fonts.
FontsGets the fonts the texts are measured with, or null when the measurer was created from fonts of Meziantou.Framework.Imaging.

Gets the family of the texts: the family name of the regular font, or the families of ImageTextMeasurer.Fonts.

public string FontFamily { get; }

Property value

string

Gets the fonts the texts are measured with, or null when the measurer was created from fonts of Meziantou.Framework.Imaging.

public SceneFontCollection? Fonts { get; }

Property value

SceneFontCollection?

Methods

NameDescription
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)

ImageTextMeasurer.cs

Measures a line of text.

public TextMetrics Measure(string text, SceneFont font)
Parameters
text string
The text, on one line.
font SceneFont
The size, the weight and the style of the font.
Returns

TextMetrics The dimensions of the text.

Measure(string, SceneFont, double, double)

ImageTextMeasurer.cs

Measures 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
text string
The text, on one line.
font SceneFont
The size, the weight and the style of the font.
letterSpacing double
The space added after each character, in pixels.
wordSpacing double
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

The width is the one of the TextLayout the image renderer draws: without the optional ligatures with a letter spacing, and with the spacing after each cluster of glyphs.