pub struct CMap {
pub name: Option<String>,
pub cmap_type: CMapType,
pub wmode: u8,
pub codespace_ranges: Vec<CodeRange>,
pub mappings: Vec<CMapEntry>,
pub inherited_predefined: Option<String>,
/* private fields */
}Expand description
CMap structure for character code mappings
Fields§
§name: Option<String>CMap name
cmap_type: CMapTypeCMap type
wmode: u8Writing mode (0 = horizontal, 1 = vertical)
codespace_ranges: Vec<CodeRange>Code space ranges
mappings: Vec<CMapEntry>Character mappings
inherited_predefined: Option<String>Predefined parent CMap inherited via usecmap. When set to
"Identity-H" or "Identity-V", map() falls back to
returning the input code as-is for any code the child CMap
did not map explicitly, and is_valid_code() accepts the full
2-byte (Identity-H) or 1-byte (Identity-V) space. External
CMap chaining (non-predefined parents) is recorded for
observability but does not enable any fallback.
Implementations§
Source§impl CMap
impl CMap
Sourcepub fn identity_h() -> Self
pub fn identity_h() -> Self
Create a predefined Identity CMap
Sourcepub fn identity_v() -> Self
pub fn identity_v() -> Self
Create a predefined Identity-V CMap
Sourcepub fn parse(data: &[u8]) -> ParseResult<Self>
pub fn parse(data: &[u8]) -> ParseResult<Self>
Parse a CMap from data.
Adobe CMaps are PostScript, not line-oriented. Same-line forms
like 1 begincodespacerange <0000><00D1> endcodespacerange are
legal (and shipped by BOE / various other producers — see issue
#272). The previous line-based scanner could get stuck in a state
flag because endcodespacerange never appeared as its own line.
This implementation tokenises the input first and then consumes
tokens with a state machine that is whitespace-agnostic.
Sourcepub fn is_valid_code(&self, code: &[u8]) -> bool
pub fn is_valid_code(&self, code: &[u8]) -> bool
Check if a code is in valid codespace
Sourcepub fn to_unicode(&self, mapped: &[u8]) -> Option<String>
pub fn to_unicode(&self, mapped: &[u8]) -> Option<String>
Convert mapped value to Unicode string