pub struct Font {
fonts: Vec<Arc<FontImpl>>,
characters: Option<BTreeMap<char, Vec<String>>>,
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<BTreeMap<char, Vec<String>>>
Lazily calculated.
replacement_glyph: (usize, GlyphInfo)
§pixels_per_point: f32
§row_height: f32
§glyph_info_cache: HashMap<char, (usize, GlyphInfo)>
Implementations§
source§impl Font
impl Font
pub fn new(fonts: Vec<Arc<FontImpl>>) -> Self
pub fn preload_characters(&mut self, s: &str)
pub fn preload_common_characters(&mut self)
sourcepub fn characters(&mut self) -> &BTreeMap<char, Vec<String>>
pub fn characters(&mut self) -> &BTreeMap<char, Vec<String>>
All supported characters, and in which font they are available in.
pub fn round_to_pixel(&self, point: f32) -> f32
sourcepub fn row_height(&self) -> f32
pub fn row_height(&self) -> f32
Height of one row of text. In points
pub fn uv_rect(&self, c: char) -> UvRect
sourcepub fn glyph_width(&mut self, c: char) -> f32
pub fn glyph_width(&mut self, c: char) -> f32
Width of this character in points.
sourcepub fn has_glyphs(&mut self, s: &str) -> bool
pub fn has_glyphs(&mut self, s: &str) -> bool
Can we display all the glyphs in this text?
sourcefn glyph_info(&mut self, c: char) -> (usize, GlyphInfo)
fn glyph_info(&mut self, c: char) -> (usize, GlyphInfo)
\n
will (intentionally) show up as the replacement character.
pub(crate) fn font_impl_and_glyph_info( &mut self, c: char, ) -> (Option<&FontImpl>, GlyphInfo)
pub(crate) fn ascent(&self) -> f32
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> 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
Mutably borrows from an owned value. Read more