Class StbTrueTypeRasterizer
Represents a glyph rasterizer that uses StbTrueTypeSharp for TrueType font rendering.
public class StbTrueTypeRasterizer : IGlyphRasterizer, IDisposable
- Inheritance
-
StbTrueTypeRasterizer
- Implements
- Inherited Members
- Extension Methods
Constructors
StbTrueTypeRasterizer(byte[])
Initializes a new instance of the StbTrueTypeRasterizer class.
public StbTrueTypeRasterizer(byte[] fontData)
Parameters
fontDatabyte[]The font data.
Methods
ContainsGlyph(int)
Checks if the character is supported in this font.
public bool ContainsGlyph(int codepoint)
Parameters
codepointintUnicode character codepoint to check.
Returns
- bool
true if the character with the specified codepoint is supported by this font instance; otherwise false.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Performs internal resources clean-up operations.
protected virtual void Dispose(bool disposing)
Parameters
disposingboolIndicates whether the disposing was initialized by user or finalizer.
~StbTrueTypeRasterizer()
Finalizes an instance of the StbTrueTypeRasterizer class.
protected ~StbTrueTypeRasterizer()
Remarks
This rasterizer uses C STB_TrueType library which needs manual font data release.
GetFontMetrics(float, FontStyle)
Gets metrics for the font with the specified font size.
public FontMetrics GetFontMetrics(float fontSize, FontStyle style)
Parameters
fontSizefloatExpected font size in points to calculate scaled metrics for.
styleFontStyleThe style of the font to use.
Returns
- FontMetrics
An instance of the FontMetrics struct with font calculated metrics.
GetGlyphMetrics(int, float, FontStyle)
Gets the metrics for a glyph at the specified size and style.
public FontGlyph GetGlyphMetrics(int codepoint, float size, FontStyle style)
Parameters
codepointintThe Unicode codepoint of the glyph.
sizefloatThe size of the glyph in pixels.
styleFontStyleThe style of the font.
Returns
- FontGlyph
The metrics for the glyph.
GetKerning(int, int, float, FontStyle)
Gets the kerning between two glyphs.
public float GetKerning(int first, int second, float size, FontStyle style)
Parameters
firstintFirst glyph codepoint.
secondintSecond glyph codepoint.
sizefloatFont size.
styleFontStyleFont style.
Returns
- float
The kerning value in pixels.
RasterizeGlyph(int, float, FontStyle)
Rasterizes a glyph at the specified size and style.
public IMemoryOwner<byte>? RasterizeGlyph(int codepoint, float size, FontStyle style)
Parameters
codepointintThe Unicode codepoint of the glyph to rasterize.
sizefloatThe size of the glyph in pixels.
styleFontStyleThe style of the glyph.
Returns
- IMemoryOwner<byte>
The rasterized glyph pixels byte sequence.