Struct Charmap
pub struct Charmap<'a> { /* private fields */ }Expand description
Mapping of characters to nominal glyph identifiers.
The mappings are derived from the cmap
table. Depending on the font, the returned mapping may have entries that point to virtual/phantom glyph
ids beyond the num_glyphs entry of the maxp table, which are only used during the shaping process,
for example.
§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§
§impl<'a> Charmap<'a>
impl<'a> Charmap<'a>
pub fn has_variant_map(&self) -> bool
pub fn has_variant_map(&self) -> bool
Returns true if a Unicode variation sequence mapping is available.
pub 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.
pub 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.
pub 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.
pub 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> UnsafeUnpin 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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more