Back to API Reference
Class

TextLayout

sealed

Positions glyphs within the layout bounds based on line breaking results and alignment settings.

Remarks

This is the final positioning stage of the text processing pipeline. It takes the output from LineBreaker (lines and runs) and produces PositionedGlyph data with final X/Y coordinates. Handles: Horizontal alignment (left, center, right) with RTL awareness Vertical alignment (top, middle, bottom) Line spacing and margins Glyph scaling based on font size
[ctor]public TextLayout()

Initializes a new instance of the TextLayout class with default settings.

public void SetFontMetrics(float ascender, float descender, float lineHeight, float glyphScaleFactor, float capHeight)

Sets font metrics used for line height and baseline calculations.

public void SetLayoutSettings(LayoutSettings newSettings)

Sets the layout settings controlling dimensions and alignment.

public void SetEffectiveLineHeights(float firstLineHeight, float lastLineHeight)

Sets the effective line heights after modifier callbacks, used for half-leading calculation.

public void Layout(Span<TextLine> lines, ReadOnlySpan<ShapedRun> runs, ReadOnlySpan<ShapedGlyph> glyphs, ReadOnlySpan<float> perLineAdvances, float totalHeight, PositionedGlyph[] result, int glyphCount, float width, float height)

Positions all glyphs from the line breaking results into final screen coordinates.

public static float ComputeTrimAmount(float ascender, float descender, float capHeight, TextOverEdge overEdge, TextUnderEdge underEdge, LeadingDistribution distribution, float effectiveFirstLineHeight, float effectiveLastLineHeight)

Computes the total height trim based on edge metrics and leading distribution.

See Also