pub struct FontMetrics {
pub units_per_em: u16,
pub advance: f32,
pub line_height: f32,
pub descent: f32,
}
Expand description
Metrics for rendering a monospaced font.
Fields§
§units_per_em: u16
The number of font units per Em. To scale the font to a specific size, the font metrics are scaled relative to this unit. For example, the line height in pixels for a font at size 12px would be:
line_height / units_per_em * 12
advance: f32
The amount of horizontal advance between characters.
line_height: f32
Height between the baselines of two lines of text.
descent: f32
Space below the text baseline. This is the distance between the text baseline of a line and the top of the next line.
Implementations§
Source§impl FontMetrics
impl FontMetrics
Sourcepub const DEFAULT: FontMetrics
pub const DEFAULT: FontMetrics
Font metrics that should work for fonts that are similar to, e.g., Liberation mono, Consolas or Menlo. If this is not accurate, it will be noticeable as overlap or gaps between box drawing characters.
FontMetrics {
units_per_em: 1000,
advance: 600.0,
line_height: 1200.0,
descent: 300.0,
}
Trait Implementations§
Source§impl Clone for FontMetrics
impl Clone for FontMetrics
Source§fn clone(&self) -> FontMetrics
fn clone(&self) -> FontMetrics
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for FontMetrics
impl Debug for FontMetrics
Source§impl Default for FontMetrics
impl Default for FontMetrics
impl Copy for FontMetrics
Auto Trait Implementations§
impl Freeze for FontMetrics
impl RefUnwindSafe for FontMetrics
impl Send for FontMetrics
impl Sync for FontMetrics
impl Unpin for FontMetrics
impl UnwindSafe for FontMetrics
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> ResetDiscriminant<T> for Twhere
T: Copy,
impl<T> ResetDiscriminant<T> for Twhere
T: Copy,
Source§fn discriminant(&self) -> T
fn discriminant(&self) -> T
Value based on which equality for the reset will be determined.