pub struct FontContext { /* private fields */ }Expand description
Shared font context used by layout and PDF serialization. Provides text measurement with real glyph metrics.
Implementations§
Source§impl FontContext
impl FontContext
pub fn new() -> Self
Sourcepub fn sentinel_digit_count(&self) -> u32
pub fn sentinel_digit_count(&self) -> u32
Get the current sentinel digit count.
Sourcepub fn set_sentinel_digit_count(&mut self, count: u32)
pub fn set_sentinel_digit_count(&mut self, count: u32)
Set the number of digits used to measure page number sentinel width.
Sourcepub fn char_width(
&self,
ch: char,
family: &str,
weight: u32,
italic: bool,
font_size: f64,
) -> f64
pub fn char_width( &self, ch: char, family: &str, weight: u32, italic: bool, font_size: f64, ) -> f64
Get the advance width of a single character in points.
When family contains a comma (font fallback chain), resolves the
best font for this specific character before measuring.
Sourcepub fn measure_string(
&self,
text: &str,
family: &str,
weight: u32,
italic: bool,
font_size: f64,
letter_spacing: f64,
) -> f64
pub fn measure_string( &self, text: &str, family: &str, weight: u32, italic: bool, font_size: f64, letter_spacing: f64, ) -> f64
Measure the width of a string in points.
Sourcepub fn resolve(&self, family: &str, weight: u32, italic: bool) -> &FontData
pub fn resolve(&self, family: &str, weight: u32, italic: bool) -> &FontData
Resolve a font key to its font data.
Sourcepub fn registry(&self) -> &FontRegistry
pub fn registry(&self) -> &FontRegistry
Access the underlying font registry.
Sourcepub fn registry_mut(&mut self) -> &mut FontRegistry
pub fn registry_mut(&mut self) -> &mut FontRegistry
Access the underlying font registry mutably.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FontContext
impl RefUnwindSafe for FontContext
impl Send for FontContext
impl Sync for FontContext
impl Unpin for FontContext
impl UnsafeUnpin for FontContext
impl UnwindSafe for FontContext
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