Skip to main content

TextTextures

Struct TextTextures 

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

Fonts and the texts rasterized with them, keyed by content and render size.

Implementations§

Source§

impl TextTextures

Source

pub fn new() -> Self

No fonts and no texts.

Source

pub fn add_font( &mut self, family: impl Into<String>, bytes: impl Into<Arc<[u8]>>, face_index: u32, ) -> Result<(), TextError>

Appends an OpenType font to the fallback stack text draws with. Texts already rasterized are dropped.

§Errors

Returns TextError::Raster for malformed font bytes.

Source

pub fn font_count(&self) -> usize

Fonts in the fallback stack.

Source

pub fn prepare( &mut self, renderer: &Renderer, frame: &FrameDesc<'_>, size: RenderSize, ) -> Result<(), TextError>

Rasterizes and uploads every text frame shows at size that is not already held: its captions and the text generators its clips draw. Resolves every layout it draws that is not already held, and rasterizes its texts. Forgets the least recently shown beyond a small number.

§Errors

Returns TextError when a text cannot be rasterized or uploaded; with no fonts registered, only if the frame shows one.

Source

pub fn layout(&self, key: u128) -> Option<Arc<PreparedLayout>>

The prepared layout with key, as layout_key names it.

Source

pub fn measure_layout( &self, root: &LayoutNode, time: MediaTime, size: RenderSize, canvas: (u32, u32), ) -> Result<LayoutBounds, TextError>

Where each node of root lies on a picture of size at picture time time, its pixels those of a canvas canvas, laid out with these fonts: crate::measure_layout.

§Errors

Returns TextError::Raster as Self::prepare would for its texts.

Source

pub fn prepare_at( &mut self, renderer: &Renderer, project: &EngineProject, time: MediaTime, size: RenderSize, ) -> Result<(), EngineError>

Self::prepare for the frame of project at time, rendered at size; nothing to do, and no evaluation, when the project draws no text (crate::EngineProject::draws_text).

§Errors

Returns crate::EngineError::Evaluate or crate::EngineError::Text.

Source

pub fn measure( &self, text: &str, style: &TextStyle, size: RenderSize, ) -> Result<TextBounds, TextError>

Where text in style lies on a canvas of size, drawn with these fonts: measure_text.

§Errors

Returns TextError::Raster as Self::prepare would for the text.

Source

pub fn get(&self, key: u64) -> Option<TextTexture<'_>>

The prepared text with key, as text_key names it.

Trait Implementations§

Source§

impl Debug for TextTextures

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for TextTextures

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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, 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,