Font

Struct Font 

Source
pub struct Font(/* private fields */);
Expand description

A font instance with runtime data

This represents a single font that can be used for text rendering. Fonts are managed by the FontAtlas and should not be created directly.

TODO: Currently using pointer wrapper approach for simplicity. Future improvement: Implement complete field mapping like imgui-rs for better type safety.

Note: Our dear-imgui-sys uses newer ImGui version with ImFontBaked architecture, while imgui-rs uses older version with direct field mapping. This difference requires careful consideration when implementing full mapping.

Implementations§

Source§

impl Font

Source

pub fn id(&self) -> FontId

Returns the identifier of this font

Source

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

Returns the raw ImFont pointer

Source

pub fn is_glyph_in_font(&self, c: char) -> bool

Check if a glyph is available in this font

Source

pub fn calc_text_size( &self, size: f32, max_width: f32, wrap_width: f32, text: &str, ) -> [f32; 2]

Calculate text size for the given text

Source

pub fn calc_word_wrap_position( &self, size: f32, text: &str, wrap_width: f32, ) -> usize

Calculate word wrap position for the given text

Source

pub fn clear_output_data(&mut self)

Clear output data (glyphs storage, UV coordinates)

Source

pub fn add_remap_char(&mut self, from: char, to: char)

Add character remapping

Source

pub fn is_glyph_range_unused(&self, c_begin: u32, c_last: u32) -> bool

Check if a glyph range is unused

Trait Implementations§

Source§

impl Debug for Font

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Font

§

impl RefUnwindSafe for Font

§

impl !Send for Font

§

impl !Sync for Font

§

impl Unpin for Font

§

impl UnwindSafe for Font

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