pub struct TextStyle {
pub font_size: f32,
pub paint: Paint,
pub shadow: Option<Shadow>,
pub weight: u16,
pub italic: bool,
pub align: TextAlign,
pub max_lines: Option<u16>,
pub ellipsis: bool,
pub line_height: Option<f32>,
pub letter_spacing: f32,
pub raster: GlyphRaster,
}Fields§
§font_size: f32§paint: Paint§shadow: Option<Shadow>§weight: u16OpenType weight axis: 400 is normal, 700 is bold. Selects the matching font face.
italic: bool§align: TextAlign§max_lines: Option<u16>Clamp the text to at most this many lines (None = unlimited). Lines beyond it are dropped.
ellipsis: boolWhen clamped by max_lines, replace the overflowing tail with an ellipsis (…).
line_height: Option<f32>Line height as a multiple of font_size (e.g. 1.5). None keeps the shaper’s natural line height, so the default renders byte-for-byte as before.
letter_spacing: f32Extra advance in logical pixels added after each glyph. 0.0 uses the font’s natural advances.
raster: GlyphRasterWhich grid the glyphs land on. See GlyphRaster.
Implementations§
Source§impl TextStyle
impl TextStyle
pub fn new(font_size: f32, paint: impl Into<Paint>) -> Self
pub fn with_weight(self, weight: u16) -> Self
Sourcepub fn with_size(self, font_size: f32) -> Self
pub fn with_size(self, font_size: f32) -> Self
Overrides the size a style was built at, so a style carrying theme-resolved weight and slant can be re-sized without being rebuilt from scratch (and losing them).
Sourcepub fn with_shadow(self, shadow: Shadow) -> Self
pub fn with_shadow(self, shadow: Shadow) -> Self
Drops a shadow behind the glyphs — what keeps text legible over an image the style knows nothing about.
pub fn with_italic(self, italic: bool) -> Self
pub fn with_align(self, align: TextAlign) -> Self
pub fn with_max_lines(self, max_lines: u16) -> Self
pub fn with_ellipsis(self, ellipsis: bool) -> Self
pub fn with_line_height(self, line_height: f32) -> Self
pub fn with_letter_spacing(self, letter_spacing: f32) -> Self
Sourcepub fn with_raster(self, raster: GlyphRaster) -> Self
pub fn with_raster(self, raster: GlyphRaster) -> Self
Puts the glyphs on whole pixels with coverage resolved to on or off. See GlyphRaster.