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
/*!
Script aware cluster segmentation.

This module provides support for breaking text into clusters that are
appropriate for shaping with a given script. For most scripts, clusters are
equivalent to Unicode grapheme clusters. More complex scripts, however,
may produce shaping clusters that contain multiple graphemes.
*/

mod char;
#[allow(clippy::module_inception)]
mod cluster;
mod complex;
mod info;
mod myanmar;
mod parse;
mod simple;
mod token;

pub use self::{
    char::{Char, ShapeClass},
    cluster::{CharCluster, SourceRange, Status, MAX_CLUSTER_SIZE},
    info::{CharInfo, ClusterInfo, Emoji, Whitespace},
    parse::Parser,
    token::Token,
};

use super::unicode_data;

/// Boundary type of a character or cluster.
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
#[repr(u8)]
pub enum Boundary {
    /// Not a boundary.
    None = 0,
    /// Start of a word.
    Word = 1,
    /// Potential line break.
    Line = 2,
    /// Mandatory line break.
    Mandatory = 3,
}

impl Boundary {
    pub(super) fn from_raw(raw: u16) -> Self {
        match raw & 0b11 {
            0 => Self::None,
            1 => Self::Word,
            2 => Self::Line,
            3 => Self::Mandatory,
            _ => Self::None,
        }
    }
}

/// Artibrary user data that can be associated with a character throughout
/// the shaping pipeline.
pub type UserData = u32;