Class TextMetrics
Encapsulates the full set of measurement results for laid-out text.
public sealed class TextMetrics
- Inheritance
-
TextMetrics
- Inherited Members
Properties
Advance
Gets the logical advance rectangle of the text in pixel units.
public FontRectangle Advance { get; }
Property Value
Remarks
Reflects line-box height and horizontal or vertical text advance from the layout model. Does not guarantee that all rendered glyph pixels fit within the returned rectangle.
Bounds
Gets the rendered glyph bounds of the text in pixel units.
public FontRectangle Bounds { get; }
Property Value
Remarks
This is the tight ink bounds enclosing all rendered glyphs and may be smaller or larger than the logical advance. May have a non-zero origin.
GraphemeMetrics
Gets the grapheme metrics entries in final layout order.
public ReadOnlySpan<GraphemeMetrics> GraphemeMetrics { get; }
Property Value
LineCount
Gets the number of laid-out lines in the text.
public int LineCount { get; }
Property Value
LineMetrics
Gets the per-line layout metrics for the text.
public ReadOnlySpan<LineMetrics> LineMetrics { get; }
Property Value
RenderableBounds
Gets the union of the logical advance rectangle (positioned at the text options origin) and the rendered glyph bounds in pixel units.
public FontRectangle RenderableBounds { get; }
Property Value
Remarks
Use this rectangle when both typographic advance and rendered glyph overshoot must fit within the same bounding box.
WordMetrics
Gets the word-boundary segment metrics in source order.
public ReadOnlySpan<WordMetrics> WordMetrics { get; }
Property Value
Methods
GetCaret(CaretPlacement)
Gets an absolute caret position in the laid-out text.
public CaretPosition GetCaret(CaretPlacement placement)
Parameters
placementCaretPlacementThe absolute caret placement.
Returns
- CaretPosition
The caret position in pixel units.
GetCaretPosition(TextHit)
Gets the caret position for the supplied hit.
public CaretPosition GetCaretPosition(TextHit hit)
Parameters
hitTextHitThe hit-tested grapheme position.
Returns
- CaretPosition
The caret position in pixel units.
GetGlyphMetrics()
Gets the positioned metrics of each laid-out glyph entry.
public ReadOnlyMemory<GlyphMetrics> GetGlyphMetrics()
Returns
- ReadOnlyMemory<GlyphMetrics>
A read-only memory region containing per-glyph metrics entries.
GetSelectionBounds(CaretPosition, CaretPosition)
Gets selection bounds between two caret positions.
public ReadOnlyMemory<FontRectangle> GetSelectionBounds(CaretPosition anchor, CaretPosition focus)
Parameters
anchorCaretPositionThe fixed selection endpoint.
focusCaretPositionThe active selection endpoint.
Returns
- ReadOnlyMemory<FontRectangle>
A read-only memory region containing the selection bounds in visual order and pixel units.
GetSelectionBounds(GraphemeMetrics)
Gets selection bounds for the supplied grapheme metrics.
public ReadOnlyMemory<FontRectangle> GetSelectionBounds(GraphemeMetrics metrics)
Parameters
metricsGraphemeMetricsThe grapheme metrics to select.
Returns
- ReadOnlyMemory<FontRectangle>
A read-only memory region containing the selection bounds in visual order and pixel units.
GetSelectionBounds(TextHit, TextHit)
Gets selection bounds between two hit-tested grapheme positions.
public ReadOnlyMemory<FontRectangle> GetSelectionBounds(TextHit anchor, TextHit focus)
Parameters
Returns
- ReadOnlyMemory<FontRectangle>
A read-only memory region containing the selection bounds in visual order and pixel units.
GetSelectionBounds(WordMetrics)
Gets selection bounds for the supplied word metrics.
public ReadOnlyMemory<FontRectangle> GetSelectionBounds(WordMetrics metrics)
Parameters
metricsWordMetricsThe word metrics to select.
Returns
- ReadOnlyMemory<FontRectangle>
A read-only memory region containing the selection bounds in visual order and pixel units.
GetWordMetrics(CaretPosition)
Gets the word metrics for the word-boundary segment containing the supplied caret position.
public WordMetrics GetWordMetrics(CaretPosition caret)
Parameters
caretCaretPositionThe caret position.
Returns
- WordMetrics
The word metrics containing the caret's grapheme insertion index.
GetWordMetrics(TextHit)
Gets the word metrics for the word-boundary segment containing the supplied hit-tested grapheme position.
public WordMetrics GetWordMetrics(TextHit hit)
Parameters
hitTextHitThe hit-tested grapheme position.
Returns
- WordMetrics
The word metrics containing the hit grapheme.
HitTest(Vector2)
Hit tests the supplied point against the laid-out grapheme advance bounds.
public TextHit HitTest(Vector2 point)
Parameters
pointVector2The point in pixel units.
Returns
- TextHit
The hit-tested grapheme position.
MoveCaret(CaretPosition, CaretMovement)
Moves the supplied caret by the requested operation.
public CaretPosition MoveCaret(CaretPosition caret, CaretMovement movement)
Parameters
caretCaretPositionThe current caret position.
movementCaretMovementThe movement operation.
Returns
- CaretPosition
The moved caret position in pixel units.