zng_ext_font/unit.rs
1use zng_layout::unit::Length;
2
3/// Text font size.
4///
5/// The [`Default`] value is the *root* font size, usually the one set in the window widget.
6///
7/// [`Default`]: Length::Default
8pub type FontSize = Length;
9
10/// Text line height.
11///
12/// The [`Default`] value is computed from the font metrics, `ascent - descent + line_gap`, this is
13/// usually similar to `1.2.em()`. Relative values are computed from the default value, so `200.pct()` is double
14/// the default line height.
15///
16/// [`Default`]: Length::Default
17pub type LineHeight = Length;
18
19/// Extra spacing added in between text letters.
20///
21/// Letter spacing is computed using the font data, this unit represents
22/// extra space added to the computed spacing.
23///
24/// A "letter" is a character glyph cluster, e.g.: `a`, `â`, `1`, `-`, `漢`.
25///
26/// The [`Default`] value signals that letter spacing can be tweaked when text *justification* is enabled, all other
27/// values disable automatic adjustments for justification. Relative values are computed from the length of the space `' '` character.
28///
29/// [`Default`]: Length::Default
30pub type LetterSpacing = Length;
31
32/// Extra spacing added to the Unicode `U+0020 SPACE` character.
33///
34/// Word spacing is done using the space character "advance" as defined in the font,
35/// this unit represents extra spacing added to that default spacing.
36///
37/// A "word" is the sequence of characters in-between space characters. This extra
38/// spacing is applied per space character not per word, if there are three spaces between words
39/// the extra spacing is applied thrice. Usually the number of spaces between words is collapsed to one,
40/// see [`WhiteSpace`](crate::WhiteSpace).
41///
42/// The [`Default`] value signals that word spacing can be tweaked when text *justification* is enabled, all other
43/// values disable automatic adjustments for justification. Relative values are computed from the length of the space `' '` character,
44/// so a word spacing of `100.pct()` visually adds *another* space in between words.
45///
46/// [`Default`]: Length::Default
47pub type WordSpacing = Length;
48
49/// Extra spacing in-between text lines.
50///
51/// The [`Default`] value is zero. Relative values are calculated from the [`LineHeight`], so `50.pct()` is half
52/// the computed line height.
53///
54/// [`Default`]: Length::Default
55pub type LineSpacing = Length;
56
57/// Extra spacing in-between paragraphs.
58///
59/// The initial paragraph space is `line_height + line_spacing * 2`, this extra spacing is added to that.
60///
61/// A "paragraph" is a sequence of lines in-between wgt lines (empty or spaces only). This extra space is applied per wgt line
62/// not per paragraph, if there are three wgt lines between paragraphs the extra spacing is applied trice.
63///
64/// The [`Default`] value is zero.
65///
66/// [`Default`]: Length::Default
67pub type ParagraphSpacing = Length;
68
69/// Length of a `TAB` space.
70///
71/// Relative lengths are computed from the normal space character "advance" plus the [`WordSpacing`].
72/// So a `200%` length is 2 spaces.
73///
74/// The [`Default`] value is `400.pct()`, 4 spaces.
75///
76/// [`Default`]: Length::Default
77pub type TabLength = Length;
78
79/// Height of the text underline decoration.
80///
81/// Relative lengths are computed from `1.em()`, with a minimum of one pixel.
82///
83/// The [`Default`] value is defined by the font.
84///
85/// [`Default`]: Length::Default
86pub type UnderlineThickness = Length;
87
88/// Height of the text overline or strikethrough decoration.
89///
90/// Relative lengths are computed from `1.em()`, with a minimum of one pixel.
91///
92/// The [`Default`] value is `10.pct()`.
93pub type TextLineThickness = Length;