pub struct TextTexturePipeline {
engine: FlexibleTextEngine,
renderer: RefCell<FlexibleTextRenderer>,
cache: RefCell<TextTextureCache>,
format: TextureFormat,
}Expand description
High-level pipeline: text → RenderTexture, with caching.
Owns its own FlexibleTextEngine + FlexibleTextRenderer +
TextTextureCache. The engine + renderer share an
Arc<Mutex<FontSystem>> (M-TEXT.3 contract).
The pipeline is opt-in — callers construct it explicitly. It is
not held by crate::render::Renderer, so apps that never render
flexible text don’t pay glyphon + cache costs.
Fields§
§engine: FlexibleTextEngine§renderer: RefCell<FlexibleTextRenderer>§cache: RefCell<TextTextureCache>§format: TextureFormatImplementations§
Source§impl TextTexturePipeline
impl TextTexturePipeline
Sourcepub fn new(app: &Application, format: TextureFormat) -> Self
pub fn new(app: &Application, format: TextureFormat) -> Self
Build a pipeline with a system-fonts FlexibleTextEngine.
Sourcepub fn from_font_paths<P: AsRef<Path>>(
app: &Application,
format: TextureFormat,
paths: impl IntoIterator<Item = P>,
) -> Result<Self>
pub fn from_font_paths<P: AsRef<Path>>( app: &Application, format: TextureFormat, paths: impl IntoIterator<Item = P>, ) -> Result<Self>
Build a pipeline with an engine seeded from explicit font
files. See FlexibleTextEngine::from_font_paths.
§Errors
Returns io::Error if any font path can’t be opened or parsed.
Sourcepub fn from_font_bytes(
app: &Application,
format: TextureFormat,
bytes: impl IntoIterator<Item = Vec<u8>>,
) -> Self
pub fn from_font_bytes( app: &Application, format: TextureFormat, bytes: impl IntoIterator<Item = Vec<u8>>, ) -> Self
Build a pipeline with an engine seeded from raw font bytes.
See FlexibleTextEngine::from_font_bytes — designed for
crates that ship their fonts via include_bytes! and want the
same font set in native + wasm builds.
Sourcepub fn format(&self) -> TextureFormat
pub fn format(&self) -> TextureFormat
Color format the pipeline writes into (matches what was passed
to Self::new / Self::from_font_paths).
Sourcepub fn stats(&self) -> (u64, u64)
pub fn stats(&self) -> (u64, u64)
(hits, misses) since construction. Useful in tests that
verify the cache short-circuits on repeated lookups.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Drop every cached entry.
Sourcepub fn engine(&self) -> &FlexibleTextEngine
pub fn engine(&self) -> &FlexibleTextEngine
Borrow the engine for direct layout queries (metrics, etc.).
Sourcepub fn render(
&self,
app: &Application,
text: &WispText,
width_px: u32,
height_px: u32,
) -> Arc<RenderTexture>
pub fn render( &self, app: &Application, text: &WispText, width_px: u32, height_px: u32, ) -> Arc<RenderTexture>
Render text into a width_px × height_px RenderTexture,
or return the cached version if text + dimensions match an
earlier call.
The text is positioned with its top-left at the texture’s top-left
(NDC (-1, +1)) and rendered with crate::color::Color
WHITE as the default per-glyph color (the actual glyph color
comes from crate::text::WispTextStyle::color).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TextTexturePipeline
impl !RefUnwindSafe for TextTexturePipeline
impl Send for TextTexturePipeline
impl !Sync for TextTexturePipeline
impl Unpin for TextTexturePipeline
impl UnsafeUnpin for TextTexturePipeline
impl !UnwindSafe for TextTexturePipeline
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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