pub struct Fonts(Arc<Mutex<FontsAndCache>>);
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.
Tuple Fields§
§0: Arc<Mutex<FontsAndCache>>
Implementations§
§impl Fonts
impl Fonts
pub 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
pub fn begin_pass(&self, pixels_per_point: f32, max_texture_side: usize)
pub fn begin_pass(&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.
pub 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
pub fn texture_atlas(&self) -> Arc<Mutex<TextureAtlas>>
pub fn texture_atlas(&self) -> Arc<Mutex<TextureAtlas>>
The font atlas.
Pass this to crate::Tessellator
.
pub 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
.
pub 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.
pub fn has_glyphs(&self, font_id: &FontId, s: &str) -> bool
pub fn has_glyphs(&self, font_id: &FontId, s: &str) -> bool
Can we display all the glyphs in this text?
pub 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
pub fn families(&self) -> Vec<FontFamily>
pub fn families(&self) -> Vec<FontFamily>
List of all known font families.
pub 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
pub 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
.
pub 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.
pub 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.
pub 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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Fonts
impl !RefUnwindSafe for Fonts
impl Send for Fonts
impl Sync for Fonts
impl Unpin for Fonts
impl !UnwindSafe for Fonts
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request