pub struct ResolvedFont {
pub name: String,
pub data: Vec<u8>,
pub face_index: u32,
pub units_per_em: u16,
pub ascender: i16,
pub descender: i16,
pub pdf_widths: Option<(u16, Vec<u16>)>,
pub pdf_encoding: Option<PdfSimpleEncoding>,
pub pdf_source_font: Option<PdfSourceFont>,
}Expand description
A resolved font ready for use in PDF rendering.
Fields§
§name: StringPostScript name or family name.
data: Vec<u8>Raw font data (TTF/OTF/CFF bytes).
face_index: u32Font face index within a collection (TTC/OTC).
units_per_em: u16Units per em from the font’s head table.
ascender: i16Ascender in font units.
descender: i16Descender in font units (negative).
pdf_widths: Option<(u16, Vec<u16>)>PDF /Widths array for glyph metrics: (first_char_code, widths).
pdf_encoding: Option<PdfSimpleEncoding>Optional /Encoding differences for the PDF width table.
pdf_source_font: Option<PdfSourceFont>Existing simple-font object reused to preserve the PDF’s original metrics.
Implementations§
Source§impl ResolvedFont
impl ResolvedFont
Sourcepub fn measure_string(&self, text: &str, font_size: f64) -> f64
pub fn measure_string(&self, text: &str, font_size: f64) -> f64
Measure the approximate width of a string in points at the given font size.
Sourcepub fn line_height(&self, font_size: f64) -> f64
pub fn line_height(&self, font_size: f64) -> f64
Line height in points at the given font size.
Sourcepub fn ascender_pt(&self, font_size: f64) -> f64
pub fn ascender_pt(&self, font_size: f64) -> f64
Ascender in points at the given font size.
Sourcepub fn descender_pt(&self, font_size: f64) -> f64
pub fn descender_pt(&self, font_size: f64) -> f64
Descender in points at the given font size (negative value).
Sourcepub fn pdf_glyph_widths(&self) -> (u16, Vec<u16>)
pub fn pdf_glyph_widths(&self) -> (u16, Vec<u16>)
Generate a Unicode-indexed width table from PDF /Widths.
WHY: Custom encodings via /Differences are essential for correct glyph
width mapping. Without this, widths are indexed by the wrong characters
for fonts that deviate from WinAnsi.
SPEC: PDF spec §9.6.6.1 defines /Differences as a code-to-glyph-name
override table layered on top of a base encoding.
LIMITATION: CID fonts (/Type0) use /W arrays and CMaps rather than
simple-font /Widths; that path is not handled here.
Sourcepub fn cid_font_info(&self) -> Option<CidFontInfo>
pub fn cid_font_info(&self) -> Option<CidFontInfo>
Generate CID font data for Identity-H encoding.
Returns glyph widths indexed by GID and a GID→Unicode mapping for the ToUnicode CMap.
Trait Implementations§
Source§impl Clone for ResolvedFont
impl Clone for ResolvedFont
Source§fn clone(&self) -> ResolvedFont
fn clone(&self) -> ResolvedFont
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ResolvedFont
impl RefUnwindSafe for ResolvedFont
impl Send for ResolvedFont
impl Sync for ResolvedFont
impl Unpin for ResolvedFont
impl UnsafeUnpin for ResolvedFont
impl UnwindSafe for ResolvedFont
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