pub struct Metrics {
pub role: TextStyle,
pub leading: f32,
pub weight: FontWeight,
pub scale: f32,
}Expand description
One role as it is actually set: a rung on the ladder, the leading it carries, and the weight it is set in.
Fields§
§role: TextStyle§leading: f32Line height as a multiple of the painted size, so leading follows the
type wherever set_base_text_size puts it.
weight: FontWeightThe ladder carries one bold cell, so a set needing several heading weights names its own here rather than reading it off the role.
scale: f32A factor over the painted ladder, for one surface sized apart from the rest — a document the reader has zoomed. 1.0 is the ladder itself.
Implementations§
Source§impl Metrics
impl Metrics
pub const fn new(role: TextStyle, leading: f32, weight: FontWeight) -> Self
Sourcepub const fn scaled(self, scale: f32) -> Self
pub const fn scaled(self, scale: f32) -> Self
The same metrics at scale times the ladder. Replaces rather than
compounds, so a slider handing over an absolute factor cannot drift.
pub fn size(self) -> f32
pub fn line_height(self) -> f32
Trait Implementations§
impl Copy for Metrics
Source§impl From<TextStyle> for Metrics
impl From<TextStyle> for Metrics
Source§fn from(role: TextStyle) -> Self
fn from(role: TextStyle) -> Self
The ladder’s own setting for a role: its measured leading and weight.
A set that wants prose leading names its own through Metrics::new.
impl StructuralPartialEq for Metrics
Auto Trait Implementations§
impl Freeze for Metrics
impl RefUnwindSafe for Metrics
impl Send for Metrics
impl Sync for Metrics
impl Unpin for Metrics
impl UnsafeUnpin for Metrics
impl UnwindSafe for Metrics
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> 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 more