pub struct TextTextures { /* private fields */ }Expand description
Fonts and the texts rasterized with them, keyed by content and render size.
Implementations§
Source§impl TextTextures
impl TextTextures
Sourcepub fn add_font(
&mut self,
family: impl Into<String>,
bytes: impl Into<Arc<[u8]>>,
face_index: u32,
) -> Result<(), TextError>
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.
Sourcepub fn font_count(&self) -> usize
pub fn font_count(&self) -> usize
Fonts in the fallback stack.
Sourcepub fn prepare(
&mut self,
renderer: &dyn TextUpload,
frame: &FrameDesc<'_>,
size: RenderSize,
) -> Result<(), TextError>
pub fn prepare( &mut self, renderer: &dyn TextUpload, 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.
Sourcepub fn layout(&self, key: u128) -> Option<Arc<PreparedLayout>>
pub fn layout(&self, key: u128) -> Option<Arc<PreparedLayout>>
The prepared layout with key, as layout_key names it.
Sourcepub fn measure_layout(
&self,
root: &LayoutNode,
time: MediaTime,
size: RenderSize,
canvas: (u32, u32),
) -> Result<LayoutBounds, TextError>
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.
Sourcepub fn prepare_at(
&mut self,
renderer: &dyn TextUpload,
project: &EngineProject,
time: MediaTime,
size: RenderSize,
) -> Result<(), EngineError>
pub fn prepare_at( &mut self, renderer: &dyn TextUpload, 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.
Sourcepub fn measure(
&self,
text: &str,
style: &TextStyle,
size: RenderSize,
) -> Result<TextBounds, TextError>
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.
Trait Implementations§
Source§impl Debug for TextTextures
impl Debug for TextTextures
Auto Trait Implementations§
impl !RefUnwindSafe for TextTextures
impl !UnwindSafe for TextTextures
impl Freeze for TextTextures
impl Send for TextTextures
impl Sync for TextTextures
impl Unpin for TextTextures
impl UnsafeUnpin for TextTextures
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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