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: u16The table version (tableVersion), 0.
tables: Vec<CmapSubtable>The subtables (tables).
Implementations§
Source§impl Cmap
impl Cmap
Sourcepub fn parse(data: &[u8]) -> Result<Self>
pub fn parse(data: &[u8]) -> Result<Self>
Parses a cmap (or DMAP) table; this needs no font, since glyphs are
stored by ID.
Sourcepub fn getcmap(
&self,
platform_id: u16,
plat_enc_id: u16,
) -> Option<&CmapSubtable>
pub fn getcmap( &self, platform_id: u16, plat_enc_id: u16, ) -> Option<&CmapSubtable>
The first subtable with the given platform and encoding IDs (getcmap).
Sourcepub fn get_best_cmap(&self, preferences: &[(u16, u16)]) -> Option<&CharMap>
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.
Sourcepub fn build_reversed(&self) -> BTreeMap<u32, BTreeSet<u32>>
pub fn build_reversed(&self) -> BTreeMap<u32, BTreeSet<u32>>
Glyph ID to the code points mapped to it in the Unicode subtables
(buildReversed).
Sourcepub fn build_reversed_min(&self) -> BTreeMap<u32, u32>
pub fn build_reversed_min(&self) -> BTreeMap<u32, u32>
Glyph ID to the lowest code point mapped to it in the Unicode subtables
(buildReversedMin).
Sourcepub fn sort_tables(&mut self) -> Result<()>
pub fn sort_tables(&mut self) -> Result<()>
Sorts the subtables by (platform ID, encoding ID, language), as the
specification requires (tables.sort()).
Trait Implementations§
impl StructuralPartialEq for Cmap
Source§impl Table for Cmap
impl Table for Cmap
Source§fn remap_glyphs(&mut self, f: &mut dyn FnMut(u32) -> Result<u32>) -> Result<()>
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 compile(&mut self, font: &mut Font) -> Result<Vec<u8>>
fn compile(&mut self, font: &mut Font) -> Result<Vec<u8>>
Compiles the table to binary (
compile).Source§fn clone_table(&self) -> Box<dyn Table>
fn clone_table(&self) -> Box<dyn Table>
A deep copy.
Source§fn ensure_decompiled(&mut self)
fn ensure_decompiled(&mut self)
Expands whatever was left compact when reading (
ensureDecompiled).Source§fn is_raw(&self) -> bool
fn is_raw(&self) -> bool
Whether this is a plain
DefaultTable, which TTX marks as raw.Source§fn decompile_error(&self) -> Option<&str>
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
impl TableType for Cmap
Source§const COMPANION: Option<Tag> = None
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".Auto Trait Implementations§
impl Forget for Cmap
impl Freeze for Cmap
impl Move for Cmap
impl RefUnwindSafe for Cmap
impl Send for Cmap
impl Sync for Cmap
impl Unpin for Cmap
impl UnsafeUnpin for Cmap
impl UnwindSafe for Cmapwhere
RawVecInner: UnwindSafe,
Arc<BTreeMap<u32, u32>>: UnwindSafe,
BTreeMap<u32, Vec<(u32, Option<u32>)>>: UnwindSafe,
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
Mutably borrows from an owned value. Read more