Skip to main content

Module color

Module color 

Source
Expand description

Color glyphs.

A COLR glyph is painted through a sequence of PaintSink callbacks for transforms, clips, fills and layers. Version 0 glyphs are layers of solid-filled outlines. Version 1 adds gradients, transforms and compositing. ColorGlyph::paint paints both versions in font units at the font’s location.

§Examples

Paint a glyph:

let glyph = font.color_glyphs().get(glyph).expect("a color glyph");
glyph.paint(sink)

Measure a glyph. This uses the clip box if the glyph has one, and the bounds of what it paints otherwise:

if let Some(glyph) = font.color_glyphs().get(glyph) {
    let extents = glyph.extents().expect("a well formed paint graph");
    println!("{extents:?}");
}

Structs§

Color
CPAL (Color Record) record
ColorGlyph
A color glyph, ready to paint through a PaintSink.
ColorGlyphs
Provides access to the color glyphs in a font.
ColorStop
A color stop of a gradient.
Palette
A single color palette.
PaletteType
The PaletteType flags.
Palettes
Provides access to the color palettes in a font.

Enums§

Brush
A solid color or gradient used to fill a region.
ColorGlyphVersion
The version of COLR that defines a glyph.
CompositeMode
CompositeMode enumeration
Extend
Extend enumeration
PaintCachedColorGlyph
Whether a sink painted a nested color glyph from its own cache.

Traits§

PaintSink
Receives the operations that paint a color glyph.