Struct epaint::text::font::Font

source ·
pub struct Font {
    fonts: Vec<Arc<FontImpl>>,
    characters: Option<BTreeSet<char>>,
    replacement_glyph: (usize, GlyphInfo),
    pixels_per_point: f32,
    row_height: f32,
    glyph_info_cache: HashMap<char, (usize, GlyphInfo)>,
}
Expand description

Wrapper over multiple FontImpl (e.g. a primary + fallbacks for emojis)

Fields§

§fonts: Vec<Arc<FontImpl>>§characters: Option<BTreeSet<char>>

Lazily calculated.

§replacement_glyph: (usize, GlyphInfo)§pixels_per_point: f32§row_height: f32§glyph_info_cache: HashMap<char, (usize, GlyphInfo)>

Implementations§

source§

impl Font

source

pub fn new(fonts: Vec<Arc<FontImpl>>) -> Self

source

pub fn preload_characters(&mut self, s: &str)

source

pub fn preload_common_characters(&mut self)

source

pub fn characters(&mut self) -> &BTreeSet<char>

All supported characters.

source

pub fn round_to_pixel(&self, point: f32) -> f32

source

pub fn row_height(&self) -> f32

Height of one row of text. In points

source

pub fn uv_rect(&self, c: char) -> UvRect

source

pub fn glyph_width(&mut self, c: char) -> f32

Width of this character in points.

source

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

Can we display this glyph?

source

pub fn has_glyphs(&mut self, s: &str) -> bool

Can we display all the glyphs in this text?

source

fn glyph_info(&mut self, c: char) -> (usize, GlyphInfo)

\n will (intentionally) show up as the replacement character.

source

pub(crate) fn font_impl_and_glyph_info( &mut self, c: char, ) -> (Option<&FontImpl>, GlyphInfo)

source

fn glyph_info_no_cache_or_fallback( &mut self, c: char, ) -> Option<(usize, GlyphInfo)>

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, 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>,

§

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>,

§

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.