pub struct TextStyle {
pub font_family: Option<String>,
pub font_size: f32,
pub color: Rgba,
pub line_height: f32,
pub align: TextAlign,
pub max_width: f32,
pub position: Vec2,
pub anchor: Vec2,
pub outline: Option<TextOutline>,
pub background: Option<TextBackground>,
}Expand description
How text looks and where it lies: a caption track’s cues, or a text
crate::Generator.
Sizes are resolution-independent: the font size is a fraction of the
canvas height, the wrapping width a fraction of the canvas width, and the
outline and background padding fractions of the font size. The engine
draws with the fonts its host registered: those of font_family first,
then the rest in their fallback order.
Fields§
§font_family: Option<String>The family the text draws in, as the font’s own name table gives it
(typographic family, else family), matched without regard to ASCII
case. Glyphs its fonts lack, and a family no registered font has,
draw from the other fonts in fallback order. None draws from the
fallback order alone. Non-empty, at most MAX_FONT_FAMILY_BYTES
bytes.
font_size: f32Font size as a fraction of the canvas height: positive, at most
crate::MAX_CAPTION_FONT_SIZE on a caption track and
MAX_TEXT_GENERATOR_FONT_SIZE in a text generator.
color: RgbaText color.
line_height: f32Baseline-to-baseline distance in font sizes, in [0.5, 3].
align: TextAlignHow lines align within the text.
max_width: f32Width text wraps at, as a fraction of the canvas width, in (0, 1].
position: Vec2Where on the canvas the text’s anchor lies, (0, 0) top-left to
(1, 1) bottom-right.
anchor: Vec2The point of the text, background included, placed at
position: (0.5, 1) is its bottom centre.
outline: Option<TextOutline>A band around the glyphs.
background: Option<TextBackground>A box behind each line.