Skip to main content

GlyphVariationData

Type Alias GlyphVariationData 

Source
pub type GlyphVariationData<'a> = TupleVariationData<'a, GlyphDelta>;
Expand description

Variation data specialized for the glyph variations table.

Aliased Type§

pub struct GlyphVariationData<'a> {
    pub(crate) axis_count: u16,
    pub(crate) shared_tuples: Option<ComputedArray<'a, Tuple<'a>>>,
    pub(crate) shared_point_numbers: Option<PackedPointNumbers<'a>>,
    pub(crate) tuple_count: TupleVariationCount,
    pub(crate) header_data: FontData<'a>,
    pub(crate) serialized_data: FontData<'a>,
    pub(crate) _marker: PhantomData<fn() -> GlyphDelta>,
}

Fields§

§axis_count: u16§shared_tuples: Option<ComputedArray<'a, Tuple<'a>>>§shared_point_numbers: Option<PackedPointNumbers<'a>>§tuple_count: TupleVariationCount§header_data: FontData<'a>§serialized_data: FontData<'a>§_marker: PhantomData<fn() -> GlyphDelta>

Implementations§

Source§

impl GlyphVariationData<'_>

Source

pub fn simple_deltas<C, D>( &self, coords: &[F2Dot14], points: &[Point<C>], flags: &mut [PointFlags], contours: &[u16], buffers: &mut DeltaBuffers<'_, D>, ) -> Result<(), ReadError>
where C: PointCoord, D: PointCoord + From<C>,

Computes the deltas for the points of a simple glyph at the given location in variation space.

Deltas for points that a sparse tuple does not reference are inferred by interpolation, so this needs the glyph’s points and contour end points in addition to the buffers it writes.

  • points and contours describe the unvaried glyph. points must include the four phantom points.
  • flags is used as scratch: the PointMarker::HAS_DELTA marker is cleared and set as tuples are processed.
  • buffers supplies the output and interpolation storage.

flags and both buffers must be at least as long as points, which is what everything here is indexed by.

The deltas are zeroed before anything else happens, so they never retain values from a previous call.

See Gvar::simple_deltas to look a glyph’s data up first.

Source

pub fn composite_deltas<D: PointCoord>( &self, coords: &[F2Dot14], deltas: &mut [Point<D>], ) -> Result<(), ReadError>

Computes the deltas for the component offsets of a composite glyph at the given location in variation space.

Interpolation is meaningless for component offsets, so this skips the expensive part of Self::simple_deltas and needs no scratch.

deltas must have one entry per component plus four for the phantom points, and is zeroed first.

See Gvar::composite_deltas to look a glyph’s data up first.

Source

fn accumulate_deltas<D: PointCoord>( &self, coords: &[F2Dot14], deltas: &mut [Point<D>], apply_sparse_tuple: impl FnMut(Fixed, TupleVariation<'_, GlyphDelta>, &mut [Point<D>]) -> Result<(), ReadError>, ) -> Result<(), ReadError>

The parts shared by simple and composite glyph processing.

Zeroes deltas, then accumulates every tuple that is active at coords. Dense tuples are handled here; sparse tuples are passed to apply_sparse_tuple, which differs between the two glyph kinds.

Source§

impl<'a> GlyphVariationData<'a>

Source

pub(crate) fn new( data: FontData<'a>, axis_count: u16, shared_tuples: SharedTuples<'a>, ) -> Result<Self, ReadError>