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
impl ClassDefBuilder
Sourcepub fn new_using_class_0() -> Self
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.
Sourcepub fn checked_add(&mut self, cls: IntSet<GlyphId16>) -> bool
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.
Sourcepub fn build_with_mapping(self) -> (ClassDef, HashMap<IntSet<GlyphId16>, u16>)
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.)
Trait Implementations§
Source§impl Clone for ClassDefBuilder
impl Clone for ClassDefBuilder
Source§fn clone(&self) -> ClassDefBuilder
fn clone(&self) -> ClassDefBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClassDefBuilder
impl Debug for ClassDefBuilder
Source§impl Default for ClassDefBuilder
impl Default for ClassDefBuilder
Source§fn default() -> ClassDefBuilder
fn default() -> ClassDefBuilder
Source§impl<'de> Deserialize<'de> for ClassDefBuilder
impl<'de> Deserialize<'de> for ClassDefBuilder
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ClassDefBuilder
impl PartialEq for ClassDefBuilder
Source§impl Serialize for ClassDefBuilder
impl Serialize for ClassDefBuilder
impl Eq for ClassDefBuilder
impl StructuralPartialEq for ClassDefBuilder
Auto Trait Implementations§
impl !Freeze for ClassDefBuilder
impl RefUnwindSafe for ClassDefBuilder
impl Send for ClassDefBuilder
impl Sync for ClassDefBuilder
impl Unpin for ClassDefBuilder
impl UnwindSafe for ClassDefBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.