pub enum OutlineGlyph<'a> {
Glyf(GlyfGlyph<'a>),
Cff(CffGlyph<'a>),
Type1(Type1Glyph<'a>),
Varc(VarcGlyph<'a>),
}Expand description
A glyph outline from a specific source.
Each variant contains the data needed to draw that source: a glyf
plan, a CFF subfont, or a composite tree. To hint an outline, match on
the variant and use the source’s own types.
Variants§
Glyf(GlyfGlyph<'a>)
A TrueType outline.
Cff(CffGlyph<'a>)
A CFF or CFF2 charstring.
Type1(Type1Glyph<'a>)
A Type 1 charstring.
Varc(VarcGlyph<'a>)
A VARC composite.
Implementations§
Source§impl OutlineGlyph<'_>
impl OutlineGlyph<'_>
Sourcepub fn source(&self) -> OutlineSource
pub fn source(&self) -> OutlineSource
Returns the table that provides the outline.
Sourcepub fn required_memory_size(&self) -> usize
pub fn required_memory_size(&self) -> usize
Returns the size in bytes of the working memory needed by
draw.
This is zero for charstrings.
Sourcepub fn draw(
&self,
options: &DrawOptions,
memory: DrawMemory<'_>,
sink: &mut dyn PathSink,
) -> Result<DrawnMetrics, Error>
pub fn draw( &self, options: &DrawOptions, memory: DrawMemory<'_>, sink: &mut dyn PathSink, ) -> Result<DrawnMetrics, Error>
Draws the unhinted outline into sink with the given options.
Supplied memory must hold at least
required_memory_size bytes, or the draw
fails with Error::InsufficientMemory.
Returns any metrics provided by the outline.
Sourcefn draw_dyn(
&self,
options: &DrawOptions,
precision: Precision,
memory: Option<&mut [u8]>,
sink: &mut dyn PathSink,
) -> Result<DrawnMetrics, Error>
fn draw_dyn( &self, options: &DrawOptions, precision: Precision, memory: Option<&mut [u8]>, sink: &mut dyn PathSink, ) -> Result<DrawnMetrics, Error>
Implements draw with the given arithmetic precision.
Takes a trait object so the sources are compiled once rather than once per sink type.
Sourcepub fn required_memory_size_unscaled(&self) -> usize
pub fn required_memory_size_unscaled(&self) -> usize
Returns the size in bytes of the working memory needed by
draw_unscaled.
Sourcepub fn draw_unscaled(
&self,
memory: DrawMemory<'_>,
sink: &mut dyn UnscaledOutlineSink,
) -> Result<DrawnMetrics, Error>
pub fn draw_unscaled( &self, memory: DrawMemory<'_>, sink: &mut dyn UnscaledOutlineSink, ) -> Result<DrawnMetrics, Error>
Sends the outline’s points to sink in font units.
A glyf outline provides its points as stored, with variations
applied. Other sources are drawn as a path in font units and converted
to points. When a contour closes at its start point, that point is not
repeated.
memory works as in draw, with a size given by
required_memory_size_unscaled.
A VARC composite has no advance of its own, so the returned metrics
have none. Its advance is the one in the font’s metrics tables, from
GlyphMetrics::h_advance.
fn draw_unscaled_dyn( &self, memory: Option<&mut [u8]>, sink: &mut dyn UnscaledOutlineSink, ) -> Result<DrawnMetrics, Error>
Sourcepub fn extents(&self) -> Result<GlyphExtents<f32>, Error>
pub fn extents(&self) -> Result<GlyphExtents<f32>, Error>
Returns the extents of the outline in font units.
The extents are computed from the control points, so a curve’s control points are included rather than the curve itself. An empty glyph has zero extents.
Sourcepub(crate) fn control_box(&self) -> Result<Option<BoundingBox<f32>>, Error>
pub(crate) fn control_box(&self) -> Result<Option<BoundingBox<f32>>, Error>
Returns the bounding box of the control points.
This is used for clips that intersect boxes.
Trait Implementations§
Source§impl<'a> Clone for OutlineGlyph<'a>
impl<'a> Clone for OutlineGlyph<'a>
Source§fn clone(&self) -> OutlineGlyph<'a>
fn clone(&self) -> OutlineGlyph<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more