FontAtlas

Struct FontAtlas 

Source
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

Source

pub fn new() -> Self

Creates a new font atlas with default settings

Source

pub fn with_font_loader(loader: &FontLoader) -> Self

Creates a new font atlas with a custom font loader

Source

pub fn raw(&self) -> *mut ImFontAtlas

Returns the raw ImFontAtlas pointer

Source

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.

Source

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.

Source

pub fn font_loader_flags(&self) -> FontLoaderFlags

Gets the current font loader flags

Source

pub fn add_font(&mut self, font_sources: &[FontSource<'_>]) -> FontId

Add a font to the atlas using FontSource

Source

pub fn add_font_with_config(&mut self, font_cfg: &FontConfig) -> &mut Font

Add a font to the atlas using FontConfig

Source

pub fn add_font_default(&mut self, font_cfg: Option<&FontConfig>) -> &mut Font

Add the default font to the atlas

Source

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

Source

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)

Source

pub fn remove_font(&mut self, font: &mut Font)

Remove a font from the atlas

Source

pub fn clear(&mut self)

Clear all fonts and texture data

Source

pub fn clear_fonts(&mut self)

Clear only the fonts (keep texture data)

Source

pub fn clear_tex_data(&mut self)

Clear only the texture data (keep fonts)

Source

pub fn get_glyph_ranges_default(&self) -> &[ImWchar]

Get default glyph ranges (Basic Latin + Latin Supplement)

Source

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.

Source

pub fn is_built(&self) -> bool

Check if the texture is built

Source

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

Source

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.

Source

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

Source

pub fn set_tex_ref(&mut self, tex_ref: ImTextureRef)

Set texture reference for the font atlas

Source

pub fn tex_data_mut(&mut self) -> Option<&mut TextureData>

Get a mutable view of the atlas texture data, if available

Source

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.

Source

pub fn get_tex_data(&self) -> *mut ImTextureData

Get texture data pointer

Returns the current texture data used by the atlas

Source

pub fn get_tex_uv_scale(&self) -> [f32; 2]

Get texture UV scale

Source

pub fn get_tex_uv_white_pixel(&self) -> [f32; 2]

Get texture UV white pixel coordinates

Trait Implementations§

Source§

impl Debug for FontAtlas

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FontAtlas

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for FontAtlas

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more