OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright © 2012 Google, Inc. |
| 3 * |
| 4 * This is part of HarfBuzz, a text shaping library. |
| 5 * |
| 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. |
| 11 * |
| 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. |
| 17 * |
| 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. |
| 23 * |
| 24 * Google Author(s): Behdad Esfahbod |
| 25 */ |
| 26 |
| 27 #ifndef HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH |
| 28 #define HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH |
| 29 |
| 30 #include "hb-private.hh" |
| 31 |
| 32 |
| 33 #include "hb-ot-shape-complex-private.hh" |
| 34 |
| 35 |
| 36 /* buffer var allocations */ |
| 37 #define indic_category() complex_var_persistent_u8_0() /* indic_category_t */ |
| 38 #define indic_position() complex_var_persistent_u8_1() /* indic_matra_category_t
*/ |
| 39 |
| 40 #define INDIC_TABLE_ELEMENT_TYPE uint8_t |
| 41 |
| 42 /* Cateories used in the OpenType spec: |
| 43 * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx |
| 44 */ |
| 45 /* Note: This enum is duplicated in the -machine.rl source file. |
| 46 * Not sure how to avoid duplication. */ |
| 47 enum indic_category_t { |
| 48 OT_X = 0, |
| 49 OT_C, |
| 50 OT_Ra, /* Not explicitly listed in the OT spec, but used in the grammar. */ |
| 51 OT_V, |
| 52 OT_N, |
| 53 OT_H, |
| 54 OT_ZWNJ, |
| 55 OT_ZWJ, |
| 56 OT_M, |
| 57 OT_SM, |
| 58 OT_VD, |
| 59 OT_A, |
| 60 OT_NBSP, |
| 61 OT_DOTTEDCIRCLE /* Not in the spec, but special in Uniscribe. /Very very/ spec
ial! */ |
| 62 }; |
| 63 |
| 64 /* Visual positions in a syllable from left to right. */ |
| 65 enum indic_position_t { |
| 66 POS_RA_TO_BECOME_REPH, |
| 67 POS_PRE_M, |
| 68 POS_PRE_C, |
| 69 POS_BASE_C, |
| 70 POS_ABOVE_C, |
| 71 POS_BELOW_C, |
| 72 POS_ABOVE_M, |
| 73 POS_BELOW_M, |
| 74 POS_POST_C, |
| 75 POS_POST_M, |
| 76 POS_SMVD |
| 77 }; |
| 78 |
| 79 /* Categories used in IndicSyllabicCategory.txt from UCD. */ |
| 80 enum indic_syllabic_category_t { |
| 81 INDIC_SYLLABIC_CATEGORY_OTHER = OT_X, |
| 82 |
| 83 INDIC_SYLLABIC_CATEGORY_AVAGRAHA = OT_X, |
| 84 INDIC_SYLLABIC_CATEGORY_BINDU = OT_SM, |
| 85 INDIC_SYLLABIC_CATEGORY_CONSONANT = OT_C, |
| 86 INDIC_SYLLABIC_CATEGORY_CONSONANT_DEAD = OT_C, |
| 87 INDIC_SYLLABIC_CATEGORY_CONSONANT_FINAL = OT_C, |
| 88 INDIC_SYLLABIC_CATEGORY_CONSONANT_HEAD_LETTER = OT_C, |
| 89 INDIC_SYLLABIC_CATEGORY_CONSONANT_MEDIAL = OT_C, |
| 90 INDIC_SYLLABIC_CATEGORY_CONSONANT_PLACEHOLDER = OT_NBSP, |
| 91 INDIC_SYLLABIC_CATEGORY_CONSONANT_SUBJOINED = OT_C, |
| 92 INDIC_SYLLABIC_CATEGORY_CONSONANT_REPHA = OT_C, |
| 93 INDIC_SYLLABIC_CATEGORY_MODIFYING_LETTER = OT_X, |
| 94 INDIC_SYLLABIC_CATEGORY_NUKTA = OT_N, |
| 95 INDIC_SYLLABIC_CATEGORY_REGISTER_SHIFTER = OT_X, |
| 96 INDIC_SYLLABIC_CATEGORY_TONE_LETTER = OT_X, |
| 97 INDIC_SYLLABIC_CATEGORY_TONE_MARK = OT_X, |
| 98 INDIC_SYLLABIC_CATEGORY_VIRAMA = OT_H, |
| 99 INDIC_SYLLABIC_CATEGORY_VISARGA = OT_SM, |
| 100 INDIC_SYLLABIC_CATEGORY_VOWEL = OT_V, |
| 101 INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT = OT_M, |
| 102 INDIC_SYLLABIC_CATEGORY_VOWEL_INDEPENDENT = OT_V |
| 103 }; |
| 104 |
| 105 /* Categories used in IndicSMatraCategory.txt from UCD */ |
| 106 enum indic_matra_category_t { |
| 107 INDIC_MATRA_CATEGORY_NOT_APPLICABLE = POS_BASE_C, |
| 108 |
| 109 INDIC_MATRA_CATEGORY_LEFT = POS_PRE_M, |
| 110 INDIC_MATRA_CATEGORY_TOP = POS_ABOVE_M, |
| 111 INDIC_MATRA_CATEGORY_BOTTOM = POS_BELOW_M, |
| 112 INDIC_MATRA_CATEGORY_RIGHT = POS_POST_M, |
| 113 |
| 114 /* We don't really care much about these since we decompose them |
| 115 * in the generic pre-shaping layer. They will only be used if |
| 116 * the font does not cover the decomposition. In which case, we |
| 117 * define these as aliases to the place we want the split-matra |
| 118 * glyph to show up. Quite arbitrary. |
| 119 * |
| 120 * TODO: There are some split matras without Unicode decompositions. |
| 121 * We have to figure out what to do with them. |
| 122 */ |
| 123 INDIC_MATRA_CATEGORY_BOTTOM_AND_RIGHT = POS_POST_M, |
| 124 INDIC_MATRA_CATEGORY_LEFT_AND_RIGHT = POS_PRE_M, |
| 125 INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM = POS_BELOW_M, |
| 126 INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM_AND_RIGHT = POS_POST_M, |
| 127 INDIC_MATRA_CATEGORY_TOP_AND_LEFT = POS_PRE_M, |
| 128 INDIC_MATRA_CATEGORY_TOP_AND_LEFT_AND_RIGHT = POS_PRE_M, |
| 129 INDIC_MATRA_CATEGORY_TOP_AND_RIGHT = POS_POST_M, |
| 130 |
| 131 INDIC_MATRA_CATEGORY_INVISIBLE = INDIC_MATRA_CATEGORY_NOT_APPLI
CABLE, |
| 132 INDIC_MATRA_CATEGORY_OVERSTRUCK = INDIC_MATRA_CATEGORY_NOT_APPLI
CABLE, |
| 133 INDIC_MATRA_CATEGORY_VISUAL_ORDER_LEFT = INDIC_MATRA_CATEGORY_NOT_APPLI
CABLE |
| 134 }; |
| 135 |
| 136 /* Note: We use ASSERT_STATIC_EXPR_ZERO() instead of ASSERT_STATIC_EXPR() and th
e comma operation |
| 137 * because gcc fails to optimize the latter and fills the table in at runtime. *
/ |
| 138 #define INDIC_COMBINE_CATEGORIES(S,M) \ |
| 139 (ASSERT_STATIC_EXPR_ZERO (M == INDIC_MATRA_CATEGORY_NOT_APPLICABLE || (S == IN
DIC_SYLLABIC_CATEGORY_VIRAMA || S == INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT)) +
\ |
| 140 ASSERT_STATIC_EXPR_ZERO (S < 16 && M < 16) + \ |
| 141 ((M << 4) | S)) |
| 142 |
| 143 |
| 144 #include "hb-ot-shape-complex-indic-table.hh" |
| 145 |
| 146 /* XXX |
| 147 * This is a hack for now. We should: |
| 148 * 1. Move this data into the main Indic table, |
| 149 * and/or |
| 150 * 2. Probe font lookups to determine consonant positions. |
| 151 */ |
| 152 static const struct consonant_position_t { |
| 153 hb_codepoint_t u; |
| 154 indic_position_t position; |
| 155 } consonant_positions[] = { |
| 156 {0x0930, POS_BELOW_C}, |
| 157 {0x09AC, POS_BELOW_C}, |
| 158 {0x09AF, POS_POST_C}, |
| 159 {0x09B0, POS_BELOW_C}, |
| 160 {0x09F0, POS_BELOW_C}, |
| 161 {0x0A2F, POS_POST_C}, |
| 162 {0x0A30, POS_BELOW_C}, |
| 163 {0x0A35, POS_BELOW_C}, |
| 164 {0x0A39, POS_BELOW_C}, |
| 165 {0x0AB0, POS_BELOW_C}, |
| 166 {0x0B24, POS_BELOW_C}, |
| 167 {0x0B28, POS_BELOW_C}, |
| 168 {0x0B2C, POS_BELOW_C}, |
| 169 {0x0B2D, POS_BELOW_C}, |
| 170 {0x0B2E, POS_BELOW_C}, |
| 171 {0x0B2F, POS_POST_C}, |
| 172 {0x0B30, POS_BELOW_C}, |
| 173 {0x0B32, POS_BELOW_C}, |
| 174 {0x0B33, POS_BELOW_C}, |
| 175 {0x0B5F, POS_POST_C}, |
| 176 {0x0B71, POS_BELOW_C}, |
| 177 {0x0C15, POS_BELOW_C}, |
| 178 {0x0C16, POS_BELOW_C}, |
| 179 {0x0C17, POS_BELOW_C}, |
| 180 {0x0C18, POS_BELOW_C}, |
| 181 {0x0C19, POS_BELOW_C}, |
| 182 {0x0C1A, POS_BELOW_C}, |
| 183 {0x0C1B, POS_BELOW_C}, |
| 184 {0x0C1C, POS_BELOW_C}, |
| 185 {0x0C1D, POS_BELOW_C}, |
| 186 {0x0C1E, POS_BELOW_C}, |
| 187 {0x0C1F, POS_BELOW_C}, |
| 188 {0x0C20, POS_BELOW_C}, |
| 189 {0x0C21, POS_BELOW_C}, |
| 190 {0x0C22, POS_BELOW_C}, |
| 191 {0x0C23, POS_BELOW_C}, |
| 192 {0x0C24, POS_BELOW_C}, |
| 193 {0x0C25, POS_BELOW_C}, |
| 194 {0x0C26, POS_BELOW_C}, |
| 195 {0x0C27, POS_BELOW_C}, |
| 196 {0x0C28, POS_BELOW_C}, |
| 197 {0x0C2A, POS_BELOW_C}, |
| 198 {0x0C2B, POS_BELOW_C}, |
| 199 {0x0C2C, POS_BELOW_C}, |
| 200 {0x0C2D, POS_BELOW_C}, |
| 201 {0x0C2E, POS_BELOW_C}, |
| 202 {0x0C2F, POS_BELOW_C}, |
| 203 {0x0C30, POS_BELOW_C}, |
| 204 {0x0C32, POS_BELOW_C}, |
| 205 {0x0C33, POS_BELOW_C}, |
| 206 {0x0C35, POS_BELOW_C}, |
| 207 {0x0C36, POS_BELOW_C}, |
| 208 {0x0C37, POS_BELOW_C}, |
| 209 {0x0C38, POS_BELOW_C}, |
| 210 {0x0C39, POS_BELOW_C}, |
| 211 {0x0C95, POS_BELOW_C}, |
| 212 {0x0C96, POS_BELOW_C}, |
| 213 {0x0C97, POS_BELOW_C}, |
| 214 {0x0C98, POS_BELOW_C}, |
| 215 {0x0C99, POS_BELOW_C}, |
| 216 {0x0C9A, POS_BELOW_C}, |
| 217 {0x0C9B, POS_BELOW_C}, |
| 218 {0x0C9C, POS_BELOW_C}, |
| 219 {0x0C9D, POS_BELOW_C}, |
| 220 {0x0C9E, POS_BELOW_C}, |
| 221 {0x0C9F, POS_BELOW_C}, |
| 222 {0x0CA0, POS_BELOW_C}, |
| 223 {0x0CA1, POS_BELOW_C}, |
| 224 {0x0CA2, POS_BELOW_C}, |
| 225 {0x0CA3, POS_BELOW_C}, |
| 226 {0x0CA4, POS_BELOW_C}, |
| 227 {0x0CA5, POS_BELOW_C}, |
| 228 {0x0CA6, POS_BELOW_C}, |
| 229 {0x0CA7, POS_BELOW_C}, |
| 230 {0x0CA8, POS_BELOW_C}, |
| 231 {0x0CAA, POS_BELOW_C}, |
| 232 {0x0CAB, POS_BELOW_C}, |
| 233 {0x0CAC, POS_BELOW_C}, |
| 234 {0x0CAD, POS_BELOW_C}, |
| 235 {0x0CAE, POS_BELOW_C}, |
| 236 {0x0CAF, POS_BELOW_C}, |
| 237 {0x0CB0, POS_BELOW_C}, |
| 238 {0x0CB2, POS_BELOW_C}, |
| 239 {0x0CB3, POS_BELOW_C}, |
| 240 {0x0CB5, POS_BELOW_C}, |
| 241 {0x0CB6, POS_BELOW_C}, |
| 242 {0x0CB7, POS_BELOW_C}, |
| 243 {0x0CB8, POS_BELOW_C}, |
| 244 {0x0CB9, POS_BELOW_C}, |
| 245 {0x0CDE, POS_BELOW_C}, |
| 246 {0x0D2F, POS_POST_C}, |
| 247 {0x0D30, POS_POST_C}, |
| 248 {0x0D32, POS_BELOW_C}, |
| 249 {0x0D35, POS_POST_C}, |
| 250 }; |
| 251 |
| 252 /* XXX |
| 253 * This is a hack for now. We should move this data into the main Indic table. |
| 254 * Or completely remove it and just check in the tables. |
| 255 */ |
| 256 static const hb_codepoint_t ra_chars[] = { |
| 257 0x0930, /* Devanagari */ |
| 258 0x09B0, /* Bengali */ |
| 259 0x09F0, /* Bengali */ |
| 260 0x0A30, /* Gurmukhi */ /* No Reph */ |
| 261 0x0AB0, /* Gujarati */ |
| 262 0x0B30, /* Oriya */ |
| 263 0x0BB0, /* Tamil */ /* No Reph */ |
| 264 0x0C30, /* Telugu */ /* No Reph */ |
| 265 0x0CB0, /* Kannada */ |
| 266 0x0D30, /* Malayalam */ /* No Reph */ |
| 267 }; |
| 268 |
| 269 |
| 270 #endif /* HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH */ |
OLD | NEW |