pub struct FontEncoding { /* private fields */ }Expand description
An encoding table that may be a standard encoding modified by a Differences array.
This represents the /Encoding entry in a PDF font dictionary, which can be:
- A name referring to a standard encoding (e.g., /WinAnsiEncoding)
- A dictionary with /BaseEncoding + /Differences array
Implementations§
Source§impl FontEncoding
impl FontEncoding
Sourcepub fn from_standard(encoding: StandardEncoding) -> Self
pub fn from_standard(encoding: StandardEncoding) -> Self
Create a FontEncoding from a standard encoding.
Sourcepub fn from_standard_with_differences(
encoding: StandardEncoding,
differences: &[(u8, char)],
) -> Self
pub fn from_standard_with_differences( encoding: StandardEncoding, differences: &[(u8, char)], ) -> Self
Create a FontEncoding from a standard encoding with Differences applied.
The differences slice contains pairs of (code, character) that override
the base encoding. This matches the PDF /Differences array format:
[code1 /name1 /name2 ... codeN /nameN ...] where each code starts a run
of consecutive overrides.
Sourcepub fn from_table(table: [Option<char>; 256]) -> Self
pub fn from_table(table: [Option<char>; 256]) -> Self
Create a FontEncoding from a custom table (256 entries).
Sourcepub fn apply_differences(&mut self, differences: &[(u8, char)])
pub fn apply_differences(&mut self, differences: &[(u8, char)])
Apply Differences array overrides to this encoding.
Sourcepub fn decode(&self, code: u8) -> Option<char>
pub fn decode(&self, code: u8) -> Option<char>
Decode a single byte code to a Unicode character.
Sourcepub fn decode_bytes(&self, bytes: &[u8]) -> String
pub fn decode_bytes(&self, bytes: &[u8]) -> String
Decode a byte string into a Unicode string.
Bytes with no mapping are replaced with U+FFFD (replacement character).
Trait Implementations§
Source§impl Clone for FontEncoding
impl Clone for FontEncoding
Source§fn clone(&self) -> FontEncoding
fn clone(&self) -> FontEncoding
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more