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
impl StrutStyle
Sourcepub const DISABLED: StrutStyle
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.
Sourcepub fn new() -> StrutStyle
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).
Sourcepub fn from_text_style(text_style: &TextStyle) -> FromTextStyle<'_>
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.
Sourcepub fn font_family(self, font_family: impl Into<String>) -> StrutStyle
pub fn font_family(self, font_family: impl Into<String>) -> StrutStyle
The name of the font to use when calculating the strut.
Sourcepub fn font_family_fallback(
self,
font_family_fallback: Vec<String>,
) -> StrutStyle
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.
Sourcepub fn package(self, package: impl Into<String>) -> StrutStyle
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.
Sourcepub fn font_size(self, font_size: f64) -> StrutStyle
pub fn font_size(self, font_size: f64) -> StrutStyle
The size of text (in logical pixels) to use when obtaining metrics from the font.
Sourcepub fn height(self, height: f64) -> StrutStyle
pub fn height(self, height: f64) -> StrutStyle
The minimum height of the strut, as a multiple of font_size.
Sourcepub fn leading_distribution(
self,
leading_distribution: TextLeadingDistribution,
) -> StrutStyle
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.
Sourcepub fn font_weight(self, font_weight: FontWeight) -> StrutStyle
pub fn font_weight(self, font_weight: FontWeight) -> StrutStyle
The typeface thickness to use when calculating the strut.
Sourcepub fn font_style(self, font_style: FontStyle) -> StrutStyle
pub fn font_style(self, font_style: FontStyle) -> StrutStyle
The typeface variant to use when calculating the strut.
Sourcepub fn leading(self, leading: f64) -> StrutStyle
pub fn leading(self, leading: f64) -> StrutStyle
The additional leading to apply to the strut as a multiple of
font_size.
Sourcepub fn force_strut_height(self, force_strut_height: bool) -> StrutStyle
pub fn force_strut_height(self, force_strut_height: bool) -> StrutStyle
Whether the strut height should be forced.
Sourcepub fn debug_label(self, debug_label: impl Into<String>) -> StrutStyle
pub fn debug_label(self, debug_label: impl Into<String>) -> StrutStyle
A human-readable description of this strut style.
Sourcepub fn font_family_fallback_list(&self) -> Option<Vec<String>>
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.
Sourcepub fn compare_to(&self, other: &StrutStyle) -> RenderComparison
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.
Sourcepub fn inherit_from_text_style(&self, other: Option<&TextStyle>) -> StrutStyle
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.
Sourcepub fn merge(&self, other: Option<&StrutStyle>) -> StrutStyle
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.
Sourcepub fn get_paragraph_strut_style(&self, text_scaler: &TextScaler) -> StrutStyle
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
impl StrutStyle
Sourcepub fn debug_fill_properties_with_prefix(
&self,
properties: &mut DiagnosticPropertiesBuilder,
prefix: &str,
)
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
impl Clone for StrutStyle
Source§fn clone(&self) -> StrutStyle
fn clone(&self) -> StrutStyle
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 StrutStyle
impl Debug for StrutStyle
Source§impl Default for StrutStyle
impl Default for StrutStyle
Source§fn default() -> StrutStyle
fn default() -> StrutStyle
Source§impl Diagnosticable for StrutStyle
impl Diagnosticable for StrutStyle
Source§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
Source§fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Object.runtimeType as diagnostics print it: the last segment of
the Rust type path, without generic arguments.Source§fn identity_hash(&self) -> u64
fn identity_hash(&self) -> u64
Object.hashCode as diagnostics print it: the object’s address.Source§fn to_diagnostics_node(&self) -> DiagnosticableNode
fn to_diagnostics_node(&self) -> DiagnosticableNode
DiagnosticsNode::to_string_deep.Source§fn to_diagnostics_node_with(
&self,
name: Option<String>,
style: Option<DiagnosticsTreeStyle>,
) -> DiagnosticableNode
fn to_diagnostics_node_with( &self, name: Option<String>, style: Option<DiagnosticsTreeStyle>, ) -> DiagnosticableNode
toDiagnosticsNode(name:, style:).Source§fn to_string(&self) -> String
fn to_string(&self) -> String
toString: a single-line description with properties and no
children. Read moreSource§fn to_string_at(&self, min_level: DiagnosticLevel) -> String
fn to_string_at(&self, min_level: DiagnosticLevel) -> String
toString(minLevel:).Source§impl Display for StrutStyle
impl Display for StrutStyle
Auto Trait Implementations§
impl Forget for StrutStyle
impl Freeze for StrutStyle
impl Move for StrutStyle
impl RefUnwindSafe for StrutStyle
impl Send for StrutStylewhere
RawVecInner: Send,
impl Sync for StrutStylewhere
RawVecInner: Sync,
impl Unpin for StrutStyle
impl UnsafeUnpin for StrutStylewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
impl UnwindSafe for StrutStylewhere
RawVecInner: UnwindSafe,
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.