pub struct Charmap<'a> { /* private fields */ }
Expand description
Mapping of characters to nominal glyph identifiers.
The mappings are derived from the cmap table.
§Obtaining a Charmap
Typically a Charmap is acquired by calling charmap on a FontRef.
§Selection strategy
Fonts may contain multiple subtables in various formats supporting different encodings. The selection strategy implemented here is designed to choose mappings that capture the broadest available Unicode coverage:
-
Unicode characters: a symbol mapping subtable is selected if available. Otherwise, subtables supporting the Unicode full repertoire or Basic Multilingual Plane (BMP) are preferred, in that order. Formats 4 and 12 are supported.
-
Unicode variation sequences: these are provided by a format 14 subtable.
Implementations§
Source§impl<'a> Charmap<'a>
impl<'a> Charmap<'a>
Sourcepub fn new(font: &impl TableProvider<'a>) -> Self
pub fn new(font: &impl TableProvider<'a>) -> Self
Creates a new character map from the given font.
Sourcepub fn has_map(&self) -> bool
pub fn has_map(&self) -> bool
Returns true if a suitable Unicode character mapping is available.
Sourcepub fn has_variant_map(&self) -> bool
pub fn has_variant_map(&self) -> bool
Returns true if a Unicode variation sequence mapping is available.
Sourcepub fn map(&self, ch: impl Into<u32>) -> Option<GlyphId>
pub fn map(&self, ch: impl Into<u32>) -> Option<GlyphId>
Maps a character to a nominal glyph identifier.
Returns None
if a mapping does not exist.
Sourcepub fn mappings(&self) -> Mappings<'a> ⓘ
pub fn mappings(&self) -> Mappings<'a> ⓘ
Returns an iterator over all mappings of codepoint to nominal glyph identifiers in the character map.
Sourcepub fn map_variant(
&self,
ch: impl Into<u32>,
selector: impl Into<u32>,
) -> Option<MapVariant>
pub fn map_variant( &self, ch: impl Into<u32>, selector: impl Into<u32>, ) -> Option<MapVariant>
Maps a character and variation selector to a nominal glyph identifier.
Returns None
if a mapping does not exist.
Sourcepub fn variant_mappings(&self) -> VariantMappings<'a> ⓘ
pub fn variant_mappings(&self) -> VariantMappings<'a> ⓘ
Returns an iterator over all mappings of character and variation selector to nominal glyph identifier in the character map.