Skip to main content

ColrInstance

Struct ColrInstance 

Source
pub struct ColrInstance<'a> {
    colr: Colr<'a>,
    index_map: Option<DeltaSetIndexMap<'a>>,
    var_store: Option<ItemVariationStore<'a>>,
    coords: &'a [F2Dot14],
}
Expand description

Combination of a COLR table and a location in variation space for resolving paints.

See resolve_paint, ColorStops::resolve and resolve_clip_box.

Fields§

§colr: Colr<'a>§index_map: Option<DeltaSetIndexMap<'a>>§var_store: Option<ItemVariationStore<'a>>§coords: &'a [F2Dot14]

Implementations§

Source§

impl<'a> ColrInstance<'a>

Source

pub fn new(colr: Colr<'a>, coords: &'a [F2Dot14]) -> Self

Creates a new instance for the given COLR table and normalized variation coordinates.

Source

fn var_deltas<const N: usize>(&self, var_index_base: u32) -> [FloatItemDelta; N]

Computes a sequence of N variation deltas starting at the given var_base index.

Methods from Deref<Target = Colr<'a>>§

Source

pub fn v0_closure_palette_indices( &self, glyph_set: &IntSet<GlyphId>, palette_indices: &mut IntSet<u16>, )

Source

pub fn v1_closure( &self, glyph_set: &mut IntSet<GlyphId>, layer_indices: &mut IntSet<u32>, palette_indices: &mut IntSet<u16>, variation_indices: &mut IntSet<u32>, )

Collect the transitive closure of v1 glyphs,layer/paletted indices and variation/delta set indices for COLRv1

Source

pub fn v0_closure_glyphs( &self, glyph_set: &IntSet<GlyphId>, glyphset_colrv0: &mut IntSet<GlyphId>, )

Collect the transitive closure of V0 glyphs needed for all of the input glyphs set

Source

pub const MIN_SIZE: usize

Source

pub fn resolve_offset<O, R>(&self, offset: O) -> Result<R, ReadError>
where O: Offset, R: FontRead<'a>,

Resolve the provided offset from the start of this table.

Source

pub fn offset_data(&self) -> FontData<'a>

Return a reference to this table’s raw data.

We use this in the compile crate to resolve offsets.

Source

pub fn shape(&self) -> &Colr<'a>

👎Deprecated: just use the base type directly

Return a reference to the table’s ‘Shape’ struct.

This is a low level implementation detail, but it can be useful in some cases where you want to know things about a table’s layout, such as the byte offsets of specific fields.

Source

pub fn version(&self) -> u16

Table version number - set to 0 or 1.

Source

pub fn num_base_glyph_records(&self) -> u16

Number of BaseGlyph records; may be 0 in a version 1 table.

Source

pub fn base_glyph_records_offset(&self) -> Nullable<Offset32>

Offset to baseGlyphRecords array (may be NULL).

Source

pub fn base_glyph_records(&self) -> Option<Result<&'a [BaseGlyph], ReadError>>

Attempt to resolve base_glyph_records_offset.

Source

pub fn layer_records_offset(&self) -> Nullable<Offset32>

Offset to layerRecords array (may be NULL).

Source

pub fn layer_records(&self) -> Option<Result<&'a [Layer], ReadError>>

Attempt to resolve layer_records_offset.

Source

pub fn num_layer_records(&self) -> u16

Number of Layer records; may be 0 in a version 1 table.

Source

pub fn base_glyph_list_offset(&self) -> Option<Nullable<Offset32>>

Offset to BaseGlyphList table.

Source

pub fn base_glyph_list(&self) -> Option<Result<BaseGlyphList<'a>, ReadError>>

Attempt to resolve base_glyph_list_offset.

Source

pub fn layer_list_offset(&self) -> Option<Nullable<Offset32>>

Offset to LayerList table (may be NULL).

Source

pub fn layer_list(&self) -> Option<Result<LayerList<'a>, ReadError>>

Attempt to resolve layer_list_offset.

Source

pub fn clip_list_offset(&self) -> Option<Nullable<Offset32>>

Offset to ClipList table (may be NULL).

Source

pub fn clip_list(&self) -> Option<Result<ClipList<'a>, ReadError>>

Attempt to resolve clip_list_offset.

Source

pub fn var_index_map_offset(&self) -> Option<Nullable<Offset32>>

Offset to DeltaSetIndexMap table (may be NULL).

Source

pub fn var_index_map(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>>

Attempt to resolve var_index_map_offset.

Source

pub fn item_variation_store_offset(&self) -> Option<Nullable<Offset32>>

Offset to ItemVariationStore (may be NULL).

Source

pub fn item_variation_store( &self, ) -> Option<Result<ItemVariationStore<'a>, ReadError>>

Attempt to resolve item_variation_store_offset.

Source

pub fn version_byte_range(&self) -> Range<usize>

Source

pub fn num_base_glyph_records_byte_range(&self) -> Range<usize>

Source

pub fn base_glyph_records_offset_byte_range(&self) -> Range<usize>

Source

pub fn layer_records_offset_byte_range(&self) -> Range<usize>

Source

pub fn num_layer_records_byte_range(&self) -> Range<usize>

Source

pub fn base_glyph_list_offset_byte_range(&self) -> Range<usize>

Source

pub fn layer_list_offset_byte_range(&self) -> Range<usize>

Source

pub fn clip_list_offset_byte_range(&self) -> Range<usize>

Source

pub fn var_index_map_offset_byte_range(&self) -> Range<usize>

Source

pub fn item_variation_store_offset_byte_range(&self) -> Range<usize>

Source

pub fn v0_base_glyph( &self, glyph_id: GlyphId, ) -> Result<Option<Range<usize>>, ReadError>

Returns the COLRv0 base glyph for the given glyph identifier.

The return value is a range of layer indices that can be passed to v0_layer to retrieve the layer glyph identifiers and palette color indices.

Source

pub fn v0_layer(&self, index: usize) -> Result<(GlyphId16, u16), ReadError>

Returns the COLRv0 layer at the given index.

The layer is represented by a tuple containing the glyph identifier of the associated outline and the palette color index.

Source

pub fn v1_base_glyph( &self, glyph_id: GlyphId, ) -> Result<Option<(Paint<'a>, usize)>, ReadError>

Returns the COLRv1 base glyph for the given glyph identifier.

The second value in the tuple is a unique identifier for the paint that may be used to detect recursion in the paint graph.

Source

pub fn v1_layer(&self, index: usize) -> Result<(Paint<'a>, usize), ReadError>

Returns the COLRv1 layer at the given index.

The second value in the tuple is a unique identifier for the paint that may be used to detect recursion in the paint graph.

Source

pub fn v1_clip_box( &self, glyph_id: GlyphId, ) -> Result<Option<ClipBox<'a>>, ReadError>

Returns the COLRv1 clip box for the given glyph identifier.

Trait Implementations§

Source§

impl<'a> Clone for ColrInstance<'a>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Deref for ColrInstance<'a>

Source§

type Target = Colr<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'a> Freeze for ColrInstance<'a>

§

impl<'a> RefUnwindSafe for ColrInstance<'a>

§

impl<'a> Send for ColrInstance<'a>

§

impl<'a> Sync for ColrInstance<'a>

§

impl<'a> Unpin for ColrInstance<'a>

§

impl<'a> UnsafeUnpin for ColrInstance<'a>

§

impl<'a> UnwindSafe for ColrInstance<'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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.