pub enum PdfFont {
Type1(Type1PdfFont),
TrueType(TrueTypePdfFont),
Cff(CffPdfFont),
CidTrueType(CidTrueTypePdfFont),
CidCff(CidCffPdfFont),
Type3(Type3PdfFont),
}Expand description
Resolved PDF font, ready for glyph rendering.
Variants§
Type1(Type1PdfFont)
TrueType(TrueTypePdfFont)
Cff(CffPdfFont)
CidTrueType(CidTrueTypePdfFont)
Type 0 composite font (CIDFontType2 with TrueType outlines)
CidCff(CidCffPdfFont)
Type 0 composite font (CIDFontType0 with CFF outlines)
Type3(Type3PdfFont)
Type 3 font: glyphs defined as content streams.
Implementations§
Source§impl PdfFont
impl PdfFont
Sourcepub fn glyph_path(&self, char_code: u8) -> Option<PsPath>
pub fn glyph_path(&self, char_code: u8) -> Option<PsPath>
Get glyph outline path for a character code (single-byte fonts). Returns None for Type 3 fonts (they use content streams, not outlines).
Sourcepub fn glyph_path_cid(&self, cid: u16) -> Option<PsPath>
pub fn glyph_path_cid(&self, cid: u16) -> Option<PsPath>
Get glyph outline path for a CID (2-byte composite fonts).
Sourcepub fn glyph_path_unicode(&self, unicode: u16) -> Option<PsPath>
pub fn glyph_path_unicode(&self, unicode: u16) -> Option<PsPath>
Get glyph path for a Unicode code point, bypassing CID machinery. Used for malformed PDFs that mix WinAnsi literal strings in CID fonts.
Sourcepub fn glyph_width_unicode(&self, unicode: u16) -> f64
pub fn glyph_width_unicode(&self, unicode: u16) -> f64
Get width for a Unicode code point from hmtx, bypassing CID widths.
Sourcepub fn glyph_width(&self, char_code: u8) -> f64
pub fn glyph_width(&self, char_code: u8) -> f64
Get width for a character code (in text space units, already ÷1000).
Sourcepub fn glyph_width_cid(&self, cid: u16) -> f64
pub fn glyph_width_cid(&self, cid: u16) -> f64
Get width for a CID (2-byte composite fonts).
Sourcepub fn font_matrix(&self) -> Matrix
pub fn font_matrix(&self) -> Matrix
Font matrix (glyph space → text space).
Returns identity for CidCff because the full matrix (including per-FD
composition) is applied inside glyph_path_cid().
Sourcepub fn is_composite(&self) -> bool
pub fn is_composite(&self) -> bool
Whether this is a composite (CID) font that uses multi-byte character codes.
Sourcepub fn dw2(&self) -> [f64; 2]
pub fn dw2(&self) -> [f64; 2]
Default vertical metrics [v_y, w1] for vertical writing mode. v_y = vertical origin y offset (in 1/1000 em), w1 = vertical advance.
Sourcepub fn vertical_metrics_cid(&self, cid: u16) -> [f64; 3]
pub fn vertical_metrics_cid(&self, cid: u16) -> [f64; 3]
Get per-CID vertical metrics (w1, v_x, v_y), falling back to DW2. Returns values in 1/1000 em units.
Sourcepub fn has_cid_glyph(&self, cid: u16) -> bool
pub fn has_cid_glyph(&self, cid: u16) -> bool
Whether a CID maps to a GID that exists in the font. Used to distinguish valid 2-byte CID codes from misinterpreted WinAnsi bytes in malformed PDFs that mix 1-byte literal text with CID fonts.
Sourcepub fn resolve_code_to_cid(&self, code: u32) -> u32
pub fn resolve_code_to_cid(&self, code: u32) -> u32
Map a raw character code to a CID using the encoding CMap. Returns the code unchanged if no mapping exists (identity encoding).
Sourcepub fn code_width(&self, first_byte: u8) -> usize
pub fn code_width(&self, first_byte: u8) -> usize
Get the byte width of a character code starting with the given byte. Only meaningful for composite fonts; returns 1 for simple fonts.
Sourcepub fn type3_char_proc(&self, char_code: u8) -> Option<&[u8]>
pub fn type3_char_proc(&self, char_code: u8) -> Option<&[u8]>
Get the Type 3 glyph stream data for a character code.
Sourcepub fn type3_resources(&self) -> Option<&PdfDict>
pub fn type3_resources(&self) -> Option<&PdfDict>
Get the Type 3 font resources dict.
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
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