pub struct OutlinePlan<'a> {
pub glyph: GlyphId,
pub glyph_data: Option<Glyph<'a>>,
pub num_points: u32,
pub num_contours: u32,
pub max_simple_points: u32,
pub max_hinted_composite_points: u32,
pub max_component_delta_stack: u32,
pub has_hinting: bool,
pub has_overlaps: bool,
pub applies_variations: bool,
}Expand description
What an outline is made of, and how much scratch space building it needs.
Produced by walking the composite tree without reading point data, which
is cheap enough to do per draw. Self::buffer_lengths sizes the buffers
and Self::load fills them.
Fields§
§glyph: GlyphIdThe glyph this describes.
glyph_data: Option<Glyph<'a>>The root glyph’s glyf data, or None for an empty glyph such as a
space.
A missing or unreadable glyph is an error from OutlinePlan::new,
not None here.
num_points: u32Total points in the outline, summed over every simple glyph in the tree, plus the phantom points.
num_contours: u32Total contours, summed over every simple glyph in the tree.
max_simple_points: u32Largest point count, including phantom points, of any one simple glyph in the tree.
max_hinted_composite_points: u32Largest point count, including phantom points, contributed by any one composite glyph in the tree that carries instructions.
Zero when no composite is instructed. Only a hinted composite keeps
its loaded points in font units, so this is tracked separately from
Self::max_simple_points.
max_component_delta_stack: u32Deepest the per-component delta stack gets while loading nested composites.
has_hinting: boolTrue if any glyph in the tree carries TrueType instructions.
has_overlaps: boolTrue if any glyph in the tree is flagged as having overlapping contours or components.
applies_variations: boolTrue when gvar deltas will be applied: the font has a gvar table
and the context names a location in it.
A variable font read at its default instance needs no delta buffers. This is the one field taken from the context rather than the walk.
Implementations§
Source§impl<'a> OutlinePlan<'a>
impl<'a> OutlinePlan<'a>
Sourcepub fn new(
context: &dyn OutlineContext<'a>,
glyph: GlyphId,
) -> Result<Self, Error>
pub fn new( context: &dyn OutlineContext<'a>, glyph: GlyphId, ) -> Result<Self, Error>
Walks the glyph, and the tree below a composite, collecting what building its outline requires.
Sourcepub fn buffer_lengths<S: Scale>(&self) -> BufferLengths
pub fn buffer_lengths<S: Scale>(&self) -> BufferLengths
Returns how long each scratch buffer has to be to load at S.
Sourcepub fn load<'s, 'buf, S: Scale>(
&'s self,
context: &'a dyn OutlineContext<'a>,
scale: &'s S,
buffers: Buffers<'buf, S>,
hinter: Option<&mut dyn Hinter<S::Coord>>,
) -> Result<OutlineRef<'buf, S::Coord>, Error>
pub fn load<'s, 'buf, S: Scale>( &'s self, context: &'a dyn OutlineContext<'a>, scale: &'s S, buffers: Buffers<'buf, S>, hinter: Option<&mut dyn Hinter<S::Coord>>, ) -> Result<OutlineRef<'buf, S::Coord>, Error>
Builds the outline this plan describes.
The buffers must be at least as long as buffer_lengths says. The
location comes from context. The result borrows buffers and
nothing else.
use read_fonts::{
tables::glyf::outline::{Buffers, OutlinePlan, OutlineTables, Scale26Dot6},
types::{GlyphId, Point},
FontRef,
};
let font = FontRef::new(font_test_data::COLRV0V1_VARIABLE)?;
let tables = OutlineTables::new(&font)?;
let plan = OutlinePlan::new(&tables, GlyphId::new(1))?;
// A static draw, and 26.6 keeps a font unit copy of the points.
let lengths = plan.buffer_lengths::<Scale26Dot6>();
let mut points = vec![Point::default(); lengths.points as usize];
let mut flags = vec![Default::default(); lengths.points as usize];
let mut contours = vec![0; lengths.contours as usize];
let mut unscaled = vec![Point::default(); lengths.unscaled as usize];
let buffers = Buffers {
points: &mut points,
flags: &mut flags,
contours: &mut contours,
unscaled: &mut unscaled,
// Only needed when varying.
deltas: &mut [],
iup: &mut [],
composite_deltas: &mut [],
};
let scale = Scale26Dot6::new(Some(16.0), tables.units_per_em);
let outline = plan.load(&tables, &scale, buffers, None)?;
assert_eq!(outline.points().len(), outline.flags().len());fn walk( &mut self, context: &dyn OutlineContext<'a>, glyph: &Glyph<'a>, component_depth: u32, recurse_depth: usize, components: &mut usize, ) -> Result<(), Error>
Trait Implementations§
Source§impl<'a> Clone for OutlinePlan<'a>
impl<'a> Clone for OutlinePlan<'a>
Source§fn clone(&self) -> OutlinePlan<'a>
fn clone(&self) -> OutlinePlan<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more