swash/text/cluster/
char.rs

1use super::super::JoiningType;
2use super::UserData;
3use crate::GlyphId;
4
5/// Character output from the cluster parser.
6#[derive(Copy, Clone, Debug)]
7pub struct Char {
8    /// The character.
9    pub ch: char,
10    /// Offset of the character in code units.
11    pub offset: u32,
12    /// Shaping class of the character.
13    pub shape_class: ShapeClass,
14    /// Joining type of the character.
15    pub joining_type: JoiningType,
16    /// True if the character is ignorable.
17    pub ignorable: bool,
18    /// True if the character should be considered when mapping glyphs.
19    pub contributes_to_shaping: bool,
20    /// Nominal glyph identifier.
21    pub glyph_id: GlyphId,
22    /// Arbitrary user data.
23    pub data: UserData,
24}
25
26impl Default for Char {
27    fn default() -> Self {
28        Self {
29            ch: '\0',
30            shape_class: ShapeClass::Base,
31            joining_type: JoiningType::U,
32            ignorable: false,
33            contributes_to_shaping: true,
34            glyph_id: 0,
35            data: 0,
36            offset: 0,
37        }
38    }
39}
40
41/// Shaping class of a character.
42#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
43#[repr(u8)]
44pub enum ShapeClass {
45    /// Reph form.
46    Reph,
47    /// Pre-base form.
48    Pref,
49    /// Myanmar three character prefix.
50    Kinzi,
51    /// Base character.
52    Base,
53    /// Mark character.
54    Mark,
55    /// Halant modifier.
56    Halant,
57    /// Medial consonant Ra.
58    MedialRa,
59    /// Pre-base vowel modifier.
60    VMPre,
61    /// Pre-base dependent vowel.
62    VPre,
63    /// Below base dependent vowel.
64    VBlw,
65    /// Anusvara class.
66    Anusvara,
67    /// Zero width joiner.
68    Zwj,
69    /// Zero width non-joiner.
70    Zwnj,
71    /// Control character.
72    Control,
73    /// Variation selector.
74    Vs,
75    /// Other character.
76    Other,
77}
78
79impl Default for ShapeClass {
80    fn default() -> Self {
81        Self::Base
82    }
83}