Class TextMeasurer
Encapsulated logic for laying out and then measuring text properties.
Inherited Members
Namespace: SixLabors.Fonts
Assembly: SixLabors.Fonts.dll
Syntax
public static class TextMeasurer
Methods
| Edit this page View SourceCountLines(ReadOnlySpan<char>, TextOptions)
Gets the number of lines contained within the text.
Declaration
public static int CountLines(ReadOnlySpan<char> text, TextOptions options)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<char> | text | The text. |
TextOptions | options | The text shaping options. |
Returns
Type | Description |
---|---|
int | The line count. |
CountLines(string, TextOptions)
Gets the number of lines contained within the text.
Declaration
public static int CountLines(string text, TextOptions options)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text. |
TextOptions | options | The text shaping options. |
Returns
Type | Description |
---|---|
int | The line count. |
MeasureAdvance(ReadOnlySpan<char>, TextOptions)
Measures the advance (line-height and horizontal/vertical advance) of the text in pixel units.
Declaration
public static FontRectangle MeasureAdvance(ReadOnlySpan<char> text, TextOptions options)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<char> | text | The text. |
TextOptions | options | The text shaping options. |
Returns
Type | Description |
---|---|
FontRectangle | The advance of the text if it was to be rendered. |
MeasureAdvance(string, TextOptions)
Measures the advance (line-height and horizontal/vertical advance) of the text in pixel units.
Declaration
public static FontRectangle MeasureAdvance(string text, TextOptions options)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text. |
TextOptions | options | The text shaping options. |
Returns
Type | Description |
---|---|
FontRectangle | The advance of the text if it was to be rendered. |
MeasureBounds(ReadOnlySpan<char>, TextOptions)
Measures the text bounds in sub-pixel units.
Declaration
public static FontRectangle MeasureBounds(ReadOnlySpan<char> text, TextOptions options)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<char> | text | The text. |
TextOptions | options | The text shaping options. |
Returns
Type | Description |
---|---|
FontRectangle | The bounds of the text if it was to be rendered. |
MeasureBounds(string, TextOptions)
Measures the text bounds in sub-pixel units.
Declaration
public static FontRectangle MeasureBounds(string text, TextOptions options)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text. |
TextOptions | options | The text shaping options. |
Returns
Type | Description |
---|---|
FontRectangle | The bounds of the text if it was to be rendered. |
MeasureSize(ReadOnlySpan<char>, TextOptions)
Measures the minimum size required, in pixel units, to render the text.
Declaration
public static FontRectangle MeasureSize(ReadOnlySpan<char> text, TextOptions options)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<char> | text | The text. |
TextOptions | options | The text shaping options. |
Returns
Type | Description |
---|---|
FontRectangle | The size of the text if it was to be rendered. |
MeasureSize(string, TextOptions)
Measures the minimum size required, in pixel units, to render the text.
Declaration
public static FontRectangle MeasureSize(string text, TextOptions options)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text. |
TextOptions | options | The text shaping options. |
Returns
Type | Description |
---|---|
FontRectangle | The size of the text if it was to be rendered. |
TryMeasureCharacterAdvances(ReadOnlySpan<char>, TextOptions, out ReadOnlySpan<GlyphBounds>)
Measures the advance (line-height and horizontal/vertical advance) of each character of the text in pixel units.
Declaration
public static bool TryMeasureCharacterAdvances(ReadOnlySpan<char> text, TextOptions options, out ReadOnlySpan<GlyphBounds> advances)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<char> | text | The text. |
TextOptions | options | The text shaping options. |
ReadOnlySpan<GlyphBounds> | advances | The list of character advances of the text if it was to be rendered. |
Returns
Type | Description |
---|---|
bool | Whether any of the characters had non-empty advances. |
TryMeasureCharacterAdvances(string, TextOptions, out ReadOnlySpan<GlyphBounds>)
Measures the advance (line-height and horizontal/vertical advance) of each character of the text in pixel units.
Declaration
public static bool TryMeasureCharacterAdvances(string text, TextOptions options, out ReadOnlySpan<GlyphBounds> advances)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text. |
TextOptions | options | The text shaping options. |
ReadOnlySpan<GlyphBounds> | advances | The list of character advances of the text if it was to be rendered. |
Returns
Type | Description |
---|---|
bool | Whether any of the characters had non-empty advances. |
TryMeasureCharacterBounds(ReadOnlySpan<char>, TextOptions, out ReadOnlySpan<GlyphBounds>)
Measures the character bounds of the text in sub-pixel units.
Declaration
public static bool TryMeasureCharacterBounds(ReadOnlySpan<char> text, TextOptions options, out ReadOnlySpan<GlyphBounds> bounds)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<char> | text | The text. |
TextOptions | options | The text shaping options. |
ReadOnlySpan<GlyphBounds> | bounds | The list of character bounds of the text if it was to be rendered. |
Returns
Type | Description |
---|---|
bool | Whether any of the characters had non-empty bounds. |
TryMeasureCharacterBounds(string, TextOptions, out ReadOnlySpan<GlyphBounds>)
Measures the character bounds of the text in sub-pixel units.
Declaration
public static bool TryMeasureCharacterBounds(string text, TextOptions options, out ReadOnlySpan<GlyphBounds> bounds)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text. |
TextOptions | options | The text shaping options. |
ReadOnlySpan<GlyphBounds> | bounds | The list of character bounds of the text if it was to be rendered. |
Returns
Type | Description |
---|---|
bool | Whether any of the characters had non-empty bounds. |
TryMeasureCharacterSizes(ReadOnlySpan<char>, TextOptions, out ReadOnlySpan<GlyphBounds>)
Measures the minimum size required, in pixel units, to render each character in the text.
Declaration
public static bool TryMeasureCharacterSizes(ReadOnlySpan<char> text, TextOptions options, out ReadOnlySpan<GlyphBounds> sizes)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<char> | text | The text. |
TextOptions | options | The text shaping options. |
ReadOnlySpan<GlyphBounds> | sizes | The list of character dimensions of the text if it was to be rendered. |
Returns
Type | Description |
---|---|
bool | Whether any of the characters had non-empty dimensions. |
TryMeasureCharacterSizes(string, TextOptions, out ReadOnlySpan<GlyphBounds>)
Measures the minimum size required, in pixel units, to render each character in the text.
Declaration
public static bool TryMeasureCharacterSizes(string text, TextOptions options, out ReadOnlySpan<GlyphBounds> sizes)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text. |
TextOptions | options | The text shaping options. |
ReadOnlySpan<GlyphBounds> | sizes | The list of character dimensions of the text if it was to be rendered. |
Returns
Type | Description |
---|---|
bool | Whether any of the characters had non-empty dimensions. |