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 and drops rasterized texts.

§Errors

Returns TextError::Raster for malformed font bytes.

Source

pub fn font_count(&self) -> usize

Fonts in the fallback stack.

Source

pub fn unmatched_font_families(&self) -> Vec<String>

Requested families no registered font has, sorted (alpha2_text::TextRasterizer::unmatched_families).

Source

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

Rasterizes and uploads every text and resolves every layout frame shows at size that is not already held, evicting 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>

crate::measure_layout with these fonts.

§Errors

Returns TextError::Raster as Self::prepare would.

Source

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

Self::prepare for project at time; skips 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: &TextAt<'_>, style: &TextStyle, size: RenderSize, ) -> Result<TextBounds, TextError>

crate::measure_text with these fonts.

§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 crate::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§

§

impl !Freeze for TextTextures

§

impl !RefUnwindSafe for TextTextures

§

impl !UnwindSafe for TextTextures

§

impl Forget for TextTextures

§

impl Move for TextTextures

§

impl Send for TextTextures
where RawVecInner: Send, Arc<[u8]>: Send, RawTable<(u64, CacheEntry)>: Send, NodeRef<Owned, u64, u64, LeafOrInternal>: Send, BoxRaw<(u64, u64)>: Send, RawTable<(u64, (Arc<DrawnCluster>, u64))>: Send, Mutex<BTreeSet<String>>: Send, RawTable<(u64, TextEntry)>: Send, RawTable<(u128, LayoutEntry)>: Send, RawTable<(u64, ShapedEntry)>: Send,

§

impl Sync for TextTextures
where RawVecInner: Sync, Arc<[u8]>: Sync, RawTable<(u64, CacheEntry)>: Sync, NodeRef<Owned, u64, u64, LeafOrInternal>: Sync, BoxRaw<(u64, u64)>: Sync, RawTable<(u64, (Arc<DrawnCluster>, u64))>: Sync, Mutex<BTreeSet<String>>: Sync, RawTable<(u64, TextEntry)>: Sync, RawTable<(u128, LayoutEntry)>: Sync, RawTable<(u64, ShapedEntry)>: Sync,

§

impl Unpin for TextTextures
where *const u8 is !null: Unpin, Arc<[u8]>: Unpin, Arc<TextRasterResult>: Unpin, *const LeafNode<u64, u64> is !null: Unpin, Box<(u64, u64)>: Unpin, Arc<DrawnCluster>: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, *const LeafNode<String, SetValZST> is !null: Unpin, Box<(String, SetValZST)>: Unpin, Arc<TextPixels>: Unpin, Arc<PreparedLayout>: Unpin, Box<DataBinding>: Unpin, Arc<ShapedText>: Unpin,

§

impl UnsafeUnpin for TextTextures
where *const u8 is !null: UnsafeUnpin, PhantomData<LoadedFont>: UnsafeUnpin, PhantomData<(u64, CacheEntry)>: UnsafeUnpin, *const LeafNode<u64, u64> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(u64, u64)>>: UnsafeUnpin, PhantomData<(u64, (Arc<DrawnCluster>, u64))>: UnsafeUnpin, Align4<u32>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, *const LeafNode<String, SetValZST> is !null: UnsafeUnpin, PhantomData<Box<(String, SetValZST)>>: UnsafeUnpin, PhantomData<(u64, TextEntry)>: UnsafeUnpin, PhantomData<(u128, LayoutEntry)>: UnsafeUnpin, PhantomData<(u64, ShapedEntry)>: UnsafeUnpin,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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,