TextMeasurerExtensions Class
Extension methods for ITextMeasurer.
public static class TextMeasurerExtensionsMethods
| Name | Description |
|---|---|
| Measure(ITextMeasurer, SceneText) | Measures a text as the renderers draw it: its spans one after the other, with their fonts and their spacing. |
| Measure(ITextMeasurer, IEnumerable<SceneTextSpan>, SceneFont) | Measures a text made of spans: the spans one after the other, on the same baseline. |
| Measure(ITextMeasurer, 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: see ITextMeasurer.Measure. |
| WithFontFamily(ITextMeasurer, string?) | Returns a measurer whose family is fontFamily: it measures the texts that name no family (SceneFont.Family is null) as texts of that family. Use its ITextMeasurer.FontFamily as the family of the scene (Scene.FontFamily), so the renderers draw these texts with the family that measured them. |
Measure overloads
Measure(ITextMeasurer, SceneText)
TextMeasurerExtensions.csMeasures a text as the renderers draw it: its spans one after the other, with their fonts and their spacing.
public static TextMetrics Measure(this ITextMeasurer measurer, SceneText text)Parameters
measurerITextMeasurer- The measurer.
textSceneText- The text.
Returns
TextMetrics The sum of the widths of the spans, with their spacing, and the largest ascent and descent. A text fitted to a length (SceneText.TextLength), or whose spans are moved horizontally (SceneTextSpan.X, SceneTextSpan.Dx), has the width from the left of its leftmost span to the right of its rightmost one.
Measure(ITextMeasurer, IEnumerable<SceneTextSpan>, SceneFont)
TextMeasurerExtensions.csMeasures a text made of spans: the spans one after the other, on the same baseline.
public static TextMetrics Measure(this ITextMeasurer measurer, IEnumerable<SceneTextSpan> spans, SceneFont font)Parameters
measurerITextMeasurer- The measurer.
spansIEnumerable<SceneTextSpan>- The spans.
fontSceneFont- The font of the spans that set none.
Returns
TextMetrics The sum of the widths of the spans, with their spacing, and the largest ascent and descent.
Remarks
A span without spacing (SceneTextSpan.LetterSpacing, SceneTextSpan.WordSpacing) has none: measure a SceneText to apply its spacing.
Measure(ITextMeasurer, string, SceneFont, double, double)
TextMeasurerExtensions.csMeasures a line of text with a letter spacing and a word spacing (SceneText.LetterSpacing, SceneText.WordSpacing), as the renderers draw it: see ITextMeasurer.Measure.
public static TextMetrics Measure(this ITextMeasurer measurer, string text, SceneFont font, double letterSpacing, double wordSpacing)Parameters
measurerITextMeasurer- The measurer.
textstring- The text, on one line.
fontSceneFont- The font.
letterSpacingdouble- The space added after each grapheme cluster, in pixels.
wordSpacingdouble- The space added to each space (U+0020 and U+00A0), in pixels.
Returns
TextMetrics The dimensions of the text: its width includes the spacing.
WithFontFamily(ITextMeasurer, string?)
TextMeasurerExtensions.csReturns a measurer whose family is fontFamily: it measures the texts that name no family (SceneFont.Family is null) as texts of that family. Use its ITextMeasurer.FontFamily as the family of the scene (Scene.FontFamily), so the renderers draw these texts with the family that measured them.
public static ITextMeasurer WithFontFamily(this ITextMeasurer measurer, string? fontFamily)Parameters
measurerITextMeasurer- The measurer.
fontFamilystring?- The CSS
font-familyof the texts, ornullto keep the family of the measurer.
Returns
ITextMeasurer The measurer.
Remarks
With fonts (ITextMeasurer.Fonts), the texts are measured with the first family of the list the fonts have, or their default family. A measurer without fonts, such as AfmTextMeasurer, measures every family with its own metrics.