Skip to main content

PdfFont

Struct PdfFont 

Source
pub struct PdfFont {
    pub font_type: FontType,
    pub base_font: String,
    pub encoding: Encoding,
    pub to_unicode: Option<ToUnicodeCMap>,
    pub widths: HashMap<u32, f64>,
    pub default_width: f64,
    pub first_char: u32,
    pub is_cid: bool,
}
Expand description

A loaded PDF font with encoding and metrics.

Fields§

§font_type: FontType

Font type.

§base_font: String

Base font name (e.g., “Helvetica”, “ABCDEF+ArialMT”).

§encoding: Encoding

Text encoding for simple fonts.

§to_unicode: Option<ToUnicodeCMap>

ToUnicode CMap (if present).

§widths: HashMap<u32, f64>

Character widths: code -> width in 1/1000 units.

§default_width: f64

Default width for missing characters.

§first_char: u32

First character code in the Widths array.

§is_cid: bool

Whether this is a CID (multi-byte) font.

Implementations§

Source§

impl PdfFont

Source

pub fn from_dict(dict: &PdfObject, doc: &mut CosDoc) -> Result<Self>

Load a font from a PDF font dictionary.

Source

pub fn char_width(&self, code: u32) -> f64

Get the width of a character code in 1/1000 units.

Source

pub fn decode_text(&self, data: &[u8]) -> String

Decode a byte string to Unicode using this font’s encoding.

Trait Implementations§

Source§

impl Debug for PdfFont

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.