cranpose_text/shaping_span.rs
1use std::ops::Range;
2
3use crate::{font_family_resolver::FontRequest, font_feature::FontFeature};
4
5/// A stretch of a paragraph with one font, size and set of shaping settings:
6/// a style span of the text. Spans that differ only in what does not change
7/// shaping, such as color, are one span, since a ligature such as Arabic
8/// lam-alef forms only inside one span.
9#[derive(Clone, Debug)]
10pub struct ShapingSpan<'a> {
11 /// The byte range in the text.
12 pub range: Range<usize>,
13 /// The family, weight and style. The weight and style also set the axes
14 /// of a variable font read without a declaration.
15 pub font: FontRequest<'a>,
16 /// The font size in pixels.
17 pub size: f32,
18 /// The OpenType features to turn on or off.
19 pub features: &'a [FontFeature],
20 /// A BCP 47 language tag such as `ja` or `sr-Latn`, which picks the
21 /// font's language-specific forms.
22 pub language: Option<&'a str>,
23 /// Extra space after each character in pixels: Compose's
24 /// `letterSpacing`; `None` takes the font's default tracking from its
25 /// `trak` table, as Apple's system fonts space their letters by size.
26 /// Scripts whose letters join take none, as on Android.
27 pub letter_spacing: Option<f32>,
28 /// How far above the line's baseline the span's baseline sits, in
29 /// pixels: Compose's `baselineShift` times the span's ascent.
30 pub baseline_shift: f32,
31}