CmapSubtable

Enum CmapSubtable 

Source
pub enum CmapSubtable<'a> {
    Format0 {
        language: u16,
        glyph_id_array: ReadArray<'a, U8>,
    },
    Format2 {
        language: u16,
        sub_header_keys: ReadArray<'a, U16Be>,
        sub_headers: ReadArray<'a, SubHeader>,
        sub_headers_scope: ReadScope<'a>,
    },
    Format4(CmapSubtableFormat4<'a>),
    Format6 {
        language: u16,
        first_code: u16,
        glyph_id_array: ReadArray<'a, U16Be>,
    },
    Format10 {
        language: u32,
        start_char_code: u32,
        glyph_id_array: ReadArray<'a, U16Be>,
    },
    Format12 {
        language: u32,
        groups: ReadArray<'a, SequentialMapGroup>,
    },
}

Variants§

§

Format0

Fields

§language: u16
§glyph_id_array: ReadArray<'a, U8>
§

Format2

Fields

§language: u16
§sub_header_keys: ReadArray<'a, U16Be>
§sub_headers: ReadArray<'a, SubHeader>
§sub_headers_scope: ReadScope<'a>
§

Format4(CmapSubtableFormat4<'a>)

§

Format6

Fields

§language: u16
§first_code: u16
§glyph_id_array: ReadArray<'a, U16Be>
§

Format10

Fields

§language: u32
§start_char_code: u32
§glyph_id_array: ReadArray<'a, U16Be>
§

Format12

Fields

§language: u32

Implementations§

Source§

impl<'a> CmapSubtable<'a>

Source

pub fn map_glyph(&self, ch: u32) -> Result<Option<u16>, ParseError>

Source

pub fn to_owned(&self) -> Option<OwnedCmapSubtable>

Returns an owned::CmapSubtable. Will only return None if self is CmapSubtable::Format2 as support for converting from this format is not yet implemented.

Source

pub fn mappings(&self) -> Result<HashMap<u16, u32>, ParseError>

Extract all the mappings from the sub-table.

The returned HashMap maps glyph indexes to char codes. If more than one char code maps to the same glyph, the HashMap will contain the first mapping encountered. Also note that the char code is not necessarily Unicode. It depends on the encoding of the cmap sub-table.

This method primarily exists to support GlyphNames.

Source

pub fn mappings_fn( &self, callback: impl FnMut(u32, u16), ) -> Result<(), ParseError>

Extract all the mappings from the sub-table.

Trait Implementations§

Source§

impl<'b> ReadBinary for CmapSubtable<'b>

Source§

type HostType<'a> = CmapSubtable<'a>

Source§

fn read<'a>(ctxt: &mut ReadCtxt<'a>) -> Result<Self::HostType<'a>, ParseError>

Source§

impl<'a> WriteBinary<&CmapSubtable<'a>> for CmapSubtable<'a>

Source§

type Output = ()

The type of the value returned by write.
Source§

fn write<C: WriteContext>( ctxt: &mut C, table: &CmapSubtable<'a>, ) -> Result<(), WriteError>

Write the binary representation of Self to ctxt.

Auto Trait Implementations§

§

impl<'a> Freeze for CmapSubtable<'a>

§

impl<'a> RefUnwindSafe for CmapSubtable<'a>

§

impl<'a> Send for CmapSubtable<'a>

§

impl<'a> Sync for CmapSubtable<'a>

§

impl<'a> Unpin for CmapSubtable<'a>

§

impl<'a> UnwindSafe for CmapSubtable<'a>

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> 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ReadBinaryDep for T
where T: ReadBinary,

Source§

type Args<'a> = ()

Source§

type HostType<'a> = <T as ReadBinary>::HostType<'a>

Source§

fn read_dep<'a>( ctxt: &mut ReadCtxt<'a>, _: <T as ReadBinaryDep>::Args<'_>, ) -> Result<<T as ReadBinaryDep>::HostType<'a>, ParseError>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T, HostType> WriteBinaryDep<HostType> for T
where T: WriteBinary<HostType>,

Source§

type Args = ()

The type of the arguments supplied to write_dep.
Source§

type Output = <T as WriteBinary<HostType>>::Output

The type of the value returned by write_dep.
Source§

fn write_dep<C>( ctxt: &mut C, val: HostType, _: <T as WriteBinaryDep<HostType>>::Args, ) -> Result<<T as WriteBinaryDep<HostType>>::Output, WriteError>
where C: WriteContext,

Write the binary representation of Self to ctxt.