pub struct TextStyle {Show 17 fields
pub family: String,
pub fallback_families: Vec<String>,
pub font_size: f32,
pub weight: Weight,
pub stretch: Stretch,
pub style: Style,
pub color: [u8; 4],
pub letter_spacing: f32,
pub word_spacing: f32,
pub line_height: LineHeight,
pub decorations: TextDecorations,
pub extra_features: Vec<OpenTypeFeature>,
pub variable_axes: Vec<VariableAxis>,
pub synthesize_styles: bool,
pub render_mode: RenderMode,
pub outline_rendering: bool,
pub material_effect_id: u32,
}Expand description
Complete text styling for a span of text.
Fields§
§family: StringFont family name (primary).
fallback_families: Vec<String>Fallback font family names.
font_size: f32Font size in pixels.
weight: WeightFont weight (100-900).
stretch: StretchFont stretch.
style: StyleFont style (normal, italic, oblique).
color: [u8; 4]Text color as RGBA.
letter_spacing: f32Letter spacing in pixels (added to each glyph advance).
word_spacing: f32Word spacing in pixels (added to space glyph advance).
line_height: LineHeightLine height mode.
decorations: TextDecorationsText decorations.
extra_features: Vec<OpenTypeFeature>OpenType features to enable (after liga/kern/calt which are always on).
variable_axes: Vec<VariableAxis>Variable font axis settings.
synthesize_styles: boolWhether to synthesize bold/italic when the variant font is missing.
render_mode: RenderModeRendering mode for glyph rasterization.
outline_rendering: boolWhether to render glyphs as resolution-independent vector outlines.
material_effect_id: u32Unique identifier for dynamic material and visual rendering effects.
Implementations§
Source§impl TextStyle
impl TextStyle
Sourcepub fn new(family: &str, font_size: f32) -> Self
pub fn new(family: &str, font_size: f32) -> Self
Create a new text style with the given family and size.
Sourcepub fn with_weight(self, weight: u16) -> Self
pub fn with_weight(self, weight: u16) -> Self
Set the font weight.
Sourcepub fn with_letter_spacing(self, spacing: f32) -> Self
pub fn with_letter_spacing(self, spacing: f32) -> Self
Set letter spacing.
Sourcepub fn with_word_spacing(self, spacing: f32) -> Self
pub fn with_word_spacing(self, spacing: f32) -> Self
Set word spacing.
Sourcepub fn with_line_height_multiple(self, multiple: f32) -> Self
pub fn with_line_height_multiple(self, multiple: f32) -> Self
Set line height as a multiple of font size.
Sourcepub fn with_line_height_fixed(self, pixels: f32) -> Self
pub fn with_line_height_fixed(self, pixels: f32) -> Self
Set a fixed line height in pixels.
Sourcepub fn with_feature(self, feature: OpenTypeFeature) -> Self
pub fn with_feature(self, feature: OpenTypeFeature) -> Self
Add an OpenType feature.
Sourcepub fn with_axis(self, axis: VariableAxis) -> Self
pub fn with_axis(self, axis: VariableAxis) -> Self
Add a variable font axis.
Sourcepub fn with_underline(self) -> Self
pub fn with_underline(self) -> Self
Enable underline decoration.
Sourcepub fn with_strikethrough(self) -> Self
pub fn with_strikethrough(self) -> Self
Enable strikethrough decoration.
Sourcepub fn with_outline_rendering(self, enabled: bool) -> Self
pub fn with_outline_rendering(self, enabled: bool) -> Self
Set whether outline vector path rendering is enabled.
Sourcepub fn with_material_effect(self, effect_id: u32) -> Self
pub fn with_material_effect(self, effect_id: u32) -> Self
Set the material effect ID for dynamic visual rendering.