Module color

Source
Expand description

Drawing color glyphs.

§Examples

§Retrieve the clip box of a COLRv1 glyph if it has one:

match font.color_glyphs()
      .get_with_format(glyph_id, ColorGlyphFormat::ColrV1)
      .expect("Glyph not found.")
      .bounding_box(&Location::default(), size)
{
  Some(bounding_box) => {
      println!("Bounding box is {:?}", bounding_box);
  }
  None => {
      println!("Glyph has no clip box.");
  }
}

§Paint a COLRv1 glyph given a font, and a glyph id and a ColorPainter implementation:

let color_glyph = font.color_glyphs()
                    .get_with_format(glyph_id, ColorGlyphFormat::ColrV1)
                    .expect("Glyph not found");
color_glyph.paint(&Location::default(), color_painter_impl)

Modules§

instance 🔒
COLR table instance.
transform 🔒
Contains a Transform object holding values of an affine transformation matrix.
traversal 🔒

Structs§

ColorGlyph
A representation of a color glyph that can be painted through a sequence of ColorPainter callbacks.
ColorGlyphCollection
Collection of color glyphs.
ColorStop
A color stop of a gradient.
Transform
A transformation matrix to be applied to the drawing canvas.

Enums§

Brush
A fill type of a COLRv1 glyph (solid fill or various gradient types).
ColorGlyphFormat
Distinguishes available color glyph formats.
ColorGlyphRoot 🔒
CompositeMode
CompositeMode enumeration
Extend
Extend enumeration
PaintCachedColorGlyph
Signals success of request to draw a COLRv1 sub glyph from cache.
PaintError
An error during drawing a COLR glyph.

Traits§

ColorPainter
A group of required painting callbacks to be provided by the client.