Skip to main content

FontFace

Struct FontFace 

Source
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

Source

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.

Source

pub fn font_data(&self) -> &[u8] ⓘ

Original font bytes, borrowed without an additional owned copy.

Source

pub const fn allocation_bytes(&self) -> usize

Source Vec capacity referenced by this handle; clones share it. Dependency-parsed metadata is excluded.

Source

pub const fn glyph_count(&self) -> usize

Number of font-local glyph identifiers, including the missing-glyph entry.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for FontFace

Source§

fn clone(&self) -> FontFace

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FontFace

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,