pub struct GlyphCache<'a, F, T> {
    pub font: Font<'a>,
    pub factory: F,
    /* private fields */
}
Expand description

A struct used for caching rendered font.

Fields§

§font: Font<'a>

The font.

§factory: F

The factory used to create textures.

Implementations§

source§

impl<'a, F, T> GlyphCache<'a, F, T>where T: CreateTexture<F> + UpdateTexture<F> + ImageSize,

source

pub fn from_font( font: Font<'a>, factory: F, settings: TextureSettings ) -> GlyphCache<'a, F, T>

Constructs a GlyphCache from a Font.

source

pub fn new<P>( font: P, factory: F, settings: TextureSettings ) -> Result<GlyphCache<'static, F, T>, Error>where P: AsRef<Path>,

Constructor for a GlyphCache.

source

pub fn from_bytes( font: &'a [u8], factory: F, settings: TextureSettings ) -> Result<GlyphCache<'a, F, T>, ()>

Creates a GlyphCache for a font stored in memory.

source

pub fn preload_chars<I>( &mut self, size: u32, chars: I ) -> Result<(), <T as TextureOp<F>>::Error>where I: Iterator<Item = char>,

Load all characters in the chars iterator for size

source

pub fn preload_printable_ascii( &mut self, size: u32 ) -> Result<(), <T as TextureOp<F>>::Error>

Load all the printable ASCII characters for size. Includes space.

source

pub fn opt_character(&self, size: u32, ch: char) -> Option<Character<'_, T>>

Return ch for size if it’s already cached. Don’t load. See the preload_* functions.

Trait Implementations§

source§

impl<'b, F, T> CharacterCache for GlyphCache<'b, F, T>where T: ImageSize + CreateTexture<F> + UpdateTexture<F>,

§

type Texture = T

The texture type associated with the character cache.
§

type Error = <T as TextureOp<F>>::Error

The error type associated with the character cache.
source§

fn character( &mut self, size: u32, ch: char ) -> Result<Character<'_, T>, <GlyphCache<'b, F, T> as CharacterCache>::Error>

Get reference to character.
source§

fn width(&mut self, size: u32, text: &str) -> Result<f64, Self::Error>

Return the width for some given text.

Auto Trait Implementations§

§

impl<'a, F, T> RefUnwindSafe for GlyphCache<'a, F, T>where F: RefUnwindSafe, T: RefUnwindSafe,

§

impl<'a, F, T> Send for GlyphCache<'a, F, T>where F: Send, T: Send,

§

impl<'a, F, T> Sync for GlyphCache<'a, F, T>where F: Sync, T: Sync,

§

impl<'a, F, T> Unpin for GlyphCache<'a, F, T>where F: Unpin, T: Unpin,

§

impl<'a, F, T> UnwindSafe for GlyphCache<'a, F, T>where F: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.