FaceCache

Struct FaceCache 

Source
pub struct FaceCache<T> { /* private fields */ }
Expand description

A cache for a single font/size pairing.

Implementations§

Source§

impl<T> FaceCache<T>

Source

pub fn new<I, F, E>( font: Font, scale: f32, chars: I, f: F, ) -> Result<FaceCache<T>, E>
where I: Iterator<Item = char>, F: Fn(Bitmap) -> Result<T, E>,

Constructs a new FaceCache of a font at a specific scale.

The characters in chars are pre-loaded into the atlas. If you need any more characters to draw things with, use prepare_string.

Source

pub fn prepare_string<F, E>(&mut self, s: &str, f: F) -> Result<(), E>
where F: Fn(Bitmap) -> Result<T, E>,

Adds all the characters in the given string to the cache.

Source

pub fn needs_preparing(&self, s: &str) -> bool

Returns true if a call to prepare_string is necessary to draw this string.

Source

pub fn drawing_commands( &self, s: &str, ) -> Result<Vec<DrawCommand<'_, T>>, FontCacheError<Void>>

Returns a vector of drawing commands that describe how to lay out characters for printing

Source

pub fn drawing_commands_prepared<F, E>( &mut self, s: &str, f: F, ) -> Result<Vec<DrawCommand<'_, T>>, E>
where F: Fn(Bitmap) -> Result<T, E>,

Returns a Vec of DrawCommands that pre-prepare the face-cache for drawing.

The only way that this will fail is if the rendering function f fails.

Trait Implementations§

Source§

impl<T: Debug> Debug for FaceCache<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for FaceCache<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for FaceCache<T>
where T: RefUnwindSafe,

§

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

§

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

§

impl<T> Unpin for FaceCache<T>
where T: Unpin,

§

impl<T> UnwindSafe for FaceCache<T>
where T: UnwindSafe,

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.