pub struct TextRendererConfig {
pub atlas_size: u32,
pub sdf: SdfConfig,
pub surface_format: TextureFormat,
pub depth_format: Option<TextureFormat>,
}Expand description
Configuration for text renderer backends.
Controls atlas texture sizes and surface formats for pipelines. Smaller atlases use less memory but may need to evict glyphs more frequently.
§Memory Usage
| Config | Atlas Size | Memory/Atlas | Bitmap Total | Hybrid Total |
|---|---|---|---|---|
| small() | 512x512 | 0.5 MB | 1 MB | 2 MB |
| medium() | 1024x1024 | 2 MB | 4 MB | 8 MB |
| large() | 2048x2048 | 4 MB | 8 MB | 16 MB |
§Example
use astrelis_text::{BitmapTextRenderer, TextRendererConfig};
// For memory-constrained environments
let renderer = BitmapTextRenderer::with_config(
context,
font_system,
TextRendererConfig::small()
);
// Create from window for automatic format matching
let renderer = FontRenderer::with_config(
context,
font_system,
TextRendererConfig::from_window(&window)
);Fields§
§atlas_size: u32Atlas texture size (width and height, must be power of 2). Default: 2048
sdf: SdfConfigSDF-specific settings (only used by SDF/Hybrid renderers).
surface_format: TextureFormatSurface texture format for pipelines. Default: Bgra8UnormSrgb
depth_format: Option<TextureFormat>Depth format for z-ordering. None disables depth testing.
Default: None
Implementations§
Source§impl TextRendererConfig
impl TextRendererConfig
Sourcepub fn from_window(window: &RenderWindow) -> Self
pub fn from_window(window: &RenderWindow) -> Self
Create configuration from a RenderWindow, inheriting its format settings.
This is the recommended way to create a config as it ensures pipeline-renderpass format compatibility automatically.
Sourcepub fn small() -> Self
pub fn small() -> Self
Small config for memory-constrained environments (512x512, ~0.5 MB per atlas).
Best for applications with limited text or embedded devices.
Sourcepub fn medium() -> Self
pub fn medium() -> Self
Medium config (~1024x1024, ~2 MB per atlas).
Good balance for most applications.
Sourcepub fn large() -> Self
pub fn large() -> Self
Large config for text-heavy applications (2048x2048, ~4 MB per atlas).
Best for applications with lots of unique glyphs or fonts.
Sourcepub fn with_atlas_size(self, size: u32) -> Self
pub fn with_atlas_size(self, size: u32) -> Self
Sourcepub fn with_sdf_config(self, config: SdfConfig) -> Self
pub fn with_sdf_config(self, config: SdfConfig) -> Self
Set SDF configuration.
Sourcepub fn with_surface_format(self, format: TextureFormat) -> Self
pub fn with_surface_format(self, format: TextureFormat) -> Self
Set surface format for pipelines.
Sourcepub fn with_depth(self, format: TextureFormat) -> Self
pub fn with_depth(self, format: TextureFormat) -> Self
Enable depth testing with the specified format.
Sourcepub fn without_depth(self) -> Self
pub fn without_depth(self) -> Self
Disable depth testing.
Trait Implementations§
Source§impl Clone for TextRendererConfig
impl Clone for TextRendererConfig
Source§fn clone(&self) -> TextRendererConfig
fn clone(&self) -> TextRendererConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TextRendererConfig
impl Debug for TextRendererConfig
Auto Trait Implementations§
impl Freeze for TextRendererConfig
impl RefUnwindSafe for TextRendererConfig
impl Send for TextRendererConfig
impl Sync for TextRendererConfig
impl Unpin for TextRendererConfig
impl UnsafeUnpin for TextRendererConfig
impl UnwindSafe for TextRendererConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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