Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright © 2012 Google, Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * This is part of HarfBuzz, a text shaping library. |
michael@0 | 5 | * |
michael@0 | 6 | * Permission is hereby granted, without written agreement and without |
michael@0 | 7 | * license or royalty fees, to use, copy, modify, and distribute this |
michael@0 | 8 | * software and its documentation for any purpose, provided that the |
michael@0 | 9 | * above copyright notice and the following two paragraphs appear in |
michael@0 | 10 | * all copies of this software. |
michael@0 | 11 | * |
michael@0 | 12 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
michael@0 | 13 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
michael@0 | 14 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
michael@0 | 15 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
michael@0 | 16 | * DAMAGE. |
michael@0 | 17 | * |
michael@0 | 18 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
michael@0 | 19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
michael@0 | 20 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
michael@0 | 21 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
michael@0 | 22 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
michael@0 | 23 | * |
michael@0 | 24 | * Google Author(s): Behdad Esfahbod |
michael@0 | 25 | */ |
michael@0 | 26 | |
michael@0 | 27 | #ifndef HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH |
michael@0 | 28 | #define HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH |
michael@0 | 29 | |
michael@0 | 30 | #include "hb-private.hh" |
michael@0 | 31 | |
michael@0 | 32 | |
michael@0 | 33 | #include "hb-ot-shape-complex-private.hh" |
michael@0 | 34 | #include "hb-ot-shape-private.hh" /* XXX Remove */ |
michael@0 | 35 | |
michael@0 | 36 | |
michael@0 | 37 | #define INDIC_TABLE_ELEMENT_TYPE uint16_t |
michael@0 | 38 | |
michael@0 | 39 | /* Cateories used in the OpenType spec: |
michael@0 | 40 | * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx |
michael@0 | 41 | */ |
michael@0 | 42 | /* Note: This enum is duplicated in the -machine.rl source file. |
michael@0 | 43 | * Not sure how to avoid duplication. */ |
michael@0 | 44 | enum indic_category_t { |
michael@0 | 45 | OT_X = 0, |
michael@0 | 46 | OT_C = 1, |
michael@0 | 47 | OT_V = 2, |
michael@0 | 48 | OT_N = 3, |
michael@0 | 49 | OT_H = 4, |
michael@0 | 50 | OT_ZWNJ = 5, |
michael@0 | 51 | OT_ZWJ = 6, |
michael@0 | 52 | OT_M = 7, |
michael@0 | 53 | OT_SM = 8, |
michael@0 | 54 | OT_VD = 9, |
michael@0 | 55 | OT_A = 10, |
michael@0 | 56 | OT_NBSP = 11, |
michael@0 | 57 | OT_DOTTEDCIRCLE = 12, |
michael@0 | 58 | OT_RS = 13, /* Register Shifter, used in Khmer OT spec. */ |
michael@0 | 59 | OT_Coeng = 14, /* Khmer-style Virama. */ |
michael@0 | 60 | OT_Repha = 15, /* Atomically-encoded logical or visual repha. */ |
michael@0 | 61 | OT_Ra = 16, |
michael@0 | 62 | OT_CM = 17, /* Consonant-Medial. */ |
michael@0 | 63 | OT_Avag = 18, /* Avagraha. */ |
michael@0 | 64 | OT_CM2 = 31 /* Consonant-Medial, second slot. */ |
michael@0 | 65 | }; |
michael@0 | 66 | |
michael@0 | 67 | /* Visual positions in a syllable from left to right. */ |
michael@0 | 68 | enum indic_position_t { |
michael@0 | 69 | POS_START, |
michael@0 | 70 | |
michael@0 | 71 | POS_RA_TO_BECOME_REPH, |
michael@0 | 72 | POS_PRE_M, |
michael@0 | 73 | POS_PRE_C, |
michael@0 | 74 | |
michael@0 | 75 | POS_BASE_C, |
michael@0 | 76 | POS_AFTER_MAIN, |
michael@0 | 77 | |
michael@0 | 78 | POS_ABOVE_C, |
michael@0 | 79 | |
michael@0 | 80 | POS_BEFORE_SUB, |
michael@0 | 81 | POS_BELOW_C, |
michael@0 | 82 | POS_AFTER_SUB, |
michael@0 | 83 | |
michael@0 | 84 | POS_BEFORE_POST, |
michael@0 | 85 | POS_POST_C, |
michael@0 | 86 | POS_AFTER_POST, |
michael@0 | 87 | |
michael@0 | 88 | POS_FINAL_C, |
michael@0 | 89 | POS_SMVD, |
michael@0 | 90 | |
michael@0 | 91 | POS_END |
michael@0 | 92 | }; |
michael@0 | 93 | |
michael@0 | 94 | /* Categories used in IndicSyllabicCategory.txt from UCD. */ |
michael@0 | 95 | enum indic_syllabic_category_t { |
michael@0 | 96 | INDIC_SYLLABIC_CATEGORY_OTHER = OT_X, |
michael@0 | 97 | |
michael@0 | 98 | INDIC_SYLLABIC_CATEGORY_AVAGRAHA = OT_Avag, |
michael@0 | 99 | INDIC_SYLLABIC_CATEGORY_BINDU = OT_SM, |
michael@0 | 100 | INDIC_SYLLABIC_CATEGORY_CONSONANT = OT_C, |
michael@0 | 101 | INDIC_SYLLABIC_CATEGORY_CONSONANT_DEAD = OT_C, |
michael@0 | 102 | INDIC_SYLLABIC_CATEGORY_CONSONANT_FINAL = OT_CM, |
michael@0 | 103 | INDIC_SYLLABIC_CATEGORY_CONSONANT_HEAD_LETTER = OT_C, |
michael@0 | 104 | INDIC_SYLLABIC_CATEGORY_CONSONANT_MEDIAL = OT_CM, |
michael@0 | 105 | INDIC_SYLLABIC_CATEGORY_CONSONANT_PLACEHOLDER = OT_NBSP, |
michael@0 | 106 | INDIC_SYLLABIC_CATEGORY_CONSONANT_SUBJOINED = OT_CM, |
michael@0 | 107 | INDIC_SYLLABIC_CATEGORY_CONSONANT_REPHA = OT_Repha, |
michael@0 | 108 | INDIC_SYLLABIC_CATEGORY_MODIFYING_LETTER = OT_X, |
michael@0 | 109 | INDIC_SYLLABIC_CATEGORY_NUKTA = OT_N, |
michael@0 | 110 | INDIC_SYLLABIC_CATEGORY_REGISTER_SHIFTER = OT_RS, |
michael@0 | 111 | INDIC_SYLLABIC_CATEGORY_TONE_LETTER = OT_X, |
michael@0 | 112 | INDIC_SYLLABIC_CATEGORY_TONE_MARK = OT_N, |
michael@0 | 113 | INDIC_SYLLABIC_CATEGORY_VIRAMA = OT_H, |
michael@0 | 114 | INDIC_SYLLABIC_CATEGORY_VISARGA = OT_SM, |
michael@0 | 115 | INDIC_SYLLABIC_CATEGORY_VOWEL = OT_V, |
michael@0 | 116 | INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT = OT_M, |
michael@0 | 117 | INDIC_SYLLABIC_CATEGORY_VOWEL_INDEPENDENT = OT_V |
michael@0 | 118 | }; |
michael@0 | 119 | |
michael@0 | 120 | /* Categories used in IndicSMatraCategory.txt from UCD */ |
michael@0 | 121 | enum indic_matra_category_t { |
michael@0 | 122 | INDIC_MATRA_CATEGORY_NOT_APPLICABLE = POS_END, |
michael@0 | 123 | |
michael@0 | 124 | INDIC_MATRA_CATEGORY_LEFT = POS_PRE_C, |
michael@0 | 125 | INDIC_MATRA_CATEGORY_TOP = POS_ABOVE_C, |
michael@0 | 126 | INDIC_MATRA_CATEGORY_BOTTOM = POS_BELOW_C, |
michael@0 | 127 | INDIC_MATRA_CATEGORY_RIGHT = POS_POST_C, |
michael@0 | 128 | |
michael@0 | 129 | /* These should resolve to the position of the last part of the split sequence. */ |
michael@0 | 130 | INDIC_MATRA_CATEGORY_BOTTOM_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT, |
michael@0 | 131 | INDIC_MATRA_CATEGORY_LEFT_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT, |
michael@0 | 132 | INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM = INDIC_MATRA_CATEGORY_BOTTOM, |
michael@0 | 133 | INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT, |
michael@0 | 134 | INDIC_MATRA_CATEGORY_TOP_AND_LEFT = INDIC_MATRA_CATEGORY_TOP, |
michael@0 | 135 | INDIC_MATRA_CATEGORY_TOP_AND_LEFT_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT, |
michael@0 | 136 | INDIC_MATRA_CATEGORY_TOP_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT, |
michael@0 | 137 | |
michael@0 | 138 | INDIC_MATRA_CATEGORY_INVISIBLE = INDIC_MATRA_CATEGORY_NOT_APPLICABLE, |
michael@0 | 139 | INDIC_MATRA_CATEGORY_OVERSTRUCK = POS_AFTER_MAIN, |
michael@0 | 140 | INDIC_MATRA_CATEGORY_VISUAL_ORDER_LEFT = POS_PRE_M |
michael@0 | 141 | }; |
michael@0 | 142 | |
michael@0 | 143 | /* Note: We use ASSERT_STATIC_EXPR_ZERO() instead of ASSERT_STATIC_EXPR() and the comma operation |
michael@0 | 144 | * because gcc fails to optimize the latter and fills the table in at runtime. */ |
michael@0 | 145 | #define INDIC_COMBINE_CATEGORIES(S,M) \ |
michael@0 | 146 | (ASSERT_STATIC_EXPR_ZERO (M == INDIC_MATRA_CATEGORY_NOT_APPLICABLE || (S == INDIC_SYLLABIC_CATEGORY_VIRAMA || S == INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT)) + \ |
michael@0 | 147 | ASSERT_STATIC_EXPR_ZERO (S < 255 && M < 255) + \ |
michael@0 | 148 | ((M << 8) | S)) |
michael@0 | 149 | |
michael@0 | 150 | HB_INTERNAL INDIC_TABLE_ELEMENT_TYPE |
michael@0 | 151 | hb_indic_get_categories (hb_codepoint_t u); |
michael@0 | 152 | |
michael@0 | 153 | #endif /* HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH */ |