pub struct CMap { /* private fields */ }Expand description
A parsed ToUnicode CMap that maps character codes to Unicode strings.
Character codes are typically 1 or 2 bytes from the PDF font encoding. Unicode values may be single characters or multi-character strings (e.g., ligatures like “fi” → “fi”).
Implementations§
Source§impl CMap
impl CMap
Sourcepub fn parse(data: &[u8]) -> Result<Self, BackendError>
pub fn parse(data: &[u8]) -> Result<Self, BackendError>
Parse a ToUnicode CMap from its raw byte content.
Extracts beginbfchar/endbfchar and beginbfrange/endbfrange
sections to build the character code → Unicode mapping table.
Sourcepub fn lookup(&self, code: u32) -> Option<&str>
pub fn lookup(&self, code: u32) -> Option<&str>
Look up the Unicode string for a character code.
Returns None if the code has no mapping in this CMap.
Sourcepub fn lookup_or_replacement(&self, code: u32) -> String
pub fn lookup_or_replacement(&self, code: u32) -> String
Look up the Unicode string for a character code, with fallback.
If no mapping is found, returns U+FFFD (REPLACEMENT CHARACTER).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CMap
impl RefUnwindSafe for CMap
impl Send for CMap
impl Sync for CMap
impl Unpin for CMap
impl UnsafeUnpin for CMap
impl UnwindSafe for CMap
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
Mutably borrows from an owned value. Read more