pub struct FontMetrics { /* private fields */ }Expand description
TextMeasure implementation backed by fontdue (UI + bundled mono).
Construction probes a small list of common Linux sans-serif paths. The
monospace slot first uses the bundled font. If a requested face is absent,
measurement falls back to ApproxTextMeasure, so construction and
measurement are infallible and portable.
§Examples
use ailloli_ui_core::FontId;
use ailloli_ui_text::{FontMetrics, TextMeasure};
let metrics = FontMetrics::new();
assert_eq!(metrics.measure("", FontId::Ui, 16), 0.0);Implementations§
Source§impl FontMetrics
impl FontMetrics
Sourcepub fn new() -> Self
pub fn new() -> Self
Loads the bundled monospace face and probes common Linux UI-font paths.
Missing or invalid system files are silently skipped. This function does filesystem I/O but never returns an error; unavailable faces use the approximate fallback during measurement.
§Examples
use ailloli_ui_core::FontId;
use ailloli_ui_text::{FontMetrics, TextMeasure};
let metrics = FontMetrics::new();
assert!(metrics.advance('x', FontId::Mono, 14) >= 0.0);Trait Implementations§
Source§impl Default for FontMetrics
impl Default for FontMetrics
Source§impl TextMeasure for FontMetrics
impl TextMeasure for FontMetrics
Auto Trait Implementations§
impl Freeze for FontMetrics
impl RefUnwindSafe for FontMetrics
impl Send for FontMetrics
impl Sync for FontMetrics
impl Unpin for FontMetrics
impl UnwindSafe for FontMetrics
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