Class PaintColorGlyph
A COLR glyph: its paint graph and, for version 1, the clip box the font gives.
public sealed record PaintColorGlyph : ColorGlyph, IEquatable<ColorGlyph>, IEquatable<PaintColorGlyph>
- Inheritance
-
PaintColorGlyph
- Implements
- Inherited Members
Examples
// Color glyphs draw in color by themselves: COLR (layers and gradients), sbix and CBDT (images), per glyph.
using (RasterCanvas<Rgba8> canvas = image.CreateCanvas())
{
canvas.DrawText("Ship it", new Vector2(8, 40), new Font(text, 24), Rgba8.Black);
canvas.DrawText("\U0001F680\U0001F389", new Vector2(100, 42), new Font(emoji, 32), Rgba8.Black);
}
// The palette is a font setting; the paint's color fills a glyph's foreground parts and its alpha the whole glyph.
var darkMode = new Font(emoji, 32) { Palette = FontPalette.Dark };
ColorGlyphFormats formats = emoji.ColorFormats;
// The paint graph is there to walk, for writers that draw color glyphs their own way.
emoji.TryGetColorGlyph(emoji.GetGlyph(0x1F680), darkMode.Palette, out ColorGlyph? rocket);
Constructors
PaintColorGlyph(ushort, ColorGlyphFormats, ColorPaint, GlyphExtents?)
A COLR glyph: its paint graph and, for version 1, the clip box the font gives.
public PaintColorGlyph(ushort Glyph, ColorGlyphFormats Format, ColorPaint Paint, GlyphExtents? ClipBox)
Parameters
GlyphushortThe glyph.
FormatColorGlyphFormatsPaintColorPaintThe paint graph's root.
ClipBoxGlyphExtents?The ClipList box in font units, or null.
Examples
// Color glyphs draw in color by themselves: COLR (layers and gradients), sbix and CBDT (images), per glyph.
using (RasterCanvas<Rgba8> canvas = image.CreateCanvas())
{
canvas.DrawText("Ship it", new Vector2(8, 40), new Font(text, 24), Rgba8.Black);
canvas.DrawText("\U0001F680\U0001F389", new Vector2(100, 42), new Font(emoji, 32), Rgba8.Black);
}
// The palette is a font setting; the paint's color fills a glyph's foreground parts and its alpha the whole glyph.
var darkMode = new Font(emoji, 32) { Palette = FontPalette.Dark };
ColorGlyphFormats formats = emoji.ColorFormats;
// The paint graph is there to walk, for writers that draw color glyphs their own way.
emoji.TryGetColorGlyph(emoji.GetGlyph(0x1F680), darkMode.Palette, out ColorGlyph? rocket);
Properties
ClipBox
The ClipList box in font units, or null.
public GlyphExtents? ClipBox { get; init; }
Property Value
Paint
The paint graph's root.
public ColorPaint Paint { get; init; }