#[non_exhaustive]pub enum TextScaler {
Linear {
text_scale_factor: f64,
},
Clamped {
scaler: Box<TextScaler>,
min_scale: f64,
max_scale: f64,
},
}Expand description
A class that describes how textual contents should be scaled for better readability.
The scale function computes the scaled font size given
the original unscaled font size specified by app developers.
Non-exhaustive: a later arm for SystemTextScaler (widgets) or a user
subclass.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Implementations§
Source§impl TextScaler
impl TextScaler
Sourcepub const NO_SCALING: TextScaler
pub const NO_SCALING: TextScaler
A TextScaler that doesn’t scale the input font size.
This is equivalent to TextScaler::linear(1.0), the
scale implementation always returns the input font size
as-is.
Sourcepub fn linear(text_scale_factor: f64) -> TextScaler
pub fn linear(text_scale_factor: f64) -> TextScaler
Creates a proportional TextScaler that scales the incoming font size
by multiplying it with the given text_scale_factor.
Sourcepub fn scale(&self, font_size: f64) -> f64
pub fn scale(&self, font_size: f64) -> f64
Computes the scaled font size (in logical pixels) with the given
unscaled font_size (in logical pixels).
The input font_size must be finite and non-negative.
Sourcepub fn text_scale_factor(&self) -> f64
pub fn text_scale_factor(&self) -> f64
The estimated number of font pixels for each logical pixel.
The value of this property is only an estimate, so it may not reflect
the exact text scaling strategy this TextScaler represents,
especially when this TextScaler is not linear. Consider using
scale instead.
Sourcepub fn clamp(&self, min_scale_factor: f64, max_scale_factor: f64) -> TextScaler
pub fn clamp(&self, min_scale_factor: f64, max_scale_factor: f64) -> TextScaler
Returns a new TextScaler that restricts the scaled font size to
within the range [min_scale_factor * font_size, max_scale_factor * font_size].
Trait Implementations§
Source§impl Clone for TextScaler
impl Clone for TextScaler
Source§fn clone(&self) -> TextScaler
fn clone(&self) -> TextScaler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TextScaler
impl Debug for TextScaler
Source§impl Display for TextScaler
Dart’s TextScaler.toString, which Debug already renders.
impl Display for TextScaler
Dart’s TextScaler.toString, which Debug already renders.