swash/text/cluster/
mod.rs

1/*!
2Script aware cluster segmentation.
3
4This module provides support for breaking text into clusters that are
5appropriate for shaping with a given script. For most scripts, clusters are
6equivalent to Unicode grapheme clusters. More complex scripts, however,
7may produce shaping clusters that contain multiple graphemes.
8*/
9
10mod char;
11#[allow(clippy::module_inception)]
12mod cluster;
13mod complex;
14mod info;
15mod myanmar;
16mod parse;
17mod simple;
18mod token;
19
20pub use self::{
21    char::{Char, ShapeClass},
22    cluster::{CharCluster, SourceRange, Status, MAX_CLUSTER_SIZE},
23    info::{CharInfo, ClusterInfo, Emoji, Whitespace},
24    parse::Parser,
25    token::Token,
26};
27
28use super::unicode_data;
29
30/// Boundary type of a character or cluster.
31#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
32#[repr(u8)]
33pub enum Boundary {
34    /// Not a boundary.
35    None = 0,
36    /// Start of a word.
37    Word = 1,
38    /// Potential line break.
39    Line = 2,
40    /// Mandatory line break.
41    Mandatory = 3,
42}
43
44impl Boundary {
45    pub(super) fn from_raw(raw: u16) -> Self {
46        match raw & 0b11 {
47            0 => Self::None,
48            1 => Self::Word,
49            2 => Self::Line,
50            3 => Self::Mandatory,
51            _ => Self::None,
52        }
53    }
54}
55
56/// Arbitrary user data that can be associated with a character throughout
57/// the shaping pipeline.
58pub type UserData = u32;