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
| Name | Description |
|---|---|
| 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.csInitializes a new instance of the ImageTextMeasurer class.
ImageTextMeasurer(Font, Font?, Font?, Font?)
ImageTextMeasurer.csInitializes a new instance of the ImageTextMeasurer class.
ImageTextMeasurer(SceneFontCollection)
ImageTextMeasurer.csInitializes a new instance of the ImageTextMeasurer class that measures the texts with the fonts of a collection.
public ImageTextMeasurer(SceneFontCollection fonts)Parameters
fontsSceneFontCollection- 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
| Name | Description |
|---|---|
| FontFamily | Gets the family of the texts: the family name of the regular font, or the families of ImageTextMeasurer.Fonts. |
| Fonts | Gets the fonts the texts are measured with, or null when the measurer was created from fonts of Meziantou.Framework.Imaging. |
FontFamily
ImageTextMeasurer.csGets the family of the texts: the family name of the regular font, or the families of ImageTextMeasurer.Fonts.
public string FontFamily { get; }Property value
Fonts
ImageTextMeasurer.csGets 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
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)
ImageTextMeasurer.csMeasures a line of text.
public TextMetrics Measure(string text, SceneFont font)Measure(string, SceneFont, double, double)
ImageTextMeasurer.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
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.