Table of Contents

Interface ISpanDrawableFont

Namespace
Icy.Rendering.Fonts
Assembly
IcyUI.dll

Represents a high-performant implementation of the IFont interface.

public interface ISpanDrawableFont : IFont
Inherited Members
Extension Methods

Remarks

This implementation supports methods to handle text spans which can improve memory and time usage.

Methods

CalculateBounds(ReadOnlySpan<char>, in FontRenderingOptions)

Calculates estimated bounds for the string to render.

Rectangle CalculateBounds(ReadOnlySpan<char> text, in FontRenderingOptions options)

Parameters

text ReadOnlySpan<char>

Text to calculate bounds.

options FontRenderingOptions

Options for the calculations.

Returns

Rectangle

Estimated bounds required for drawing.

DrawString(IRenderContext, ReadOnlySpan<char>, in FontRenderingOptions)

Draws specified text using this font instance.

void DrawString(IRenderContext context, ReadOnlySpan<char> text, in FontRenderingOptions options)

Parameters

context IRenderContext

An instance of the render context to draw font.

text ReadOnlySpan<char>

Text to draw.

options FontRenderingOptions

Options for the rendering.

GetRenderGlyphs(ReadOnlySpan<char>, in FontRenderingOptions)

Enumerates glyphs to render for the specified text.

List<RenderGlyph> GetRenderGlyphs(ReadOnlySpan<char> text, in FontRenderingOptions options)

Parameters

text ReadOnlySpan<char>

Text to enumerate glyphs for.

options FontRenderingOptions

Rendering options to apply.

Returns

List<RenderGlyph>

An enumeration for all the rendered glyphs.

MeasureAdvance(ReadOnlySpan<char>, in FontRenderingOptions)

Measures the raw cursor advance for the specified text - how far the text cursor (caret) moves after "typing" every character, including trailing whitespace that has no visible ink of its own.

Vector2 MeasureAdvance(ReadOnlySpan<char> text, in FontRenderingOptions options)

Parameters

text ReadOnlySpan<char>

Text to measure.

options FontRenderingOptions

Options for the measurement.

Returns

Vector2

The cursor's total displacement from Position.

Remarks

Unlike MeasureString(string, in FontRenderingOptions)/CalculateBounds(string, in FontRenderingOptions) - which report the tightest box containing actual glyph ink, appropriate for auto-sizing content to what's visually drawn - this always reflects the true pen position, even past a glyph whose own ink extends beyond its own advance width. Caret placement and "reserve room for what was typed" sizing (e.g. TextBox) must use this, not the ink-based measurements: a glyph that overhangs its advance can otherwise make a trailing, inkless character (like a space) appear to not move the cursor at all, because the ink-based bounds were already wider than the true cursor position.

MeasureString(ReadOnlySpan<char>, in FontRenderingOptions)

Gets the space required to draw string with this font.

Vector2 MeasureString(ReadOnlySpan<char> text, in FontRenderingOptions options)

Parameters

text ReadOnlySpan<char>

The text to measure.

options FontRenderingOptions

Options for the measure.

Returns

Vector2

Maximal size in pixels to draw the string with current font parameters.