Skip to main content

StrutStyle

Struct StrutStyle 

Source
pub struct StrutStyle {
    pub font_family: Option<String>,
    pub font_size: Option<f64>,
    pub height: Option<f64>,
    pub leading_distribution: Option<TextLeadingDistribution>,
    pub font_weight: Option<FontWeight>,
    pub font_style: Option<FontStyle>,
    pub leading: Option<f64>,
    pub force_strut_height: Option<bool>,
    pub debug_label: Option<String>,
    /* private fields */
}
Expand description

Defines the strut, which sets the minimum height a line can be relative to the baseline.

Strut applies to all lines in the paragraph. Strut is a feature that allows minimum line heights to be set. The effect is as if a zero width space was included at the beginning of each line in the paragraph. This imaginary space is “shaped” according the properties defined in this class.

No lines may be shorter than the strut. The ascent and descent of the strut are calculated, and any laid out text that has a shorter ascent or descent than the strut’s ascent or descent will take the ascent and descent of the strut. Text with ascents or descents larger than the strut’s ascent or descent will layout as normal and extend past the strut.

Strut is defined independently from any text content or TextStyles.

Fields§

§font_family: Option<String>

The name of the font to use when calculating the strut (e.g., Roboto). If the font is defined in a package, this is prefixed with packages/package_name/.

The value provided in font_family acts as the preferred family, followed in order by font_family_fallback_list.

§font_size: Option<f64>

The size of text (in logical pixels) to use when obtaining metrics from the font.

The default is 14 logical pixels.

§height: Option<f64>

The minimum height of the strut, as a multiple of font_size.

When None, the strut’s height is the font-defined ascent plus descent.

§leading_distribution: Option<TextLeadingDistribution>

How the vertical space added by the height multiplier should be distributed over and under the strut.

Defaults to None, which defers to the paragraph’s textHeightBehavior’s leading distribution; TextLeadingDistribution::Even distributes it evenly.

§font_weight: Option<FontWeight>

The typeface thickness to use when calculating the strut (e.g., bold).

The default is w400.

§font_style: Option<FontStyle>

The typeface variant to use when calculating the strut (e.g., italics).

The default is upright.

§leading: Option<f64>

The additional leading to apply to the strut as a multiple of font_size, independent of height and leading_distribution.

Half of the leading is added above the text and half below. Defaults to None, which adds none.

§force_strut_height: Option<bool>

Whether the strut height should be forced.

When true, all lines are laid out with the height of the strut, and line- and run-specific metrics are ignored.

The default is false.

§debug_label: Option<String>

A human-readable description of this strut style.

Maintained only in debug builds. Not considered by == or compare_to.

Implementations§

Source§

impl StrutStyle

Source

pub const DISABLED: StrutStyle

A StrutStyle that will have no impact on the text layout.

Equivalent to having no strut at all. All lines will be laid out according to the properties defined in TextStyle.

Source

pub fn new() -> StrutStyle

Creates a strut style.

Chain setters for the fields Dart’s constructor takes as named arguments: StrutStyle::new().font_size(14.0).

Source

pub fn from_text_style(text_style: &TextStyle) -> FromTextStyle<'_>

Builds a StrutStyle that contains values of the equivalent properties in text_style.

Chain optional Dart named arguments, then FromTextStyle::build. They override the text style’s values.

Source

pub fn font_family(self, font_family: impl Into<String>) -> StrutStyle

The name of the font to use when calculating the strut.

Source

pub fn font_family_fallback( self, font_family_fallback: Vec<String>, ) -> StrutStyle

The ordered list of font families to fall back on when a higher priority font family cannot be found.

Source

pub fn package(self, package: impl Into<String>) -> StrutStyle

The package argument must be provided if the font family is defined in a package. It is combined with font_family to set that property.

Source

pub fn font_size(self, font_size: f64) -> StrutStyle

The size of text (in logical pixels) to use when obtaining metrics from the font.

Source

pub fn height(self, height: f64) -> StrutStyle

The minimum height of the strut, as a multiple of font_size.

Source

pub fn leading_distribution( self, leading_distribution: TextLeadingDistribution, ) -> StrutStyle

How the vertical space added by the height multiplier should be distributed over and under the strut.

Source

pub fn font_weight(self, font_weight: FontWeight) -> StrutStyle

The typeface thickness to use when calculating the strut.

Source

pub fn font_style(self, font_style: FontStyle) -> StrutStyle

The typeface variant to use when calculating the strut.

Source

pub fn leading(self, leading: f64) -> StrutStyle

The additional leading to apply to the strut as a multiple of font_size.

Source

pub fn force_strut_height(self, force_strut_height: bool) -> StrutStyle

Whether the strut height should be forced.

Source

pub fn debug_label(self, debug_label: impl Into<String>) -> StrutStyle

A human-readable description of this strut style.

Source

pub fn font_family_fallback_list(&self) -> Option<Vec<String>>

The ordered list of font families to fall back on, with the package prefix applied.

Source

pub fn compare_to(&self, other: &StrutStyle) -> RenderComparison

Describe the difference between this style and another, in terms of how much damage it will make to the rendering.

Source

pub fn inherit_from_text_style(&self, other: Option<&TextStyle>) -> StrutStyle

Returns a new strut style that inherits its None values from corresponding properties in other.

If other is None, returns this strut style unchanged.

Source

pub fn merge(&self, other: Option<&StrutStyle>) -> StrutStyle

Returns a new strut style that is a combination of this style and other.

All None values of other are replaced with members from this style.

Source

pub fn get_paragraph_strut_style(&self, text_scaler: &TextScaler) -> StrutStyle

This style as dart:ui’s, with the font size scaled by text_scaler: the conversion Dart’s TextStyle.getParagraphStyle makes for a paragraph’s strut.

Source§

impl StrutStyle

Source

pub fn debug_fill_properties_with_prefix( &self, properties: &mut DiagnosticPropertiesBuilder, prefix: &str, )

Dart’s debugFillProperties(properties, {String prefix = ''}).

Trait Implementations§

Source§

impl Clone for StrutStyle

Source§

fn clone(&self) -> StrutStyle

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 StrutStyle

Source§

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

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

impl Default for StrutStyle

Source§

fn default() -> StrutStyle

Returns the “default value” for a type. Read more
Source§

impl Diagnosticable for StrutStyle

Source§

fn to_string_short(&self) -> String

A brief description of this object, usually just the type and the hash.
Source§

fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)

Add additional properties associated with the node.
Source§

fn type_name(&self) -> &'static str

Dart’s Object.runtimeType as diagnostics print it: the last segment of the Rust type path, without generic arguments.
Source§

fn identity_hash(&self) -> u64

Dart’s Object.hashCode as diagnostics print it: the object’s address.
Source§

fn to_diagnostics_node(&self) -> DiagnosticableNode

Returns a debug representation of the object used by debugging tools and by DiagnosticsNode::to_string_deep.
Source§

fn to_diagnostics_node_with( &self, name: Option<String>, style: Option<DiagnosticsTreeStyle>, ) -> DiagnosticableNode

Dart toDiagnosticsNode(name:, style:).
Source§

fn to_string(&self) -> String

Dart’s toString: a single-line description with properties and no children. Read more
Source§

fn to_string_at(&self, min_level: DiagnosticLevel) -> String

Dart’s toString(minLevel:).
Source§

impl Display for StrutStyle

Source§

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

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

impl PartialEq for StrutStyle

Source§

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

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

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Forget for StrutStyle

§

impl Freeze for StrutStyle

§

impl Move for StrutStyle

§

impl RefUnwindSafe for StrutStyle

§

impl Send for StrutStyle
where RawVecInner: Send,

§

impl Sync for StrutStyle
where RawVecInner: Sync,

§

impl Unpin for StrutStyle
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for StrutStyle

§

impl UnwindSafe for StrutStyle
where RawVecInner: UnwindSafe,

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 for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
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> ToSmolStr for T
where T: Display + ?Sized,

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,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more