Skip to main content

TextRunStyle

TextRunStyle is the low-level style object behind RichTextRun.

Most app authors do not need to construct it directly because builder methods like .size(...), .color(...), and .weight(...) on RichTextRun are easier to read. You reach for TextRunStyle directly when you want to prepare or reuse a text style value as data.

Example

use fission::core::ui::{RichTextRun, TextFontStyle, TextRunStyle};

let run = RichTextRun {
text: "Important".into(),
style: TextRunStyle {
font_size: Some(16.0),
color: Some(view.env.theme.tokens.colors.primary),
underline: false,
font_family: None,
locale: None,
font_weight: Some(700),
font_style: TextFontStyle::Normal,
line_height: None,
letter_spacing: None,
text_scale: None,
background_color: None,
},
semantics_label: None,
semantics_identifier: None,
spell_out: None,
};

Field table

FieldTypeMeaningNotes / default behavior
font_sizeOption<f32>Font size in layout points.Falls back to theme body size when absent.
colorOption<IrColor>Text color override.Falls back to the theme's primary text color when absent.
underlineboolWhether the run is underlined.Defaults to false.
font_familyOption<String>Font family override.Defaults to None.
localeOption<String>Locale override used during shaping.Defaults to None.
font_weightOption<u16>Font weight override.Falls back to 400 when absent.
font_styleTextFontStyleNormal or italic posture.Defaults to Normal.
line_heightOption<f32>Explicit line height.Defaults to None.
letter_spacingOption<f32>Additional letter spacing.Defaults to None.
text_scaleOption<f32>Scale multiplier for the run.Defaults to None, which behaves like 1.0.
background_colorOption<IrColor>Background color behind the run.Defaults to None.

Specific advice

TextRunStyle is a fully specified run style, not the cascading span style used inside nested rich-text trees. If you need inheritance-like behavior, build with rich-text spans instead of copying whole run styles around by hand.

RichTextRun, RichText, TextFontStyle, and Text.