Skip to main content

VectorFont

Struct VectorFont 

Source
pub struct VectorFont { /* private fields */ }

Implementations§

Source§

impl VectorFont

Source

pub fn from_path(path: &str) -> Result<Self, String>

Load a font from a TTF/OTF file using its default weight.

Source

pub fn from_path_weight(path: &str, weight: Option<f32>) -> Result<Self, String>

Load a font, optionally pinning the variable-font weight axis (wght). The glyph cache lives at cache/fonts/<file-stem>[@<weight>]/.

Source

pub fn from_bytes( bytes: Vec<u8>, name: &str, weight: Option<f32>, ) -> Result<Self, String>

Source

pub fn ascent(&self) -> f32

Source

pub fn descent(&self) -> f32

Source

pub fn advance(&mut self, ch: char) -> f32

Normalized advance width of ch.

Source

pub fn measure(&mut self, text: &str, px: f32) -> f32

Pixel width of text at size px.

Source

pub fn glyph_outline(&mut self, ch: char, tol_em: f32) -> GlyphOutline

Flattened outline of ch, with curves subdivided so the deviation stays under tol_em (express your pixel tolerance as tol_px / px).

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.