Skip to main content

Outlines

Struct Outlines 

Source
pub(crate) struct Outlines<'a> {
    varc: Varc<'a>,
    coverage: CoverageTable<'a>,
    var_store: Option<MultiItemVariationStore<'a>>,
    regions: Option<SparseVariationRegionList<'a>>,
    units_per_em: u16,
    axis_count: usize,
    index_count: usize,
}
Expand description

Provides access to the variable composite glyphs in a font.

Fields§

§varc: Varc<'a>§coverage: CoverageTable<'a>§var_store: Option<MultiItemVariationStore<'a>>§regions: Option<SparseVariationRegionList<'a>>§units_per_em: u16§axis_count: usize§index_count: usize

The length of the longest axis index list in the table.

A list longer than axis_count repeats an axis, and the later value wins.

Implementations§

Source§

impl<'a> Outlines<'a>

Source

pub(crate) fn new( varc: Varc<'a>, units_per_em: u16, axis_count: usize, ) -> Result<Self, ReadError>

Creates a new set of composite glyphs from varc.

axis_count is the number of variation axes that components can set. A font without fvar can still have axes in gvar or the CFF2 variation store.

Source

pub(crate) fn covers(&self, glyph: GlyphId) -> bool

Returns true if the table covers glyph.

Source

pub(crate) fn outline(&self, glyph: GlyphId) -> Option<Outline>

Returns the outline for glyph.

Returns None if the table does not cover the glyph. The tree is read only when the glyph is drawn or its memory size is requested.

Source

fn layout_of( &self, outline: &Outline, context: &dyn VarcContext, ) -> Result<Layout, Error>

Returns the memory layout for drawing outline, measuring its tree the first time.

Fails if the glyph data is malformed or the tree passes the recursion or edge limits. Every component counts, whatever its condition, so the answer is the same at every location.

Source

pub(crate) fn required_memory_size( &self, outline: &Outline, context: &dyn VarcContext, ) -> usize

Returns the size in bytes of the memory for drawing outline, or zero if it cannot be drawn.

Source

fn layout(&self, depth: usize, leaf: usize) -> Layout

Returns the memory layout for a composite.

depth is the nesting depth and leaf is the size in bytes of the largest leaf.

Source

fn region_count(&self) -> usize

Returns the number of variation regions, or zero if the table has no variation store.

Source

fn measure( &self, glyph: GlyphId, coverage_index: u32, context: &dyn VarcContext, walk: &mut Walk, ) -> Result<usize, ReadError>

Measures the tree under a composite.

Returns the size in bytes of the largest leaf and records the deepest nesting in walk. Every component is counted regardless of its condition, so the result is valid for any location.

Source

pub(crate) fn draw( &self, outline: &Outline, context: &dyn VarcContext, ppem: Option<f32>, buf: &mut [u8], sink: &mut dyn PathSink, ) -> Result<(), Error>

Draws outline into sink at the location provided by context.

The glyphs at the leaves are drawn by context. ppem is the size of the leaves, or None for font units. It also scales the component offsets. buf must hold at least required_memory_size bytes.

Source

fn draw_tree( &self, outline: &Outline, layout: &Layout, context: &dyn VarcContext, ppem: Option<f32>, memory: Memory<'_>, sink: &mut dyn PathSink, ) -> Result<(), Error>

Implements draw with memory that is already split into slices.

Source

fn draw_glyph( &self, glyph: GlyphId, coverage_index: u32, current_coords: &[F2Dot14], parent_matrix: Matrix<f32>, draw: &DrawContext<'a, '_>, scalar_cache: &mut ScalarCache<'_>, levels: Levels<'_>, leaf: &mut [u8], sink: &mut dyn PathSink, stack: &mut GlyphStack, scratch: &mut Scratch<'_>, ) -> Result<(), Error>

Source

fn component_coords( &self, component: &VarcComponent<'_>, current_coords: &[F2Dot14], coords: &mut [F2Dot14], scalar_cache: &mut ScalarCache<'_>, scratch: &mut Scratch<'_>, font_coords: &[F2Dot14], store_regions: Option<(&MultiItemVariationStore<'a>, &SparseVariationRegionList<'a>)>, ) -> Result<(), Error>

Writes the coordinates for drawing component to coords.

coords holds one value per axis.

Source

fn axis_indices(&self, nth: usize, out: &mut [u16]) -> Result<usize, ReadError>

Reads the nth list of axis indices into out and returns the number of indices.

Source

fn component_condition_met( &self, component: &VarcComponent<'_>, coords: &[F2Dot14], scalar_cache: &mut ScalarCache<'_>, scratch: &mut Scratch<'_>, store_regions: Option<(&MultiItemVariationStore<'a>, &SparseVariationRegionList<'a>)>, ) -> Result<bool, Error>

Source§

impl<'a> Outlines<'a>

Source

pub(crate) fn read(tables: &impl TableProvider<'a>) -> Option<Self>

Reads the variable composites, with their coverage and variation store resolved.

Returns None if the font has no VARC table.

Trait Implementations§

Source§

impl<'a> Clone for Outlines<'a>

Source§

fn clone(&self) -> Outlines<'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
Source§

impl<'yoke> Yokeable<'yoke> for Outlines<'static>

Source§

type Output = Outlines<'yoke>

This type MUST be Self with the 'static replaced with 'a, i.e. Self<'a>
Source§

fn transform(&'yoke self) -> &'yoke Self::Output

This method must cast self between &'a Self<'static> and &'a Self<'a>. Read more
Source§

fn transform_owned(self) -> Self::Output

This method must cast self between Self<'static> and Self<'a>. Read more
Source§

unsafe fn make(from: Self::Output) -> Self

This method can be used to cast away Self<'a>’s lifetime. Read more
Source§

fn transform_mut<F>(&'yoke mut self, f: F)
where F: 'static + for<'_yoke> FnOnce(&'_yoke mut Self::Output),

This method must cast self between &'a mut Self<'static> and &'a mut Self<'a>, and pass it to f. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Outlines<'a>

§

impl<'a> RefUnwindSafe for Outlines<'a>

§

impl<'a> Send for Outlines<'a>

§

impl<'a> Sync for Outlines<'a>

§

impl<'a> Unpin for Outlines<'a>

§

impl<'a> UnsafeUnpin for Outlines<'a>

§

impl<'a> UnwindSafe for Outlines<'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.