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.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Charmap<'a>
impl<'a> RefUnwindSafe for Charmap<'a>
impl<'a> Send for Charmap<'a>
impl<'a> Sync for Charmap<'a>
impl<'a> Unpin for Charmap<'a>
impl<'a> UnwindSafe for Charmap<'a>
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)