Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f
[chromium-blink-merge.git] / third_party / harfbuzz-ng / src / hb-ot-shape-complex-indic-private.hh
blobd8dfc6507d9d2eddef33ba5f8c0b27c7ef6ca92e
1 /*
2 * Copyright © 2012 Google, Inc.
4 * This is part of HarfBuzz, a text shaping library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * Google Author(s): Behdad Esfahbod
27 #ifndef HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH
28 #define HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH
30 #include "hb-private.hh"
33 #include "hb-ot-shape-complex-private.hh"
34 #include "hb-ot-shape-private.hh" /* XXX Remove */
37 #define INDIC_TABLE_ELEMENT_TYPE uint16_t
39 /* Cateories used in the OpenType spec:
40 * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx
42 /* Note: This enum is duplicated in the -machine.rl source file.
43 * Not sure how to avoid duplication. */
44 enum indic_category_t {
45 OT_X = 0,
46 OT_C = 1,
47 OT_V = 2,
48 OT_N = 3,
49 OT_H = 4,
50 OT_ZWNJ = 5,
51 OT_ZWJ = 6,
52 OT_M = 7,
53 OT_SM = 8,
54 OT_VD = 9,
55 OT_A = 10,
56 OT_PLACEHOLDER = 11,
57 OT_DOTTEDCIRCLE = 12,
58 OT_RS = 13, /* Register Shifter, used in Khmer OT spec. */
59 OT_Coeng = 14, /* Khmer-style Virama. */
60 OT_Repha = 15, /* Atomically-encoded logical or visual repha. */
61 OT_Ra = 16,
62 OT_CM = 17, /* Consonant-Medial. */
63 OT_Symbol = 18, /* Avagraha, etc that take marks (SM,A,VD). */
64 OT_CM2 = 31 /* Consonant-Medial, second slot. */
67 #define MEDIAL_FLAGS (FLAG (OT_CM) | FLAG (OT_CM2))
69 /* Note:
71 * We treat Vowels and placeholders as if they were consonants. This is safe because Vowels
72 * cannot happen in a consonant syllable. The plus side however is, we can call the
73 * consonant syllable logic from the vowel syllable function and get it all right! */
74 #define CONSONANT_FLAGS (FLAG (OT_C) | FLAG (OT_Ra) | MEDIAL_FLAGS | FLAG (OT_V) | FLAG (OT_PLACEHOLDER) | FLAG (OT_DOTTEDCIRCLE))
75 #define JOINER_FLAGS (FLAG (OT_ZWJ) | FLAG (OT_ZWNJ))
76 #define HALANT_OR_COENG_FLAGS (FLAG (OT_H) | FLAG (OT_Coeng))
79 /* Visual positions in a syllable from left to right. */
80 enum indic_position_t {
81 POS_START,
83 POS_RA_TO_BECOME_REPH,
84 POS_PRE_M,
85 POS_PRE_C,
87 POS_BASE_C,
88 POS_AFTER_MAIN,
90 POS_ABOVE_C,
92 POS_BEFORE_SUB,
93 POS_BELOW_C,
94 POS_AFTER_SUB,
96 POS_BEFORE_POST,
97 POS_POST_C,
98 POS_AFTER_POST,
100 POS_FINAL_C,
101 POS_SMVD,
103 POS_END
106 /* Categories used in IndicSyllabicCategory.txt from UCD. */
107 enum indic_syllabic_category_t {
108 INDIC_SYLLABIC_CATEGORY_OTHER = OT_X,
110 INDIC_SYLLABIC_CATEGORY_AVAGRAHA = OT_Symbol,
111 INDIC_SYLLABIC_CATEGORY_BINDU = OT_SM,
112 INDIC_SYLLABIC_CATEGORY_BRAHMI_JOINING_NUMBER = OT_PLACEHOLDER, /* TODO */
113 INDIC_SYLLABIC_CATEGORY_CANTILLATION_MARK = OT_A,
114 INDIC_SYLLABIC_CATEGORY_CONSONANT = OT_C,
115 INDIC_SYLLABIC_CATEGORY_CONSONANT_DEAD = OT_C,
116 INDIC_SYLLABIC_CATEGORY_CONSONANT_FINAL = OT_CM,
117 INDIC_SYLLABIC_CATEGORY_CONSONANT_HEAD_LETTER = OT_C,
118 INDIC_SYLLABIC_CATEGORY_CONSONANT_MEDIAL = OT_CM,
119 INDIC_SYLLABIC_CATEGORY_CONSONANT_PLACEHOLDER = OT_PLACEHOLDER,
120 INDIC_SYLLABIC_CATEGORY_CONSONANT_PRECEDING_REPHA = OT_Repha,
121 INDIC_SYLLABIC_CATEGORY_CONSONANT_SUBJOINED = OT_CM,
122 INDIC_SYLLABIC_CATEGORY_CONSONANT_SUCCEEDING_REPHA = OT_N,
123 INDIC_SYLLABIC_CATEGORY_GEMINATION_MARK = OT_SM,
124 INDIC_SYLLABIC_CATEGORY_INVISIBLE_STACKER = OT_H, /* TODO */
125 INDIC_SYLLABIC_CATEGORY_JOINER = OT_ZWJ,
126 INDIC_SYLLABIC_CATEGORY_MODIFYING_LETTER = OT_X,
127 INDIC_SYLLABIC_CATEGORY_NON_JOINER = OT_ZWNJ,
128 INDIC_SYLLABIC_CATEGORY_NUKTA = OT_N,
129 INDIC_SYLLABIC_CATEGORY_NUMBER = OT_PLACEHOLDER,
130 INDIC_SYLLABIC_CATEGORY_NUMBER_JOINER = OT_PLACEHOLDER, /* TODO */
131 INDIC_SYLLABIC_CATEGORY_PURE_KILLER = OT_H, /* TODO */
132 INDIC_SYLLABIC_CATEGORY_REGISTER_SHIFTER = OT_RS,
133 INDIC_SYLLABIC_CATEGORY_TONE_LETTER = OT_X,
134 INDIC_SYLLABIC_CATEGORY_TONE_MARK = OT_N,
135 INDIC_SYLLABIC_CATEGORY_VIRAMA = OT_H,
136 INDIC_SYLLABIC_CATEGORY_VISARGA = OT_SM,
137 INDIC_SYLLABIC_CATEGORY_VOWEL = OT_V,
138 INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT = OT_M,
139 INDIC_SYLLABIC_CATEGORY_VOWEL_INDEPENDENT = OT_V
142 /* Categories used in IndicSMatraCategory.txt from UCD */
143 enum indic_matra_category_t {
144 INDIC_MATRA_CATEGORY_NOT_APPLICABLE = POS_END,
146 INDIC_MATRA_CATEGORY_LEFT = POS_PRE_C,
147 INDIC_MATRA_CATEGORY_TOP = POS_ABOVE_C,
148 INDIC_MATRA_CATEGORY_BOTTOM = POS_BELOW_C,
149 INDIC_MATRA_CATEGORY_RIGHT = POS_POST_C,
151 /* These should resolve to the position of the last part of the split sequence. */
152 INDIC_MATRA_CATEGORY_BOTTOM_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT,
153 INDIC_MATRA_CATEGORY_LEFT_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT,
154 INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM = INDIC_MATRA_CATEGORY_BOTTOM,
155 INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT,
156 INDIC_MATRA_CATEGORY_TOP_AND_LEFT = INDIC_MATRA_CATEGORY_TOP,
157 INDIC_MATRA_CATEGORY_TOP_AND_LEFT_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT,
158 INDIC_MATRA_CATEGORY_TOP_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT,
160 INDIC_MATRA_CATEGORY_OVERSTRUCK = POS_AFTER_MAIN,
161 INDIC_MATRA_CATEGORY_VISUAL_ORDER_LEFT = POS_PRE_M
164 /* Note: We use ASSERT_STATIC_EXPR_ZERO() instead of ASSERT_STATIC_EXPR() and the comma operation
165 * because gcc fails to optimize the latter and fills the table in at runtime. */
166 #define INDIC_COMBINE_CATEGORIES(S,M) \
167 (ASSERT_STATIC_EXPR_ZERO (M == INDIC_MATRA_CATEGORY_NOT_APPLICABLE || \
169 S == INDIC_SYLLABIC_CATEGORY_CONSONANT_MEDIAL || \
170 S == INDIC_SYLLABIC_CATEGORY_GEMINATION_MARK || \
171 S == INDIC_SYLLABIC_CATEGORY_REGISTER_SHIFTER || \
172 S == INDIC_SYLLABIC_CATEGORY_CONSONANT_SUCCEEDING_REPHA || \
173 S == INDIC_SYLLABIC_CATEGORY_VIRAMA || \
174 S == INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT || \
175 false)) + \
176 ASSERT_STATIC_EXPR_ZERO (S < 255 && M < 255) + \
177 ((M << 8) | S))
179 HB_INTERNAL INDIC_TABLE_ELEMENT_TYPE
180 hb_indic_get_categories (hb_codepoint_t u);
182 #endif /* HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH */