1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//! Classification of whitespace characters.
//!
//! Unicode has many characters for which `char::is_whitespace` (the White_Space property)
//! is true, but CSS line layout must not treat them all alike. There are two axes.
//!
//! 1. **Whether it collapses** - CSS Text 3 section 4.1 makes only space (U+0020), tab
//! (U+0009) and the segment break (U+000A) collapsible; every other Zs (` `, thin
//! space and so on) is an ordinary, non-collapsing character.
//! Blink's `Character::IsCollapsibleSpace` (space/LF/tab/CR) and Gecko's
//! `nsTextFrameUtils::IsSpaceOrTab` (space/tab, with newlines handled separately) cover
//! the same range. A non-collapsing character is not a word separator for line layout;
//! it is passed to shaping and drawn at the font's own advance (three ` ` are three spaces wide).
//!
//! 2. **Whether a break is allowed there** - decided by the UAX #14 line breaking class.
//! ` ` (GL) and figure space (GL) forbid a break either side, while thin space and
//! friends (BA) and ZWSP (ZW) allow one immediately after.
//!
//! Advances survive even in a font without those glyphs, because the shaper (harfrust)
//! implements HarfBuzz's space fallback (`_hb_ot_shape_fallback_spaces`): with no matching
//! glyph it substitutes the space glyph and sets the prescribed advance, such as `em/2` or
//! `em/5`. There is nothing for us to supply.
//!
//! A known simplification: U+000B, U+0085, U+2028 and U+2029 are really forced line breaks,
//! but to avoid .notdef in a font lacking those glyphs they are treated here as collapsible
//! whitespace (that is, word separators), preserving the existing behaviour.
/// A zero-width break opportunity (the ZW class of UAX #14). Also what `<wbr>` amounts to.
pub const ZERO_WIDTH_SPACE: char = '\u{200b}';
/// Whether the character is collapsible whitespace (CSS Text 3's "collapsible white space").
///
/// Under `white-space: normal` a run of these becomes one inter-word space, and is dropped
/// at the start and end of a line. A whitespace character not listed here (` `, say) is an ordinary character.
pub
/// Whether a string consists only of collapsible whitespace (that is, whether no box needs
/// to be created for it). Unlike `str::trim`, a string of only ` ` is not "whitespace
/// only" (it has content).
pub
/// Whether a break is forbidden either side of the whitespace (the GL and WJ classes of UAX #14).
///
/// ` ` exists precisely for this, so it takes priority over `word-break: break-all`
/// (browsers do not break "10 kg" either).
pub
/// Whether a break is allowed immediately after the whitespace (the BA class of UAX #14).
///
/// It covers the typographic spaces that have a width (thin space and so on). ZWSP (ZW) does
/// not appear here: it is folded into a break-opportunity flag rather than emitting a glyph,
/// so `inline::flatten_spans` removes it at the character stage.
/// U+3000 IDEOGRAPHIC SPACE is not listed either, since `inline::is_cjk` already treats it
/// as a break opportunity (and it should be subject to `word-break: keep-all`).
pub