Skip to main content

PdfFont

Enum PdfFont 

Source
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

Source

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).

Source

pub fn glyph_path_cid(&self, cid: u16) -> Option<PsPath>

Get glyph outline path for a CID (2-byte composite fonts).

Source

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.

Source

pub fn glyph_width_unicode(&self, unicode: u16) -> f64

Get width for a Unicode code point from hmtx, bypassing CID widths.

Source

pub fn glyph_width(&self, char_code: u8) -> f64

Get width for a character code (in text space units, already ÷1000).

Source

pub fn glyph_width_cid(&self, cid: u16) -> f64

Get width for a CID (2-byte composite fonts).

Source

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().

Source

pub fn is_composite(&self) -> bool

Whether this is a composite (CID) font that uses multi-byte character codes.

Source

pub fn wmode(&self) -> u8

Writing mode: 0 = horizontal, 1 = vertical.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn is_type3(&self) -> bool

Whether this is a Type 3 font (glyphs are content streams).

Source

pub fn type3_char_proc(&self, char_code: u8) -> Option<&[u8]>

Get the Type 3 glyph stream data for a character code.

Source

pub fn type3_resources(&self) -> Option<&PdfDict>

Get the Type 3 font resources dict.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.