pub struct PdfFont {Show 15 fields
pub name: String,
pub base_font: String,
pub subtype: String,
pub widths: HashMap<u32, f64>,
pub default_width: f64,
pub to_unicode: HashMap<u32, String>,
pub encoding: String,
pub is_standard: bool,
pub flags: u32,
pub italic_angle: f64,
pub weight: f64,
pub bytes_per_code: u8,
pub ascent: f64,
pub descent: f64,
pub font_bbox: [f64; 4],
}Expand description
Represents a resolved PDF font with metrics and encoding info.
§Invariants
widths, default_width, ascent, descent, and font_bbox are always
stored in per-mille text-space units (1000 = 1 em). Callers convert to
user space with value / 1000.0 * font_size. Type 3 fonts, whose native
/Widths live in glyph space scaled by /FontMatrix, are normalized at
resolve time by crate::pdf::font_type3 so this invariant holds for every
subtype.
Fields§
§name: StringResource name (e.g., “F1”)
base_font: StringBase font name (e.g., “Helvetica”, “ArialMT”)
subtype: StringFont subtype (Type1, TrueType, Type0, Type3)
widths: HashMap<u32, f64>Glyph widths indexed by character code (per-mille text space)
default_width: f64Default width for missing glyphs (per-mille text space)
to_unicode: HashMap<u32, String>ToUnicode mapping: character code → Unicode string
encoding: StringEncoding name
is_standard: boolWhether this is a standard 14 font
flags: u32Font descriptor flags
italic_angle: f64Italic angle
weight: f64Font weight (estimated)
bytes_per_code: u8Bytes per character code (1 for Type1/TrueType, 2 for Type0/CID)
ascent: f64Font ascent in per-mille text-space units (1000 = 1 em)
descent: f64Font descent in per-mille text-space units (negative)
font_bbox: [f64; 4]Font bounding box [llx, lly, urx, ury] in per-mille text-space units
Implementations§
Source§impl PdfFont
impl PdfFont
Sourcepub fn default_font(name: &str) -> Self
pub fn default_font(name: &str) -> Self
Create a default font with standard metrics.
Sourcepub fn glyph_width(&self, char_code: u32) -> f64
pub fn glyph_width(&self, char_code: u32) -> f64
Get glyph width for a character code (in glyph space, typically 1/1000 of text space).
Sourcepub fn decode_char(&self, char_code: u32) -> String
pub fn decode_char(&self, char_code: u32) -> String
Get Unicode string for a character code.
Fallback order (ISO 32000 text extraction practice):
/ToUnicodeCMap (and Differences / embedded cmap filled at resolve time)- Declared single-byte encoding (WinAnsi / MacRoman)
- For Type0 / Identity-H: ASCII-range CID → Latin-1; else replacement
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PdfFont
impl RefUnwindSafe for PdfFont
impl Send for PdfFont
impl Sync for PdfFont
impl Unpin for PdfFont
impl UnsafeUnpin for PdfFont
impl UnwindSafe for PdfFont
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 more