Skip to main content

Typesetter

Struct Typesetter 

Source
pub struct Typesetter { /* private fields */ }
Expand description

Font database, glyph cache and loaded font files. Building one scans the system fonts, so keep it for every text of a render.

Implementations§

Source§

impl Typesetter

Source

pub fn new(base_dir: impl Into<PathBuf>) -> Self

System fonts plus files given relative to base_dir (the timeline’s directory).

Source

pub fn load(&mut self, file: &Path, index: u32) -> Result<LoadedFace>

Loads a font file (once) and returns face index of it (0 unless a .ttc).

Source

pub fn render( &mut self, text: &str, style: &TextStyle, scale: f32, out: [u32; 2], ) -> Result<Option<Rendered>>

Lays out text in style for an out = [w, h] px frame, lengths scaled by scale (output height / frame_size height).

Trait Implementations§

Source§

impl Debug for Typesetter

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<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, 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.