pub struct PdfFont {Show 14 fields
pub font_name: String,
pub font_data: Vec<u8>,
pub flags: u32,
pub bbox: [i16; 4],
pub italic_angle: i16,
pub ascent: i16,
pub descent: i16,
pub cap_height: i16,
pub stem_v: i16,
pub widths: Vec<u16>,
pub first_char: u32,
pub last_char: u32,
pub units_per_em: u16,
pub char_to_glyph: HashMap<char, u16>,
}Expand description
Embedded TrueType font information
Fields§
§font_name: StringFont name (extracted from the TTF)
font_data: Vec<u8>Font data (complete TTF/OTF file)
flags: u32Font flags for the descriptor
bbox: [i16; 4]Font bounding box [llx lly urx ury]
italic_angle: i16Italic angle (0 for upright fonts)
ascent: i16Ascent (height above baseline)
descent: i16Descent (depth below baseline, typically negative)
cap_height: i16Cap height (height of capital letters)
stem_v: i16Stem vertical width
widths: Vec<u16>Character widths for all used characters
first_char: u32First character code in widths array
last_char: u32Last character code in widths array
units_per_em: u16Units per em (font scaling factor, typically 1000 or 2048)
char_to_glyph: HashMap<char, u16>Character to glyph ID mapping for Unicode support
Implementations§
Source§impl PdfFont
impl PdfFont
Sourcepub fn from_ttf_data(font_data: Vec<u8>) -> Result<Self>
pub fn from_ttf_data(font_data: Vec<u8>) -> Result<Self>
Parse a TrueType font from raw bytes
Extracts font metrics and prepares the font for embedding in PDF. Supports basic Latin character set (ASCII 32-126).
Sourcepub fn char_width(&self, c: char) -> u16
pub fn char_width(&self, c: char) -> u16
Get the width of a character in font units
Sourcepub fn measure_text(&self, text: &str, font_size_pt: f64) -> f64
pub fn measure_text(&self, text: &str, font_size_pt: f64) -> f64
Measure text width at a given font size
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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