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: &Renderer,
frame: &FrameDesc<'_>,
size: RenderSize,
) -> Result<(), TextError>
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.
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: &Renderer,
project: &EngineProject,
time: MediaTime,
size: RenderSize,
) -> Result<(), EngineError>
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.
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.