pub struct BitmapTextRenderer { /* private fields */ }Expand description
Bitmap-only text renderer.
Uses only a bitmap glyph atlas for rendering, with no SDF support. This provides the lowest memory footprint (~8 MB with default atlas).
Best for UI text, labels, and other small text that doesn’t need effects.
Implementations§
Source§impl BitmapTextRenderer
impl BitmapTextRenderer
Sourcepub fn new(context: Arc<GraphicsContext>, font_system: FontSystem) -> Self
pub fn new(context: Arc<GraphicsContext>, font_system: FontSystem) -> Self
Create a new bitmap text renderer with default configuration.
Sourcepub fn with_config(
context: Arc<GraphicsContext>,
font_system: FontSystem,
config: TextRendererConfig,
) -> Self
pub fn with_config( context: Arc<GraphicsContext>, font_system: FontSystem, config: TextRendererConfig, ) -> Self
Create a new bitmap text renderer with custom configuration.
Sourcepub fn measure_text(&self, text: &Text) -> (f32, f32)
pub fn measure_text(&self, text: &Text) -> (f32, f32)
Measure text dimensions without rendering.
Sourcepub fn buffer_bounds(&self, buffer: &TextBuffer) -> (f32, f32)
pub fn buffer_bounds(&self, buffer: &TextBuffer) -> (f32, f32)
Get the logical (unscaled) bounds of a prepared text buffer.
Sourcepub fn get_text_metrics(&self, text: &Text) -> TextMetrics
pub fn get_text_metrics(&self, text: &Text) -> TextMetrics
Get font metrics for the given text style.
Sourcepub fn set_viewport(&mut self, viewport: Viewport)
pub fn set_viewport(&mut self, viewport: Viewport)
Set the viewport for rendering.
Sourcepub fn prepare(&mut self, text: &Text) -> TextBuffer
pub fn prepare(&mut self, text: &Text) -> TextBuffer
Prepare text for rendering.
Sourcepub fn draw_text(&mut self, buffer: &mut TextBuffer, position: Vec2)
pub fn draw_text(&mut self, buffer: &mut TextBuffer, position: Vec2)
Draw text at a position.
Sourcepub fn render(&mut self, render_pass: &mut RenderPass<'_>)
pub fn render(&mut self, render_pass: &mut RenderPass<'_>)
Render all queued text to the given render pass.
Sourcepub fn font_system(&self) -> Arc<RwLock<FontSystem>>
pub fn font_system(&self) -> Arc<RwLock<FontSystem>>
Get the font system.
Sourcepub fn swash_cache(&self) -> Arc<RwLock<SwashCache>>
pub fn swash_cache(&self) -> Arc<RwLock<SwashCache>>
Get the swash cache.
Sourcepub fn atlas_size(&self) -> u32
pub fn atlas_size(&self) -> u32
Get the atlas size in pixels.
Sourcepub fn atlas_texture_view(&self) -> &TextureView
pub fn atlas_texture_view(&self) -> &TextureView
Get the atlas texture view for binding.
Sourcepub fn atlas_sampler(&self) -> &Sampler
pub fn atlas_sampler(&self) -> &Sampler
Get the atlas sampler for binding.
Sourcepub fn is_atlas_dirty(&self) -> bool
pub fn is_atlas_dirty(&self) -> bool
Check if the atlas has pending changes.
Sourcepub fn upload_atlas_if_dirty(&mut self)
pub fn upload_atlas_if_dirty(&mut self)
Upload atlas data to GPU if dirty.
Sourcepub fn ensure_glyph_in_atlas(
&mut self,
cache_key: CacheKey,
) -> Option<&AtlasEntry>
pub fn ensure_glyph_in_atlas( &mut self, cache_key: CacheKey, ) -> Option<&AtlasEntry>
Ensure a glyph is in the atlas using a cache key.
Sourcepub fn get_glyph_placement(
&mut self,
cache_key: CacheKey,
) -> Option<GlyphPlacement>
pub fn get_glyph_placement( &mut self, cache_key: CacheKey, ) -> Option<GlyphPlacement>
Get glyph placement information.
Sourcepub fn ensure_glyph_with_placement(
&mut self,
cache_key: CacheKey,
) -> Option<(AtlasEntry, GlyphPlacement)>
pub fn ensure_glyph_with_placement( &mut self, cache_key: CacheKey, ) -> Option<(AtlasEntry, GlyphPlacement)>
Ensure a glyph is in the atlas and get its placement info.
Sourcepub fn get_atlas_entry(&self, cache_key: CacheKey) -> Option<&AtlasEntry>
pub fn get_atlas_entry(&self, cache_key: CacheKey) -> Option<&AtlasEntry>
Get an atlas entry by cache key (if it exists).
Trait Implementations§
Source§impl TextRender for BitmapTextRenderer
impl TextRender for BitmapTextRenderer
Source§fn draw_text(&mut self, buffer: &mut TextBuffer, position: Vec2)
fn draw_text(&mut self, buffer: &mut TextBuffer, position: Vec2)
Source§fn render(&mut self, render_pass: &mut RenderPass<'_>)
fn render(&mut self, render_pass: &mut RenderPass<'_>)
Source§fn set_viewport(&mut self, viewport: Viewport)
fn set_viewport(&mut self, viewport: Viewport)
Source§fn buffer_bounds(&self, buffer: &TextBuffer) -> (f32, f32)
fn buffer_bounds(&self, buffer: &TextBuffer) -> (f32, f32)
Auto Trait Implementations§
impl Freeze for BitmapTextRenderer
impl !RefUnwindSafe for BitmapTextRenderer
impl Send for BitmapTextRenderer
impl Sync for BitmapTextRenderer
impl Unpin for BitmapTextRenderer
impl UnsafeUnpin for BitmapTextRenderer
impl !UnwindSafe for BitmapTextRenderer
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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