ClassDefBuilder

Struct ClassDefBuilder 

Source
pub struct ClassDefBuilder { /* private fields */ }
Expand description

An opinionated builder for ClassDefs.

This ensures that class ids are assigned based on the size of the class.

If you need to know the values assigned to particular classes, call the ClassDefBuilder::build_with_mapping method, which will build the final ClassDef table, and will also return a map from the original class sets to the final assigned class id values.

If you don’t care about this, you can also construct a ClassDef from any iterator over (GlyphId16, u16) tuples, using collect:

let gid1 = GlyphId16::new(1);
let gid2 = GlyphId16::new(2);
let gid3 = GlyphId16::new(2);
let my_class: ClassDef = [(gid1, 2), (gid2, 3), (gid3, 4)].into_iter().collect();

Implementations§

Source§

impl ClassDefBuilder

Source

pub fn new() -> Self

Create a new ClassDefBuilder.

Source

pub fn new_using_class_0() -> Self

Create a new ClassDefBuilder that will assign glyphs to class 0.

In general, class 0 is a sentinel value returned when a glyph is not assigned to any other class; however in some cases (specifically in GPOS type two lookups) the ClassDef has an accompanying CoverageTable, which means that class 0 can be used, since it is known that the class is only checked if a glyph is known to have some class.

Source

pub fn checked_add(&mut self, cls: IntSet<GlyphId16>) -> bool

Check that this class can be added to this classdef, and add it if so.

returns true if the class is added, and false otherwise.

Source

pub fn build_with_mapping(self) -> (ClassDef, HashMap<IntSet<GlyphId16>, u16>)

Returns a compiled ClassDef, as well as a mapping from our glyph sets to the final class ids.

This sorts the classes, ensuring that larger classes are first.

(This is needed when subsequent structures are ordered based on the final order of class assignments.)

Source

pub fn build(self) -> ClassDef

Build a final ClassDef table.

Trait Implementations§

Source§

impl Clone for ClassDefBuilder

Source§

fn clone(&self) -> ClassDefBuilder

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 Debug for ClassDefBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClassDefBuilder

Source§

fn default() -> ClassDefBuilder

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ClassDefBuilder

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ClassDefBuilder

Source§

fn eq(&self, other: &ClassDefBuilder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ClassDefBuilder

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for ClassDefBuilder

Source§

impl StructuralPartialEq for ClassDefBuilder

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,