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
impl CidCmap
Sourcepub fn identity(vertical: bool) -> CidCmap
pub fn identity(vertical: bool) -> CidCmap
The Identity mapping (ISO 32000-1 Table 118, Identity-H/-V):
2-byte codes, CID == code.
Sourcepub fn parse(data: &[u8]) -> CidCmap
pub fn parse(data: &[u8]) -> CidCmap
Parses a decoded CMap with no way to resolve usecmap names.
Sourcepub fn parse_with(
data: &[u8],
parent: Option<Arc<CidCmap>>,
resolve: &mut dyn FnMut(&str) -> Option<Arc<CidCmap>>,
) -> CidCmap
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).
Sourcepub fn is_empty(&self) -> bool
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”.
Sourcepub fn parent(&self) -> Option<&Arc<CidCmap>>
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.
Sourcepub fn single_byte(&self, b: u8) -> bool
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.
Sourcepub fn code_at(&self, bytes: &[u8], pos: usize) -> (u32, u8)
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.