Skip to main content

Cmap

Struct Cmap 

Source
pub struct Cmap {
    pub table_version: u16,
    pub tables: Vec<CmapSubtable>,
}
Expand description

Character to Glyph Index Mapping table (table__c_m_a_p).

See https://learn.microsoft.com/en-us/typography/opentype/spec/cmap.

Fields§

§table_version: u16

The table version (tableVersion), 0.

§tables: Vec<CmapSubtable>

The subtables (tables).

Implementations§

Source§

impl Cmap

Source

pub fn parse(data: &[u8]) -> Result<Self>

Parses a cmap (or DMAP) table; this needs no font, since glyphs are stored by ID.

Source

pub fn getcmap( &self, platform_id: u16, plat_enc_id: u16, ) -> Option<&CmapSubtable>

The first subtable with the given platform and encoding IDs (getcmap).

Source

pub fn get_best_cmap(&self, preferences: &[(u16, u16)]) -> Option<&CharMap>

The mapping of the first subtable found in order of preference (getBestCmap); DEFAULT_CMAP_PREFERENCES is the default order.

Source

pub fn build_reversed(&self) -> BTreeMap<u32, BTreeSet<u32>>

Glyph ID to the code points mapped to it in the Unicode subtables (buildReversed).

Source

pub fn build_reversed_min(&self) -> BTreeMap<u32, u32>

Glyph ID to the lowest code point mapped to it in the Unicode subtables (buildReversedMin).

Source

pub fn sort_tables(&mut self) -> Result<()>

Sorts the subtables by (platform ID, encoding ID, language), as the specification requires (tables.sort()).

Trait Implementations§

Source§

impl Clone for Cmap

Source§

fn clone(&self) -> Self

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

Source§

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

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

impl Default for Cmap

Source§

fn default() -> Self

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

impl PartialEq for Cmap

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Cmap

Source§

impl Table for Cmap

Source§

fn remap_glyphs(&mut self, f: &mut dyn FnMut(u32) -> Result<u32>) -> Result<()>

Maps every glyph ID in the table with f, as when the glyph order changes (fontTools refers to glyphs by name, so this happens implicitly there). f fails for glyphs that no longer exist.
Source§

fn tag(&self) -> Tag

The table tag (tableTag).
Source§

fn compile(&mut self, font: &mut Font) -> Result<Vec<u8>>

Compiles the table to binary (compile).
Source§

fn clone_table(&self) -> Box<dyn Table>

A deep copy.
Source§

fn ensure_decompiled(&mut self)

Expands whatever was left compact when reading (ensureDecompiled).
Source§

fn is_raw(&self) -> bool

Whether this is a plain DefaultTable, which TTX marks as raw.
Source§

fn decompile_error(&self) -> Option<&str>

The error message, if decompilation failed and the table was kept as raw data (ERROR).
Source§

impl TableType for Cmap

Source§

const TAG: Tag

The tag of this table type.
Source§

fn decompile(data: &[u8], _font: &mut Font) -> Result<Self>

Parses the table (decompile).
Source§

const COMPANION: Option<Tag> = None

The tag of the beyond-64k companion that this type also implements, as GLYF for glyf. Font::get prefers it, as fontTools does with its "GLYF" if "GLYF" in font else "glyf".
Source§

fn decompile_as(tag: Tag, data: &[u8], font: &mut Font) -> Result<Self>

Parses the table under one of its tags.
Source§

fn new_as(tag: Tag) -> Self
where Self: Default,

An empty table with one of its tags (newTable).
Source§

impl TableXml for Cmap

Source§

fn to_xml(&self, writer: &mut XmlWriter, font: &mut Font) -> Result<()>

Writes the table’s TTX content, without the enclosing table element (toXML).
Source§

fn from_xml(&mut self, element: &Element, font: &mut Font) -> Result<()>

Reads one child element of the table’s TTX element (fromXML).

Auto Trait Implementations§

§

impl Forget for Cmap

§

impl Freeze for Cmap

§

impl Move for Cmap

§

impl RefUnwindSafe for Cmap

§

impl Send for Cmap
where RawVecInner: Send, Arc<BTreeMap<u32, u32>>: Send, NodeRef<Owned, u32, Vec<(u32, Option<u32>)>, LeafOrInternal>: Send, BoxRaw<(u32, Vec<(u32, Option<u32>)>)>: Send,

§

impl Sync for Cmap
where RawVecInner: Sync, Arc<BTreeMap<u32, u32>>: Sync, NodeRef<Owned, u32, Vec<(u32, Option<u32>)>, LeafOrInternal>: Sync, BoxRaw<(u32, Vec<(u32, Option<u32>)>)>: Sync,

§

impl Unpin for Cmap
where *const u8 is !null: Unpin, Arc<BTreeMap<u32, u32>>: Unpin, *const LeafNode<u32, Vec<(u32, Option<u32>)>> is !null: Unpin, Box<(u32, Vec<(u32, Option<u32>)>)>: Unpin,

§

impl UnsafeUnpin for Cmap

§

impl UnwindSafe for Cmap

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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

self as &dyn Any.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

self as &mut dyn Any.
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<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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.