Class SvgGlyphRenderer
Draws the glyphs of an OpenType SVG table (question 20): each glyph's document is read once per font and kept, and the
element glyphid is drawn in the font's units, its origin on the baseline. Set it on
ColorGlyphRenderer; Rasterize<TPixel>(SvgRenderOptions?) uses it already.
public sealed class SvgGlyphRenderer : IColorGlyphRenderer
- Inheritance
-
SvgGlyphRenderer
- Implements
- Inherited Members
Examples
// Emoji and other glyphs from an OpenType SVG table draw in color on a canvas given the renderer.
using (RasterCanvas<Rgba8> canvas = raster.CreateCanvas(new CanvasOptions { ColorGlyphRenderer = SvgGlyphRenderer.Instance }))
{
canvas.DrawText("Hello", new System.Numerics.Vector2(10, 35), font, new SolidPaint(new RgbaF32(0, 0, 0, 1)));
}
Properties
Formats
Gets the color formats the renderer draws, such as Svg.
public ColorGlyphFormats Formats { get; }
Property Value
Instance
Gets the renderer.
public static SvgGlyphRenderer Instance { get; }
Property Value
Methods
TryDraw(Canvas, Font, ushort, Matrix3x2, Paint)
Draws one glyph, or returns false when the font has nothing of the renderer's formats for it.
public bool TryDraw(Canvas canvas, Font font, ushort glyph, Matrix3x2 transform, Paint paint)
Parameters
canvasCanvasThe canvas to draw on.
fontFontThe font, at its size.
glyphushortThe glyph id.
transformMatrix3x2Maps the glyph's space (its origin on the baseline, the font's size, y down) into the canvas's local coordinates.
paintPaintThe text's paint: its color is the foreground some glyphs draw in.
Returns
- bool
True when the glyph was drawn.