pub struct Fonts(_);
Expand description
The collection of fonts used by epaint
.
Required in order to paint text. Create one and reuse. Cheap to clone.
Each Fonts
comes with a font atlas textures that needs to be used when painting.
If you are using egui
, use egui::Context::set_fonts
and egui::Context::fonts
.
You need to call Self::begin_frame
and Self::font_image_delta
once every frame.
Implementations
sourceimpl Fonts
impl Fonts
sourcepub fn new(
pixels_per_point: f32,
max_texture_side: usize,
definitions: FontDefinitions
) -> Fonts
pub fn new(
pixels_per_point: f32,
max_texture_side: usize,
definitions: FontDefinitions
) -> Fonts
sourcepub fn begin_frame(&self, pixels_per_point: f32, max_texture_side: usize)
pub fn begin_frame(&self, pixels_per_point: f32, max_texture_side: usize)
Call at the start of each frame with the latest known
pixels_per_point
and max_texture_side
.
Call after painting the previous frame, but before using Fonts
for the new frame.
This function will react to changes in pixels_per_point
and max_texture_side
,
as well as notice when the font atlas is getting full, and handle that.
sourcepub fn font_image_delta(&self) -> Option<ImageDelta>
pub fn font_image_delta(&self) -> Option<ImageDelta>
Call at the end of each frame (before painting) to get the change to the font texture since last call.
pub fn pixels_per_point(&self) -> f32
pub fn max_texture_side(&self) -> usize
sourcepub fn texture_atlas(&self) -> Arc<Mutex<TextureAtlas>>
pub fn texture_atlas(&self) -> Arc<Mutex<TextureAtlas>>
The font atlas.
Pass this to crate::Tessellator
.
sourcepub fn font_image_size(&self) -> [usize; 2]
pub fn font_image_size(&self) -> [usize; 2]
Current size of the font image.
Pass this to crate::Tessellator
.
sourcepub fn glyph_width(&self, font_id: &FontId, c: char) -> f32
pub fn glyph_width(&self, font_id: &FontId, c: char) -> f32
Width of this character in points.
sourcepub fn row_height(&self, font_id: &FontId) -> f32
pub fn row_height(&self, font_id: &FontId) -> f32
Height of one row of text in points
sourcepub fn families(&self) -> Vec<FontFamily, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn families(&self) -> Vec<FontFamily, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
List of all known font families.
sourcepub fn layout_job(&self, job: LayoutJob) -> Arc<Galley>
pub fn layout_job(&self, job: LayoutJob) -> Arc<Galley>
Layout some text.
This is the most advanced layout function.
See also Self::layout
, Self::layout_no_wrap
and
Self::layout_delayed_color
.
The implementation uses memoization so repeated calls are cheap.
pub fn num_galleys_in_cache(&self) -> usize
sourcepub fn font_atlas_fill_ratio(&self) -> f32
pub fn font_atlas_fill_ratio(&self) -> f32
How full is the font atlas?
This increases as new fonts and/or glyphs are used,
but can also decrease in a call to Self::begin_frame
.
sourcepub fn layout(
&self,
text: String,
font_id: FontId,
color: Color32,
wrap_width: f32
) -> Arc<Galley>
pub fn layout(
&self,
text: String,
font_id: FontId,
color: Color32,
wrap_width: f32
) -> Arc<Galley>
Will wrap text at the given width and line break at \n
.
The implementation uses memoization so repeated calls are cheap.
sourcepub fn layout_no_wrap(
&self,
text: String,
font_id: FontId,
color: Color32
) -> Arc<Galley>
pub fn layout_no_wrap(
&self,
text: String,
font_id: FontId,
color: Color32
) -> Arc<Galley>
Will line break at \n
.
The implementation uses memoization so repeated calls are cheap.
sourcepub fn layout_delayed_color(
&self,
text: String,
font_id: FontId,
wrap_width: f32
) -> Arc<Galley>
pub fn layout_delayed_color(
&self,
text: String,
font_id: FontId,
wrap_width: f32
) -> Arc<Galley>
Like Self::layout
, made for when you want to pick a color for the text later.
The implementation uses memoization so repeated calls are cheap.