pub struct FontAtlas { /* private fields */ }Expand description
Font atlas that manages multiple fonts and their texture data
The font atlas is responsible for:
- Loading and managing multiple fonts
- Packing font glyphs into texture atlases
- Providing texture data for rendering
Implementations§
Source§impl FontAtlas
impl FontAtlas
Sourcepub fn with_font_loader(loader: &FontLoader) -> Self
pub fn with_font_loader(loader: &FontLoader) -> Self
Creates a new font atlas with a custom font loader
Sourcepub fn raw(&self) -> *mut ImFontAtlas
pub fn raw(&self) -> *mut ImFontAtlas
Returns the raw ImFontAtlas pointer
Sourcepub fn set_font_loader(&mut self, loader: &FontLoader)
pub fn set_font_loader(&mut self, loader: &FontLoader)
Sets the font loader for this atlas
This allows using custom font backends like FreeType with additional features. Must be called before adding any fonts.
Sourcepub fn set_font_loader_flags(&mut self, flags: FontLoaderFlags)
pub fn set_font_loader_flags(&mut self, flags: FontLoaderFlags)
Sets global font loader flags
These flags apply to all fonts loaded with this atlas unless overridden in individual FontConfig instances.
Sourcepub fn font_loader_flags(&self) -> FontLoaderFlags
pub fn font_loader_flags(&self) -> FontLoaderFlags
Gets the current font loader flags
Sourcepub fn add_font(&mut self, font_sources: &[FontSource<'_>]) -> FontId
pub fn add_font(&mut self, font_sources: &[FontSource<'_>]) -> FontId
Add a font to the atlas using FontSource
Sourcepub fn add_font_with_config(&mut self, font_cfg: &FontConfig) -> &mut Font
pub fn add_font_with_config(&mut self, font_cfg: &FontConfig) -> &mut Font
Add a font to the atlas using FontConfig
Sourcepub fn add_font_default(&mut self, font_cfg: Option<&FontConfig>) -> &mut Font
pub fn add_font_default(&mut self, font_cfg: Option<&FontConfig>) -> &mut Font
Add the default font to the atlas
Sourcepub fn add_font_from_file_ttf(
&mut self,
filename: &str,
size_pixels: f32,
font_cfg: Option<&FontConfig>,
glyph_ranges: Option<&[ImWchar]>,
) -> Option<&mut Font>
pub fn add_font_from_file_ttf( &mut self, filename: &str, size_pixels: f32, font_cfg: Option<&FontConfig>, glyph_ranges: Option<&[ImWchar]>, ) -> Option<&mut Font>
Add a font from a TTF file
Sourcepub fn add_font_from_memory_ttf(
&mut self,
font_data: &[u8],
size_pixels: f32,
font_cfg: Option<&FontConfig>,
glyph_ranges: Option<&[ImWchar]>,
) -> Option<&mut Font>
pub fn add_font_from_memory_ttf( &mut self, font_data: &[u8], size_pixels: f32, font_cfg: Option<&FontConfig>, glyph_ranges: Option<&[ImWchar]>, ) -> Option<&mut Font>
Add a font from memory (TTF data)
Sourcepub fn remove_font(&mut self, font: &mut Font)
pub fn remove_font(&mut self, font: &mut Font)
Remove a font from the atlas
Sourcepub fn clear_fonts(&mut self)
pub fn clear_fonts(&mut self)
Clear only the fonts (keep texture data)
Sourcepub fn clear_tex_data(&mut self)
pub fn clear_tex_data(&mut self)
Clear only the texture data (keep fonts)
Sourcepub fn get_glyph_ranges_default(&self) -> &[ImWchar] ⓘ
pub fn get_glyph_ranges_default(&self) -> &[ImWchar] ⓘ
Get default glyph ranges (Basic Latin + Latin Supplement)
Sourcepub fn build(&mut self) -> bool
pub fn build(&mut self) -> bool
Build the font atlas texture
This is a simplified build process. For more control, use the individual build functions.
Sourcepub fn get_tex_data_info(&self) -> Option<(u32, u32)>
pub fn get_tex_data_info(&self) -> Option<(u32, u32)>
Get texture data information
Returns (min_width, min_height) if texture is built Note: Our Dear ImGui version uses a different texture management system
Sourcepub unsafe fn get_tex_data_ptr(&self) -> Option<(*const u8, u32, u32)>
pub unsafe fn get_tex_data_ptr(&self) -> Option<(*const u8, u32, u32)>
Get raw texture data pointer and dimensions
§Safety
The returned pointer is only valid while the FontAtlas exists and the texture is built. The caller must ensure proper lifetime management.
Sourcepub fn get_tex_ref(&self) -> ImTextureRef
pub fn get_tex_ref(&self) -> ImTextureRef
Get texture reference for the font atlas
Note: Our Dear ImGui version uses ImTextureRef instead of a simple texture ID
Sourcepub fn set_tex_ref(&mut self, tex_ref: ImTextureRef)
pub fn set_tex_ref(&mut self, tex_ref: ImTextureRef)
Set texture reference for the font atlas
Sourcepub fn tex_data_mut(&mut self) -> Option<&mut TextureData>
pub fn tex_data_mut(&mut self) -> Option<&mut TextureData>
Get a mutable view of the atlas texture data, if available
Sourcepub fn set_texture_id(&mut self, tex_id: TextureId)
pub fn set_texture_id(&mut self, tex_id: TextureId)
Convenience: set atlas texture id and mark status OK Also updates TexRef so draw commands use this texture id.
Sourcepub fn get_tex_data(&self) -> *mut ImTextureData
pub fn get_tex_data(&self) -> *mut ImTextureData
Get texture data pointer
Returns the current texture data used by the atlas
Sourcepub fn get_tex_uv_scale(&self) -> [f32; 2]
pub fn get_tex_uv_scale(&self) -> [f32; 2]
Get texture UV scale
Sourcepub fn get_tex_uv_white_pixel(&self) -> [f32; 2]
pub fn get_tex_uv_white_pixel(&self) -> [f32; 2]
Get texture UV white pixel coordinates