pub struct FontMap { /* private fields */ }Expand description
Font encoding information extracted from a PDF document.
Maps font resource names to their ToUnicode CMap (if available), encoding type, and glyph widths.
Implementations§
Source§impl FontMap
impl FontMap
Sourcepub fn from_page(doc: &Document, page_num: u32) -> Result<Self>
pub fn from_page(doc: &Document, page_num: u32) -> Result<Self>
Build a font map from a page’s font resources in a lopdf Document.
Sourcepub fn from_xobject_stream(
doc: &Document,
stream_id: ObjectId,
page_fonts: &FontMap,
) -> Self
pub fn from_xobject_stream( doc: &Document, stream_id: ObjectId, page_fonts: &FontMap, ) -> Self
Build a FontMap from a Form XObject’s (or AP stream’s) own Resources/Font
dictionary. The XObject’s fonts take priority over page_fonts so that
character-code decoding uses the correct CMap for each stream.
Falls back to page_fonts for any name not found in the stream’s own
Resources, and uses page_fonts as-is when the stream has no Resources.
Sourcepub fn decode_string(&self, font_name: &str, bytes: &[u8]) -> String
pub fn decode_string(&self, font_name: &str, bytes: &[u8]) -> String
Decode a PDF string from a Tj/TJ operand using the font’s ToUnicode CMap.
Sourcepub fn build_reverse_map(&self, font_name: &str) -> HashMap<char, u32>
pub fn build_reverse_map(&self, font_name: &str) -> HashMap<char, u32>
Build a reverse map (Unicode char → character code) for a font.
Priority:
- ToUnicode CMap reverse map (most authoritative).
- Differences/Encoding-based reverse map (for fonts without ToUnicode but with explicit Encoding/Differences, e.g. TeX OT1 fonts). Only populated for single-byte (Builtin) fonts.
- Empty map — caller falls back to Latin-1.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FontMap
impl RefUnwindSafe for FontMap
impl Send for FontMap
impl Sync for FontMap
impl Unpin for FontMap
impl UnsafeUnpin for FontMap
impl UnwindSafe for FontMap
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
Convert this type into
T, using the provided data to resolve any offsets.