Skip to main content

TextScaler

Enum TextScaler 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Linear

Dart’s _LinearTextScaler.

Fields

§text_scale_factor: f64

The estimated number of font pixels for each logical pixel.

§

Clamped

Dart’s _ClampedTextScaler.

Fields

§scaler: Box<TextScaler>

The scaler whose output is clamped.

§min_scale: f64

Lower bound on the scale factor.

§max_scale: f64

Upper bound on the scale factor.

Implementations§

Source§

impl TextScaler

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> TextScaler

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextScaler

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for TextScaler

Dart’s TextScaler.toString, which Debug already renders.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TextScaler

Source§

fn eq(&self, other: &TextScaler) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TextScaler

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,