Class BitmapColorGlyph
An sbix or CBDT glyph: its image, the strike's size and where the image goes, in font units with y up, so it scales with the font; the drawing code decodes and resamples it.
public sealed record BitmapColorGlyph : ColorGlyph, IEquatable<ColorGlyph>, IEquatable<BitmapColorGlyph>
- Inheritance
-
BitmapColorGlyph
- 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
BitmapColorGlyph(ushort, ColorGlyphFormats, ReadOnlyMemory<byte>, BitmapGlyphEncoding, int, int, int, GlyphExtents)
An sbix or CBDT glyph: its image, the strike's size and where the image goes, in font units with y up, so it scales with the font; the drawing code decodes and resamples it.
public BitmapColorGlyph(ushort Glyph, ColorGlyphFormats Format, ReadOnlyMemory<byte> Data, BitmapGlyphEncoding Encoding, int PixelWidth, int PixelHeight, int PixelsPerEm, GlyphExtents Bounds)
Parameters
GlyphushortThe glyph.
FormatColorGlyphFormatsDataReadOnlyMemory<byte>The image bytes, a slice of the font's memory.
EncodingBitmapGlyphEncodingThe image's encoding.
PixelWidthintThe image's width in pixels.
PixelHeightintThe image's height in pixels.
PixelsPerEmintThe strike's size.
BoundsGlyphExtentsWhere the image's edges go, in font units, y up.
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
Bounds
Where the image's edges go, in font units, y up.
public GlyphExtents Bounds { get; init; }
Property Value
Data
The image bytes, a slice of the font's memory.
public ReadOnlyMemory<byte> Data { get; init; }
Property Value
Encoding
The image's encoding.
public BitmapGlyphEncoding Encoding { get; init; }
Property Value
PixelHeight
The image's height in pixels.
public int PixelHeight { get; init; }
Property Value
PixelWidth
The image's width in pixels.
public int PixelWidth { get; init; }
Property Value
PixelsPerEm
The strike's size.
public int PixelsPerEm { get; init; }