pub struct FontManager { /* private fields */ }Expand description
Manages font discovery, loading, shaping, and metrics.
Implementations§
Source§impl FontManager
impl FontManager
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new FontManager and load system fonts.
When the bundled-fonts feature is enabled, bundled fonts (Carlito,
Caladea, Liberation) are loaded as fallbacks.
Sourcepub fn load_additional_fonts(&mut self, font_files: &[FontFile])
pub fn load_additional_fonts(&mut self, font_files: &[FontFile])
Load additional font files (user-provided or extracted from DOCX).
These fonts are loaded AFTER system fonts, so they take the highest priority in font resolution (fontdb returns the last-loaded match).
Sourcepub fn new_with_fonts(fonts: Vec<(String, Vec<u8>)>) -> Self
pub fn new_with_fonts(fonts: Vec<(String, Vec<u8>)>) -> Self
Create a FontManager with user-provided fonts (no system font loading).
Each entry is (family_name, font_bytes). This is useful in environments
where system fonts are not available, such as WASM.
Sourcepub fn resolve_font(
&mut self,
family: Option<&str>,
bold: bool,
italic: bool,
) -> Result<FontId>
pub fn resolve_font( &mut self, family: Option<&str>, bold: bool, italic: bool, ) -> Result<FontId>
Resolve a font by family name, bold, and italic flags. Returns a FontId. Uses fallback chain if the requested font is not found.
Sourcepub fn metrics(&self, font_id: FontId, size_pt: f64) -> Result<FontMetrics>
pub fn metrics(&self, font_id: FontId, size_pt: f64) -> Result<FontMetrics>
Get font metrics at a given size in points.
Sourcepub fn shape_text(
&self,
font_id: FontId,
text: &str,
size_pt: f64,
) -> Result<ShapedText>
pub fn shape_text( &self, font_id: FontId, text: &str, size_pt: f64, ) -> Result<ShapedText>
Shape a text string using rustybuzz. Returns glyph IDs and advances.
Sourcepub fn all_font_data(&self) -> Vec<FontData>
pub fn all_font_data(&self) -> Vec<FontData>
Get all used font data.