pub struct TextStyle {
pub font_size: f32,
pub line_height: f32,
pub font_family: String,
pub font_weight: String,
pub font_style: String,
pub letter_spacing: String,
pub text_indent: f32,
}Expand description
Text styling configuration
Defines the visual appearance of text content in the document, including font properties, sizing, and spacing.
Fields§
§font_size: f32The base font size (default: 1.0, unit: rem)
Relative to the root element, providing consistent sizing across different viewing contexts.
line_height: f32The line height (default: 1.6, unit: em)
Controls the vertical spacing between lines of text. Values greater than 1.0 increase spacing, while values less than 1.0 compress the text.
font_family: StringThe font family stack (default: “-apple-system, Roboto, sans-serif”)
A comma-separated list of font families to use, with fallback fonts specified for compatibility.
font_weight: StringThe font weight (default: “normal”)
Controls the thickness of the font strokes. Common values include “normal” and “bold”.
font_style: StringThe font style (default: “normal”)
Controls whether the font is normal, italic, or oblique. Common values include “normal” and “italic”.
letter_spacing: StringThe letter spacing (default: “normal”)
Controls the space between characters. Common values include “normal” or specific lengths like “0.05em”.
text_indent: f32The text indent for paragraphs (default: 2.0, unit: em)
Controls the indentation of the first line of paragraphs. A value of 2.0 means the first line is indented by 2 ems.
Implementations§
Source§impl TextStyle
impl TextStyle
Sourcepub fn with_font_size(&mut self, font_size: f32) -> &mut Self
pub fn with_font_size(&mut self, font_size: f32) -> &mut Self
Sets the font size
Sourcepub fn with_line_height(&mut self, line_height: f32) -> &mut Self
pub fn with_line_height(&mut self, line_height: f32) -> &mut Self
Sets the line height
Sourcepub fn with_font_family(&mut self, font_family: &str) -> &mut Self
pub fn with_font_family(&mut self, font_family: &str) -> &mut Self
Sets the font family
Sourcepub fn with_font_weight(&mut self, font_weight: &str) -> &mut Self
pub fn with_font_weight(&mut self, font_weight: &str) -> &mut Self
Sets the font weight
Sourcepub fn with_font_style(&mut self, font_style: &str) -> &mut Self
pub fn with_font_style(&mut self, font_style: &str) -> &mut Self
Sets the font style
Sourcepub fn with_letter_spacing(&mut self, letter_spacing: &str) -> &mut Self
pub fn with_letter_spacing(&mut self, letter_spacing: &str) -> &mut Self
Sets the letter spacing
Sourcepub fn with_text_indent(&mut self, text_indent: f32) -> &mut Self
pub fn with_text_indent(&mut self, text_indent: f32) -> &mut Self
Sets the text indent