pub struct FontFace { /* private fields */ }Expand description
One owned TTF/OpenType outline face (collection index zero).
Source bytes are retained once inside ab_glyph; rustybuzz borrows those bytes while shaping. The source Vec capacity is checked before parsing. Font discovery, fallback selection, variable-font axes, color/bitmap glyphs, wrapping and bidi paragraph layout are outside this API. Cloning shares the original bytes and parsed font without copying them.
Implementations§
Source§impl FontFace
impl FontFace
Sourcepub fn from_bytes(bytes: Vec<u8>, budget: FontBudget) -> Result<Self, FontError>
pub fn from_bytes(bytes: Vec<u8>, budget: FontBudget) -> Result<Self, FontError>
Loads already-read TTF/OTF bytes without duplicating their backing storage. The caller owns filesystem/network I/O and font licensing.
Sourcepub fn font_data(&self) -> &[u8] ⓘ
pub fn font_data(&self) -> &[u8] ⓘ
Original font bytes, borrowed without an additional owned copy.
Sourcepub const fn allocation_bytes(&self) -> usize
pub const fn allocation_bytes(&self) -> usize
Source Vec capacity referenced by this handle; clones share it. Dependency-parsed metadata is excluded.
Sourcepub const fn glyph_count(&self) -> usize
pub const fn glyph_count(&self) -> usize
Number of font-local glyph identifiers, including the missing-glyph entry.
Sourcepub fn shape_line(
&self,
text: &str,
style: &TextStyle,
budget: &TextLayoutBudget,
) -> Result<ShapedLine, FontError>
pub fn shape_line( &self, text: &str, style: &TextStyle, budget: &TextLayoutBudget, ) -> Result<ShapedLine, FontError>
Shapes a horizontal single-script directional run at baseline (0, 0).
Positions/advances use logical pixels, with positive y downward. Kerning, ligatures and combining-mark offsets come from rustybuzz/OpenType tables. Auto infers one direction/script, not a mixed-direction bidi paragraph. Newlines, controls and missing glyphs return errors; spaces retain advance. DPI changes raster resolution, not logical layout or kerning decisions.
Sourcepub fn rasterize_glyph(
&self,
glyph_id: u16,
style: &TextStyle,
budget: &TextLayoutBudget,
) -> Result<RasterizedGlyph, FontError>
pub fn rasterize_glyph( &self, glyph_id: u16, style: &TextStyle, budget: &TextLayoutBudget, ) -> Result<RasterizedGlyph, FontError>
Rasterizes one glyph at physical em size and baseline (0, 0).
Outlines are preflighted without allocating curves; pixel bounds and
command counts are checked before bounded curve and coverage allocations.
No hinting or subpixel-position variants are applied. Empty outlines
(for example spaces) return an empty bitmap, not a missing-glyph error.