Skip to main content

CidCmap

Struct CidCmap 

Source
pub struct CidCmap { /* private fields */ }
Expand description

A parsed CID CMap. Parsing is lenient: unrecognized tokens are skipped and malformed sections contribute what they parsed so far, so CidCmap::parse never fails.

Implementations§

Source§

impl CidCmap

Source

pub fn identity(vertical: bool) -> CidCmap

The Identity mapping (ISO 32000-1 Table 118, Identity-H/-V): 2-byte codes, CID == code.

Source

pub fn parse(data: &[u8]) -> CidCmap

Parses a decoded CMap with no way to resolve usecmap names.

Source

pub fn parse_with( data: &[u8], parent: Option<Arc<CidCmap>>, resolve: &mut dyn FnMut(&str) -> Option<Arc<CidCmap>>, ) -> CidCmap

Parses a decoded CMap. parent is the layer named by the stream dictionary’s /UseCMap, if any; an in-content usecmap operator resolves through resolve and fills the parent slot only when it is still empty (a CMap has one parent).

Source

pub fn is_empty(&self) -> bool

True when nothing at all was mapped — the caller’s cue to treat an embedded CMap stream as unreadable rather than as “maps everything to CID 0”.

Source

pub fn vertical(&self) -> bool

Writing mode: true for vertical (/WMode 1).

Source

pub fn parent(&self) -> Option<&Arc<CidCmap>>

The usecmap layer underneath, if any. A vertical CMap’s parent is its horizontal base, whose CIDs name the unrotated glyphs — the ones a CID-to-Unicode inversion actually knows.

Source

pub fn single_byte(&self, b: u8) -> bool

True when the codespaces read single byte b as a complete code — the ISO 32000-1 §9.3.3 condition for word spacing to apply to a composite font’s code 32.

Source

pub fn code_at(&self, bytes: &[u8], pos: usize) -> (u32, u8)

Splits the next code from bytes at pos (which must be in bounds), returning (value, length). The shortest codespace range that matches byte-wise wins; when none matches fully, the shortest range whose first byte fits still decides the length (the code maps to nothing and will read as notdef); when even that fails, one raw byte is consumed. Always consumes at least one byte. With no codespaces at all, codes are two bytes — the Type0 default this module’s callers otherwise assume.

Source

pub fn cid(&self, code: u32, len: u8) -> Option<u32>

The CID for a code of len bytes: this layer’s cidchar singletons, then its cidranges, then the parent chain, and only after every real mapping missed, the notdef entries. None reads as CID 0.

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.