pub struct Fonts {
pub fonts: FontsImpl,
/* private fields */
}
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_pass
and Self::font_image_delta
once every frame.
Fields§
§fonts: FontsImpl
Implementations§
Source§impl Fonts
impl Fonts
Sourcepub fn new(
max_texture_side: usize,
text_alpha_from_coverage: AlphaFromCoverage,
definitions: FontDefinitions,
) -> Self
pub fn new( max_texture_side: usize, text_alpha_from_coverage: AlphaFromCoverage, definitions: FontDefinitions, ) -> Self
Sourcepub fn begin_pass(
&mut self,
max_texture_side: usize,
text_alpha_from_coverage: AlphaFromCoverage,
)
pub fn begin_pass( &mut self, max_texture_side: usize, text_alpha_from_coverage: AlphaFromCoverage, )
Call at the start of each frame with the latest known
pixels_per_point
, max_texture_side
, and text_alpha_from_coverage
.
Call after painting the previous frame, but before using Fonts
for the new frame.
This function will react to changes in pixels_per_point
, max_texture_side
, and text_alpha_from_coverage
,
as well as notice when the font atlas is getting full, and handle that.
Sourcepub fn font_image_delta(&mut self) -> Option<ImageDelta>
pub fn font_image_delta(&mut 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 max_texture_side(&self) -> usize
pub fn definitions(&self) -> &FontDefinitions
Sourcepub fn texture_atlas(&self) -> &TextureAtlas
pub fn texture_atlas(&self) -> &TextureAtlas
The font atlas.
Pass this to crate::Tessellator
.
Sourcepub fn image(&self) -> ColorImage
pub fn image(&self) -> ColorImage
The full font atlas image.
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 has_glyphs(&mut self, font_id: &FontId, s: &str) -> bool
pub fn has_glyphs(&mut self, font_id: &FontId, s: &str) -> bool
Can we display all the glyphs in this text?
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_pass
.
Sourcepub fn with_pixels_per_point(&mut self, pixels_per_point: f32) -> FontsView<'_>
pub fn with_pixels_per_point(&mut self, pixels_per_point: f32) -> FontsView<'_>
Returns a FontsView
with the given pixels_per_point
that can be used to do text layout.