Interface ISpanDrawableFont
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
textReadOnlySpan<char>Text to calculate bounds.
optionsFontRenderingOptionsOptions 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
contextIRenderContextAn instance of the render context to draw font.
textReadOnlySpan<char>Text to draw.
optionsFontRenderingOptionsOptions 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
textReadOnlySpan<char>Text to enumerate glyphs for.
optionsFontRenderingOptionsRendering 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
textReadOnlySpan<char>Text to measure.
optionsFontRenderingOptionsOptions for the measurement.
Returns
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
textReadOnlySpan<char>The text to measure.
optionsFontRenderingOptionsOptions for the measure.
Returns
- Vector2
Maximal size in pixels to draw the string with current font parameters.