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: FontTypeFont type.
base_font: StringBase font name (e.g., “Helvetica”, “ABCDEF+ArialMT”).
encoding: EncodingText 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: f64Default width for missing characters.
first_char: u32First character code in the Widths array.
is_cid: boolWhether this is a CID (multi-byte) font.
Implementations§
Source§impl PdfFont
impl PdfFont
Sourcepub fn from_dict(dict: &PdfObject, doc: &mut CosDoc) -> Result<Self>
pub fn from_dict(dict: &PdfObject, doc: &mut CosDoc) -> Result<Self>
Load a font from a PDF font dictionary.
Sourcepub fn char_width(&self, code: u32) -> f64
pub fn char_width(&self, code: u32) -> f64
Get the width of a character code in 1/1000 units.
Sourcepub fn decode_text(&self, data: &[u8]) -> String
pub fn decode_text(&self, data: &[u8]) -> String
Decode a byte string to Unicode using this font’s encoding.
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
Mutably borrows from an owned value. Read more