pub struct TextRasterRequest {Show 20 fields
pub text: String,
pub font_size: f32,
pub max_width: f32,
pub line_height: f32,
pub align: TextAlign,
pub fill: TextFill,
pub emoji_policy: EmojiPolicy,
pub content_version: u64,
pub strokes: Vec<TextStroke>,
pub background: Option<TextBackground>,
pub split_background: bool,
pub font_family: Option<String>,
pub letter_spacing: f32,
pub font_weight: u16,
pub clamp: Option<TextClamp>,
pub spans: Vec<TextSpan>,
pub advance_headroom: f32,
pub animator_grouping: ClusterGrouping,
pub highlight: Option<TextHighlightRequest>,
pub animator_pivot: [f32; 2],
}Expand description
One text layout request.
Fields§
§text: StringUTF-8 text shaped by the selected font fallback stack.
font_size: f32Logical font size in pixels.
max_width: f32Maximum layout width. Non-positive values disable wrapping.
line_height: f32Baseline-to-baseline distance in font sizes. The em box (0.8 above the baseline, 0.2 below) is centered in lines taller than an em.
align: TextAlignPer-line horizontal alignment.
fill: TextFillGlyph paint. Color glyphs keep their own colors except for text-color parts, which use
TextFill::foreground, whose alpha is also their opacity.
emoji_policy: EmojiPolicyWhether color glyphs are drawn in color, and which fonts emoji take.
content_version: u64Caller-managed version. Change it whenever content/style/font inputs change.
strokes: Vec<TextStroke>Outlines, innermost first, each drawn behind the previous. At most 8, reaching at most 64 pixels together.
background: Option<TextBackground>A box behind each line, drawn behind the strokes.
split_background: boolDraws the background into TextRasterResult::background instead of under the glyphs,
so a caller can draw something (a shadow) between them.
font_family: Option<String>Preferred family, matched against any font_family_names entry after NFC and
lowercasing; the fallback stack fills missing glyphs. An unknown family keeps the fallback
order and is listed by TextRasterizer::unmatched_families.
letter_spacing: f32Space after each grapheme cluster, like CSS letter-spacing, in [-0.5, 1] font sizes.
Not applied after a line’s last cluster or within cursive scripts. Non-zero values disable
optional ligatures.
font_weight: u16Weight in [1, 1000], matched per CSS Fonts 4 and applied to a variable face’s wght
axis. Faces are never synthetically emboldened.
clamp: Option<TextClamp>Where lines are cut, as CSS line-clamp cuts them; None keeps every line.
spans: Vec<TextSpan>Byte ranges of text drawn with their own values, as CSS inline boxes: in order, without
overlap, on character boundaries, at most MAX_TEXT_SPANS. Text outside every span
takes the request’s values; an empty list draws as the request alone.
advance_headroom: f32The most an animation can widen a cluster’s advance (ClusterState::advance_scale),
in [1, MAX_CLUSTER_SCALE]: lines wrap at max_width over it and align in max_width, so
a line pushed apart that far still fits. 1 wraps at max_width.
animator_grouping: ClusterGroupingThe units whose clusters an animated raster scales and turns about one pivot.
highlight: Option<TextHighlightRequest>A box over the run being said, drawn with the background boxes (and into
TextRasterResult::background when split).
animator_pivot: [f32; 2]Where in each group’s box (its clusters’ advances by their em boxes) the pivot lies,
fractions from its left and top in [0, 1]; [0.5, 0.5] is its centre.
Implementations§
Source§impl TextRasterRequest
impl TextRasterRequest
Sourcepub fn wrap_width(&self) -> f32
pub fn wrap_width(&self) -> f32
The width lines break at: max_width over Self::advance_headroom, non-positive for
none.
Source§impl TextRasterRequest
impl TextRasterRequest
Sourcepub fn decoration_margin(&self) -> [u32; 2]
pub fn decoration_margin(&self) -> [u32; 2]
Whole pixels the strokes or background reach past the layout box, horizontally and
vertically. The texture margin (TextTexture::layout_x) adds room for ink overflow to
this.