Skip to main content

OutlineGlyph

Enum OutlineGlyph 

Source
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<'_>

Source

pub fn glyph(&self) -> GlyphId

Returns the glyph identifier.

Source

pub fn source(&self) -> OutlineSource

Returns the table that provides the outline.

Source

pub fn required_memory_size(&self) -> usize

Returns the size in bytes of the working memory needed by draw.

This is zero for charstrings.

Source

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.

Source

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.

Source

pub fn required_memory_size_unscaled(&self) -> usize

Returns the size in bytes of the working memory needed by draw_unscaled.

Source

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.

Source

fn draw_unscaled_dyn( &self, memory: Option<&mut [u8]>, sink: &mut dyn UnscaledOutlineSink, ) -> Result<DrawnMetrics, Error>

Source

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.

Source

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>

Source§

fn clone(&self) -> OutlineGlyph<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for OutlineGlyph<'a>

§

impl<'a> !RefUnwindSafe for OutlineGlyph<'a>

§

impl<'a> !UnwindSafe for OutlineGlyph<'a>

§

impl<'a> Send for OutlineGlyph<'a>

§

impl<'a> Sync for OutlineGlyph<'a>

§

impl<'a> Unpin for OutlineGlyph<'a>

§

impl<'a> UnsafeUnpin for OutlineGlyph<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.