hb-ot-shape-complex-indic.cc revision 9ee27a928a989c71923cef82a9e9828f8e9ca051
1b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod/* 220503ccd578c9983162857954e3236413469ed35Behdad Esfahbod * Copyright © 2011 Google, Inc. 3b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * 4b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * This is part of HarfBuzz, a text shaping library. 5b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * 6b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * Permission is hereby granted, without written agreement and without 7b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this 8b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * software and its documentation for any purpose, provided that the 9b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * above copyright notice and the following two paragraphs appear in 10b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * all copies of this software. 11b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * 12b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 13b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 14b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 15b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 16b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * DAMAGE. 17b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * 18b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 19b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 21b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 22b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 23b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * 24b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod * Google Author(s): Behdad Esfahbod 25b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod */ 26b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 27b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod#include "hb-ot-shape-complex-private.hh" 28b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 29b9ddbd55930228422e82b34a141ad1b6093f5376Behdad EsfahbodHB_BEGIN_DECLS 30b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 31b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 32b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod/* buffer var allocations */ 33b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod#define indic_category() complex_var_persistent_u8_0() /* indic_category_t */ 34b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod#define indic_position() complex_var_persistent_u8_1() /* indic_matra_category_t */ 35b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 36b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod#define INDIC_TABLE_ELEMENT_TYPE uint8_t 37b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 3820503ccd578c9983162857954e3236413469ed35Behdad Esfahbod/* Cateories used in the OpenType spec: 3920503ccd578c9983162857954e3236413469ed35Behdad Esfahbod * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx 4020503ccd578c9983162857954e3236413469ed35Behdad Esfahbod */ 41c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod/* Note: This enum is duplicated in the -machine.rl source file. 42c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod * Not sure how to avoid duplication. */ 43867361c3ad39629a8d5b7dc48d558a1c19e37d43Behdad Esfahbodenum indic_category_t { 4420503ccd578c9983162857954e3236413469ed35Behdad Esfahbod OT_X = 0, 4520503ccd578c9983162857954e3236413469ed35Behdad Esfahbod OT_C, 46c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod OT_Ra, /* Not explicitly listed in the OT spec, but used in the grammar. */ 4720503ccd578c9983162857954e3236413469ed35Behdad Esfahbod OT_V, 4820503ccd578c9983162857954e3236413469ed35Behdad Esfahbod OT_N, 4920503ccd578c9983162857954e3236413469ed35Behdad Esfahbod OT_H, 5020503ccd578c9983162857954e3236413469ed35Behdad Esfahbod OT_ZWNJ, 5120503ccd578c9983162857954e3236413469ed35Behdad Esfahbod OT_ZWJ, 5220503ccd578c9983162857954e3236413469ed35Behdad Esfahbod OT_M, 5320503ccd578c9983162857954e3236413469ed35Behdad Esfahbod OT_SM, 5420503ccd578c9983162857954e3236413469ed35Behdad Esfahbod OT_VD, 5520503ccd578c9983162857954e3236413469ed35Behdad Esfahbod OT_A, 56b9452bfc1696457e156e79037c863903da5454fcBehdad Esfahbod OT_NBSP 5720503ccd578c9983162857954e3236413469ed35Behdad Esfahbod}; 5820503ccd578c9983162857954e3236413469ed35Behdad Esfahbod 598fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod/* Visual positions in a syllable from left to right. */ 608fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbodenum indic_position_t { 618fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod POS_PRE, 628fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod POS_BASE, 638fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod POS_ABOVE, 648fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod POS_BELOW, 658fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod POS_POST, 668fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod}; 678fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod 6820503ccd578c9983162857954e3236413469ed35Behdad Esfahbod/* Categories used in IndicSyllabicCategory.txt from UCD */ 6920503ccd578c9983162857954e3236413469ed35Behdad Esfahbod/* The assignments are guesswork */ 70b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbodenum indic_syllabic_category_t { 7120503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_OTHER = OT_X, 7220503ccd578c9983162857954e3236413469ed35Behdad Esfahbod 73422e08dbb8e2c0c5664f1bdc7e159a673cfea8c5Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_AVAGRAHA = OT_X, 7420503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_BINDU = OT_SM, 7520503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_CONSONANT = OT_C, 7620503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_CONSONANT_DEAD = OT_C, 7720503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_CONSONANT_FINAL = OT_C, 7820503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_CONSONANT_HEAD_LETTER = OT_C, 7920503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_CONSONANT_MEDIAL = OT_C, 8020503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_CONSONANT_PLACEHOLDER = OT_NBSP, 8120503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_CONSONANT_SUBJOINED = OT_C, 8220503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_CONSONANT_REPHA = OT_C, 83422e08dbb8e2c0c5664f1bdc7e159a673cfea8c5Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_MODIFYING_LETTER = OT_X, 8420503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_NUKTA = OT_N, 85422e08dbb8e2c0c5664f1bdc7e159a673cfea8c5Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_REGISTER_SHIFTER = OT_X, 86422e08dbb8e2c0c5664f1bdc7e159a673cfea8c5Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_TONE_LETTER = OT_X, 87422e08dbb8e2c0c5664f1bdc7e159a673cfea8c5Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_TONE_MARK = OT_X, 8820503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_VIRAMA = OT_H, 8920503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_VISARGA = OT_SM, 9020503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_VOWEL = OT_V, 9120503ccd578c9983162857954e3236413469ed35Behdad Esfahbod INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT = OT_M, 92b9452bfc1696457e156e79037c863903da5454fcBehdad Esfahbod INDIC_SYLLABIC_CATEGORY_VOWEL_INDEPENDENT = OT_V 93b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod}; 94b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 9520503ccd578c9983162857954e3236413469ed35Behdad Esfahbod/* Categories used in IndicSMatraCategory.txt from UCD */ 96b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbodenum indic_matra_category_t { 978fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_NOT_APPLICABLE = POS_BASE, 9820503ccd578c9983162857954e3236413469ed35Behdad Esfahbod 998fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_LEFT = POS_PRE, 1008fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_TOP = POS_ABOVE, 1018fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_BOTTOM = POS_BELOW, 1028fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_RIGHT = POS_POST, 103422e08dbb8e2c0c5664f1bdc7e159a673cfea8c5Behdad Esfahbod 104422e08dbb8e2c0c5664f1bdc7e159a673cfea8c5Behdad Esfahbod /* We don't really care much about these since we decompose them 1058fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod * in the generic pre-shaping layer. They will only be used if 1068fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod * the font does not cover the decomposition. In which case, we 1078fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod * define these as aliases to the place we want the split-matra 1088fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod * glyph to show up. Quite arbitrary. */ 1098fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_BOTTOM_AND_RIGHT = INDIC_MATRA_CATEGORY_BOTTOM, 1108fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_LEFT_AND_RIGHT = INDIC_MATRA_CATEGORY_LEFT, 1118fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM = INDIC_MATRA_CATEGORY_BOTTOM, 1128fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM_AND_RIGHT = INDIC_MATRA_CATEGORY_BOTTOM, 1138fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_TOP_AND_LEFT = INDIC_MATRA_CATEGORY_LEFT, 1148fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_TOP_AND_LEFT_AND_RIGHT = INDIC_MATRA_CATEGORY_LEFT, 1158fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod INDIC_MATRA_CATEGORY_TOP_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT, 116422e08dbb8e2c0c5664f1bdc7e159a673cfea8c5Behdad Esfahbod 117422e08dbb8e2c0c5664f1bdc7e159a673cfea8c5Behdad Esfahbod INDIC_MATRA_CATEGORY_INVISIBLE = INDIC_MATRA_CATEGORY_NOT_APPLICABLE, 118422e08dbb8e2c0c5664f1bdc7e159a673cfea8c5Behdad Esfahbod INDIC_MATRA_CATEGORY_OVERSTRUCK = INDIC_MATRA_CATEGORY_NOT_APPLICABLE, 119422e08dbb8e2c0c5664f1bdc7e159a673cfea8c5Behdad Esfahbod INDIC_MATRA_CATEGORY_VISUAL_ORDER_LEFT = INDIC_MATRA_CATEGORY_NOT_APPLICABLE 120b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod}; 121b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 1224ec30aec3014be6effc09cbbc88dcd075f3826dfBehdad Esfahbod/* Note: We use ASSERT_STATIC_EXPR_ZERO() instead of ASSERT_STATIC_EXPR() and the comma operation 1234ec30aec3014be6effc09cbbc88dcd075f3826dfBehdad Esfahbod * because gcc fails to optimize the latter and fills the table in at runtime. */ 12420503ccd578c9983162857954e3236413469ed35Behdad Esfahbod#define INDIC_COMBINE_CATEGORIES(S,M) \ 1254ec30aec3014be6effc09cbbc88dcd075f3826dfBehdad Esfahbod (ASSERT_STATIC_EXPR_ZERO (M == INDIC_MATRA_CATEGORY_NOT_APPLICABLE || (S == INDIC_SYLLABIC_CATEGORY_VIRAMA || S == INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT)) + \ 1264ec30aec3014be6effc09cbbc88dcd075f3826dfBehdad Esfahbod ASSERT_STATIC_EXPR_ZERO (S < 16 && M < 16) + \ 1274ec30aec3014be6effc09cbbc88dcd075f3826dfBehdad Esfahbod ((M << 4) | S)) 128b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 129b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod#include "hb-ot-shape-complex-indic-table.hh" 130b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 13165988a145b4a52c37fd53c1473034f9e701f61d9Behdad Esfahbod/* XXX 13265988a145b4a52c37fd53c1473034f9e701f61d9Behdad Esfahbod * This is a hack for now. We should: 13365988a145b4a52c37fd53c1473034f9e701f61d9Behdad Esfahbod * 1. Move this data into the main Indic table, 13465988a145b4a52c37fd53c1473034f9e701f61d9Behdad Esfahbod * and/or 13565988a145b4a52c37fd53c1473034f9e701f61d9Behdad Esfahbod * 2. Probe font lookups to determine consonant positions. 13665988a145b4a52c37fd53c1473034f9e701f61d9Behdad Esfahbod */ 137743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodstatic const struct consonant_position_t { 13865988a145b4a52c37fd53c1473034f9e701f61d9Behdad Esfahbod hb_codepoint_t u; 1398fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod indic_position_t position; 14065988a145b4a52c37fd53c1473034f9e701f61d9Behdad Esfahbod} consonant_positions[] = { 1418fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0930, POS_BELOW}, 1428fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x09AC, POS_BELOW}, 1438fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x09AF, POS_POST}, 1448fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x09B0, POS_BELOW}, 1458fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x09F0, POS_BELOW}, 1468fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0A2F, POS_POST}, 1478fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0A30, POS_BELOW}, 1488fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0A35, POS_BELOW}, 1498fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0A39, POS_BELOW}, 1508fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0AB0, POS_BELOW}, 1518fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0B24, POS_BELOW}, 1528fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0B28, POS_BELOW}, 1538fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0B2C, POS_BELOW}, 1548fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0B2D, POS_BELOW}, 1558fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0B2E, POS_BELOW}, 1568fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0B2F, POS_POST}, 1578fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0B30, POS_BELOW}, 1588fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0B32, POS_BELOW}, 1598fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0B33, POS_BELOW}, 1608fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0B5F, POS_POST}, 1618fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0B71, POS_BELOW}, 1628fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C15, POS_BELOW}, 1638fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C16, POS_BELOW}, 1648fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C17, POS_BELOW}, 1658fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C18, POS_BELOW}, 1668fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C19, POS_BELOW}, 1678fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C1A, POS_BELOW}, 1688fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C1B, POS_BELOW}, 1698fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C1C, POS_BELOW}, 1708fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C1D, POS_BELOW}, 1718fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C1E, POS_BELOW}, 1728fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C1F, POS_BELOW}, 1738fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C20, POS_BELOW}, 1748fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C21, POS_BELOW}, 1758fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C22, POS_BELOW}, 1768fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C23, POS_BELOW}, 1778fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C24, POS_BELOW}, 1788fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C25, POS_BELOW}, 1798fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C26, POS_BELOW}, 1808fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C27, POS_BELOW}, 1818fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C28, POS_BELOW}, 1828fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C2A, POS_BELOW}, 1838fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C2B, POS_BELOW}, 1848fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C2C, POS_BELOW}, 1858fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C2D, POS_BELOW}, 1868fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C2E, POS_BELOW}, 1878fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C2F, POS_BELOW}, 1888fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C30, POS_BELOW}, 1898fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C32, POS_BELOW}, 1908fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C33, POS_BELOW}, 1918fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C35, POS_BELOW}, 1928fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C36, POS_BELOW}, 1938fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C37, POS_BELOW}, 1948fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C38, POS_BELOW}, 1958fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C39, POS_BELOW}, 1968fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C95, POS_BELOW}, 1978fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C96, POS_BELOW}, 1988fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C97, POS_BELOW}, 1998fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C98, POS_BELOW}, 2008fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C99, POS_BELOW}, 2018fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C9A, POS_BELOW}, 2028fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C9B, POS_BELOW}, 2038fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C9C, POS_BELOW}, 2048fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C9D, POS_BELOW}, 2058fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C9E, POS_BELOW}, 2068fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0C9F, POS_BELOW}, 2078fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CA0, POS_BELOW}, 2088fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CA1, POS_BELOW}, 2098fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CA2, POS_BELOW}, 2108fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CA3, POS_BELOW}, 2118fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CA4, POS_BELOW}, 2128fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CA5, POS_BELOW}, 2138fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CA6, POS_BELOW}, 2148fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CA7, POS_BELOW}, 2158fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CA8, POS_BELOW}, 2168fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CAA, POS_BELOW}, 2178fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CAB, POS_BELOW}, 2188fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CAC, POS_BELOW}, 2198fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CAD, POS_BELOW}, 2208fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CAE, POS_BELOW}, 2218fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CAF, POS_BELOW}, 2228fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CB0, POS_BELOW}, 2238fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CB2, POS_BELOW}, 2248fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CB3, POS_BELOW}, 2258fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CB5, POS_BELOW}, 2268fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CB6, POS_BELOW}, 2278fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CB7, POS_BELOW}, 2288fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CB8, POS_BELOW}, 2298fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CB9, POS_BELOW}, 2308fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0CDE, POS_BELOW}, 2318fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0D2F, POS_POST}, 2328fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0D30, POS_POST}, 2338fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0D32, POS_BELOW}, 2348fdba506f0f1c66b50f8f4b114d624cb956d03b7Behdad Esfahbod {0x0D35, POS_POST}, 23565988a145b4a52c37fd53c1473034f9e701f61d9Behdad Esfahbod}; 23665988a145b4a52c37fd53c1473034f9e701f61d9Behdad Esfahbod 237352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod/* XXX 238352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod * This is a hack for now. We should move this data into the main Indic table. 239352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod */ 240352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbodstatic const hb_codepoint_t ra_chars[] = { 241352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod 0x0930, /* Devanagari */ 242352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod 0x09B0, /* Bengali */ 243352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod 0x09F0, /* Bengali */ 2448354e004e553856d7d743e0f0b4de4668484026aBehdad Esfahbod//0x09F1, /* Bengali */ 245352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod//0x0A30, /* Gurmukhi */ 246352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod 0x0AB0, /* Gujarati */ 247352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod 0x0B30, /* Oriya */ 248352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod//0x0BB0, /* Tamil */ 249352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod//0x0C30, /* Telugu */ 250352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod 0x0CB0, /* Kannada */ 251352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod//0x0D30, /* Malayalam */ 252352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod}; 253352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod 254743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodstatic int 255743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodcompare_codepoint (const void *pa, const void *pb) 256743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod{ 257743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod hb_codepoint_t a = * (hb_codepoint_t *) pa; 258743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod hb_codepoint_t b = * (hb_codepoint_t *) pb; 259743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 260743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod return a < b ? -1 : a == b ? 0 : +1; 261743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod} 262743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 263743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodstatic indic_position_t 264743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodconsonant_position (hb_codepoint_t u) 265743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod{ 266743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod consonant_position_t *record; 267743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 268743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod record = (consonant_position_t *) bsearch (&u, consonant_positions, 269743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod ARRAY_LENGTH (consonant_positions), 270743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod sizeof (consonant_positions[0]), 271743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod compare_codepoint); 272743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 273743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod return record ? record->position : POS_BASE; 274743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod} 275743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 276352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbodstatic bool 277352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbodis_ra (hb_codepoint_t u) 278352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod{ 279352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod return !!bsearch (&u, ra_chars, 280352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod ARRAY_LENGTH (ra_chars), 281352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod sizeof (ra_chars[0]), 282352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod compare_codepoint); 283352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod} 284352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod 2859ee27a928a989c71923cef82a9e9828f8e9ca051Behdad Esfahbodstatic bool 2869ee27a928a989c71923cef82a9e9828f8e9ca051Behdad Esfahbodis_joiner (hb_glyph_info_t *info) 2879ee27a928a989c71923cef82a9e9828f8e9ca051Behdad Esfahbod{ 2889ee27a928a989c71923cef82a9e9828f8e9ca051Behdad Esfahbod return info->indic_category() == OT_ZWJ || info->indic_category() == OT_ZWNJ; 2899ee27a928a989c71923cef82a9e9828f8e9ca051Behdad Esfahbod} 290c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod 291c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbodstatic const struct { 292c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod hb_tag_t tag; 293c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod hb_bool_t is_global; 294c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod} indic_basic_features[] = 295b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod{ 296c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod {HB_TAG('n','u','k','t'), true}, 297c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod {HB_TAG('a','k','h','n'), false}, 298c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod {HB_TAG('r','p','h','f'), false}, 299c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod {HB_TAG('r','k','r','f'), false}, 300c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod {HB_TAG('p','r','e','f'), false}, 301c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod {HB_TAG('b','l','w','f'), false}, 302c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod {HB_TAG('h','a','l','f'), false}, 303c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod {HB_TAG('v','a','t','u'), true}, 304c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod {HB_TAG('p','s','t','f'), false}, 305c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod {HB_TAG('c','j','c','t'), true}, 306c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod}; 307c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod 308c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod/* Same order as the indic_basic_features array */ 309c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbodenum { 310c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod _NUKT, 311c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod AKHN, 312c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod RPHF, 313c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod RKRF, 314c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod PREF, 315c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod BLWF, 316c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod HALF, 317c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod _VATU, 318c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod PSTF, 319c7fe56a1d5d3e969b6ec51cd9ecd471706a19568Behdad Esfahbod _CJCT, 320b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod}; 321b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 322b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbodstatic const hb_tag_t indic_other_features[] = 323b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod{ 324b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod HB_TAG('p','r','e','s'), 325b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod HB_TAG('a','b','v','s'), 326b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod HB_TAG('b','l','w','s'), 327b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod HB_TAG('p','s','t','s'), 328b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod HB_TAG('h','a','l','n'), 329b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 330b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod HB_TAG('d','i','s','t'), 331b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod HB_TAG('a','b','v','m'), 332b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod HB_TAG('b','l','w','m'), 333b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod}; 334b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 335743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 336743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodstatic void 337743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodinitial_reordering (const hb_ot_map_t *map, 338743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod hb_face_t *face, 339743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod hb_buffer_t *buffer, 340743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod void *user_data HB_UNUSED); 341f6fd3780e12b23ff7ed3743497c8996e71dcb064Behdad Esfahbodstatic void 342f6fd3780e12b23ff7ed3743497c8996e71dcb064Behdad Esfahbodfinal_reordering (const hb_ot_map_t *map, 343f6fd3780e12b23ff7ed3743497c8996e71dcb064Behdad Esfahbod hb_face_t *face, 344f6fd3780e12b23ff7ed3743497c8996e71dcb064Behdad Esfahbod hb_buffer_t *buffer, 345743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod void *user_data HB_UNUSED); 346b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 347b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbodvoid 34876f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod_hb_ot_shape_complex_collect_features_indic (hb_ot_map_builder_t *map, const hb_segment_properties_t *props) 349b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod{ 350f6fd3780e12b23ff7ed3743497c8996e71dcb064Behdad Esfahbod map->add_bool_feature (HB_TAG('l','o','c','l')); 351a54a5505a35eef5315a8e2e7a79502901e3eff5fBehdad Esfahbod /* The Indic specs do not require ccmp, but we apply it here since if 352a54a5505a35eef5315a8e2e7a79502901e3eff5fBehdad Esfahbod * there is a use of it, it's typically at the beginning. */ 353f6fd3780e12b23ff7ed3743497c8996e71dcb064Behdad Esfahbod map->add_bool_feature (HB_TAG('c','c','m','p')); 354f6fd3780e12b23ff7ed3743497c8996e71dcb064Behdad Esfahbod 355743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod map->add_gsub_pause (initial_reordering, NULL); 356f6fd3780e12b23ff7ed3743497c8996e71dcb064Behdad Esfahbod 357b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod for (unsigned int i = 0; i < ARRAY_LENGTH (indic_basic_features); i++) 35876f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod map->add_bool_feature (indic_basic_features[i].tag, indic_basic_features[i].is_global); 359b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 360f6fd3780e12b23ff7ed3743497c8996e71dcb064Behdad Esfahbod map->add_gsub_pause (final_reordering, NULL); 361f6fd3780e12b23ff7ed3743497c8996e71dcb064Behdad Esfahbod 362b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod for (unsigned int i = 0; i < ARRAY_LENGTH (indic_other_features); i++) 36376f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod map->add_bool_feature (indic_other_features[i], true); 364b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod} 365b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 366867361c3ad39629a8d5b7dc48d558a1c19e37d43Behdad Esfahbod 36702cdf743c2ec345a44d4fcf865594b6ac13fccd0Behdad Esfahbodbool 36802cdf743c2ec345a44d4fcf865594b6ac13fccd0Behdad Esfahbod_hb_ot_shape_complex_prefer_decomposed_indic (void) 36902cdf743c2ec345a44d4fcf865594b6ac13fccd0Behdad Esfahbod{ 37002cdf743c2ec345a44d4fcf865594b6ac13fccd0Behdad Esfahbod /* We want split matras decomposed by the common shaping logic. */ 37102cdf743c2ec345a44d4fcf865594b6ac13fccd0Behdad Esfahbod return TRUE; 37202cdf743c2ec345a44d4fcf865594b6ac13fccd0Behdad Esfahbod} 37302cdf743c2ec345a44d4fcf865594b6ac13fccd0Behdad Esfahbod 374867361c3ad39629a8d5b7dc48d558a1c19e37d43Behdad Esfahbod 375b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbodvoid 37676f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod_hb_ot_shape_complex_setup_masks_indic (hb_ot_map_t *map, hb_buffer_t *buffer) 377b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod{ 3789f9bcceca6321d5a5812f878de1de39901349a78Behdad Esfahbod HB_BUFFER_ALLOCATE_VAR (buffer, indic_category); 3799f9bcceca6321d5a5812f878de1de39901349a78Behdad Esfahbod HB_BUFFER_ALLOCATE_VAR (buffer, indic_position); 3809f9bcceca6321d5a5812f878de1de39901349a78Behdad Esfahbod 381743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* We cannot setup masks here. We save information about characters 382743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * and setup masks later on in a pause-callback. */ 383743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 384743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod unsigned int count = buffer->len; 385b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod for (unsigned int i = 0; i < count; i++) 386b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod { 38776f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod unsigned int type = get_indic_categories (buffer->info[i].codepoint); 388b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 38976f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod buffer->info[i].indic_category() = type & 0x0F; 39076f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod buffer->info[i].indic_position() = type >> 4; 391743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 392352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod if (buffer->info[i].indic_category() == OT_C) { 393743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod buffer->info[i].indic_position() = consonant_position (buffer->info[i].codepoint); 394352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod if (is_ra (buffer->info[i].codepoint)) 395352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod buffer->info[i].indic_category() = OT_Ra; 396352372ae5ea0998e40cf9fe43c22b6b610a5764eBehdad Esfahbod } 397b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod } 398743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod} 399b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 40045d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbodstatic int 40145d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbodcompare_indic_order (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb) 40245d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod{ 40345d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod int a = pa->indic_position(); 40445d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod int b = pb->indic_position(); 40545d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod 40645d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod return a < b ? -1 : a == b ? 0 : +1; 40745d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod} 408867361c3ad39629a8d5b7dc48d558a1c19e37d43Behdad Esfahbod 409743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodstatic void 410743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodfound_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array, 411743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod unsigned int start, unsigned int end) 412743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod{ 413743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod unsigned int i; 414ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod hb_glyph_info_t *info = buffer->info; 415743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 416743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* Comments from: 417743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx */ 418743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 419743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* 1. Find base consonant: 420743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * 421743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * The shaping engine finds the base consonant of the syllable, using the 422743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * following algorithm: starting from the end of the syllable, move backwards 423743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * until a consonant is found that does not have a below-base or post-base 424743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * form (post-base forms have to follow below-base forms), or that is not a 425743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * pre-base reordering Ra, or arrive at the first consonant. The consonant 426743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * stopped at will be the base. 427743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * 428743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * o If the syllable starts with Ra + Halant (in a script that has Reph) 429743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * and has more than one consonant, Ra is excluded from candidates for 430743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * base consonants. 431743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod */ 432743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 433743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod unsigned int base = 0; 434743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 435743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* -> starting from the end of the syllable, move backwards */ 436743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod i = end; 437743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod do { 438743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod i--; 439743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* -> until a consonant is found */ 440ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod if (info[i].indic_category() == OT_C) 441ba7e85c104e68b4685c1b3b5c9a260fe0f6879dfBehdad Esfahbod //if ((FLAG (info[i].indic_category()) & (FLAG (OT_C) | FLAG (OT_Ra)))) 442743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod { 443743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* -> that does not have a below-base or post-base form 444743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * (post-base forms have to follow below-base forms), */ 445ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod if (info[i].indic_position() != POS_BELOW && 446ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod info[i].indic_position() != POS_POST) 447743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod { 448743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod base = i; 449743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod break; 450743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod } 451743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 452743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* TODO: or that is not a pre-base reordering Ra, */ 453743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 454743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* -> or arrive at the first consonant. The consonant stopped at will be the base. */ 455743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod base = i; 456743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod } 457743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod } while (i > start); 458743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod if (base < start) 459743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod base = start; /* Just in case... */ 460743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 461743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* TODO 462743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * If the syllable starts with Ra + Halant (in a script that has Reph) 463743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * and has more than one consonant, Ra is excluded from candidates for 464743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * base consonants. */ 465743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 466743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 467743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* 2. Decompose and reorder Matras: 468743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * 469743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * Each matra and any syllable modifier sign in the cluster are moved to the 470743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * appropriate position relative to the consonant(s) in the cluster. The 471743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * shaping engine decomposes two- or three-part matras into their constituent 472743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * parts before any repositioning. Matra characters are classified by which 473743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * consonant in a conjunct they have affinity for and are reordered to the 474743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * following positions: 475743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * 476743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * o Before first half form in the syllable 477743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * o After subjoined consonants 478743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * o After post-form consonant 479743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * o After main consonant (for above marks) 480743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * 481743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * IMPLEMENTATION NOTES: 482743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * 483743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * The normalize() routine has already decomposed matras for us, so we don't 484743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * need to worry about that. 485743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod */ 486743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 487743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 488743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* 3. Reorder marks to canonical order: 489743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * 490743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * Adjacent nukta and halant or nukta and vedic sign are always repositioned 491743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * if necessary, so that the nukta is first. 492743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * 493743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * IMPLEMENTATION NOTES: 494743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * 495743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * We don't need to do this: the normalize() routine already did this for us. 496743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod */ 497743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 498743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 49945d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod /* Reorder characters */ 50045d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod 50145d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod for (i = start; i < base; i++) 502ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod info[i].indic_position() = POS_PRE; 503ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod info[base].indic_position() = POS_BASE; 50445d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod 505fd06bf56110e73826b3d5c73ac964e2609450d46Behdad Esfahbod 506fd06bf56110e73826b3d5c73ac964e2609450d46Behdad Esfahbod /* Handle beginning Ra */ 507fd06bf56110e73826b3d5c73ac964e2609450d46Behdad Esfahbod if (start + 2 <= end && 508fd06bf56110e73826b3d5c73ac964e2609450d46Behdad Esfahbod info[start].indic_category() == OT_Ra && 5099ee27a928a989c71923cef82a9e9828f8e9ca051Behdad Esfahbod info[start + 1].indic_category() == OT_H && 5109ee27a928a989c71923cef82a9e9828f8e9ca051Behdad Esfahbod (start + 2 == end || !is_joiner (&info[start]))) 511fd06bf56110e73826b3d5c73ac964e2609450d46Behdad Esfahbod { 512fd06bf56110e73826b3d5c73ac964e2609450d46Behdad Esfahbod info[start].indic_position() = POS_POST; 513fd06bf56110e73826b3d5c73ac964e2609450d46Behdad Esfahbod info[start].mask = mask_array[RPHF]; 514fd06bf56110e73826b3d5c73ac964e2609450d46Behdad Esfahbod } 515fd06bf56110e73826b3d5c73ac964e2609450d46Behdad Esfahbod 516f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod /* For old-style Indic script tags, move the first post-base Halant after 517f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod * last consonant. */ 518f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod if ((map->get_chosen_script (0) & 0x000000FF) != '2') { 519f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod /* We should only do this for Indic scripts which have a version two I guess. */ 520f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod for (i = base + 1; i < end; i++) 521f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod if (info[i].indic_category() == OT_H) { 522f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod unsigned int j; 523f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod for (j = end - 1; j > i; j--) 524f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod if ((FLAG (info[j].indic_category()) & (FLAG (OT_C) | FLAG (OT_Ra)))) 525f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod break; 526f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod if (j > i) { 527f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod /* Move Halant to after last consonant. */ 528f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod hb_glyph_info_t t = info[i]; 529f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod memmove (&info[i], &info[i + 1], (j - i) * sizeof (info[0])); 530f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod info[j] = t; 531f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod } 532f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod break; 533f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod } 534f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod } 535f5bc2725cb892264ba223e0a49f7fd2c622a0730Behdad Esfahbod 53645d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod /* Attach ZWJ, ZWNJ, nukta, and halant to previous char to move with them. */ 53745d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod for (i = start + 1; i < end; i++) 538ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod if ((FLAG (info[i].indic_category()) & 53945d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod (FLAG (OT_ZWNJ) | FLAG (OT_ZWJ) | FLAG (OT_N) | FLAG (OT_H)))) 540ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod info[i].indic_position() = info[i - 1].indic_position(); 54145d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod 54245d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod /* We do bubble-sort, skip malicious clusters attempts */ 54345d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod if (end - start > 20) 54445d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod return; 54545d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod 54645d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod /* Sit tight, rock 'n roll! */ 547ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod hb_bubble_sort (info + start, end - start, compare_indic_order); 54845d6f29f15f1d2323bcaa2498aed23ff0c8a1567Behdad Esfahbod 549743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* Setup masks now */ 550743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 551743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* Pre-base */ 552743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod for (i = start; i < base; i++) 553ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod info[i].mask |= mask_array[HALF] | mask_array[AKHN]; 554743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* Base */ 555ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod info[base].mask |= mask_array[AKHN]; 556743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* Post-base */ 557743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod for (i = base + 1; i < end; i++) 558ee58f3bc75d2d071a71b94063bf12205a5871acbBehdad Esfahbod info[i].mask |= mask_array[BLWF] | mask_array[PSTF]; 559743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod} 560743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 561743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 562743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodstatic void 563743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodfound_vowel_syllable (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array, 564743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod unsigned int start, unsigned int end) 565743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod{ 566743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* TODO 567743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * Not clear to me how this should work. Do the matras move to before the 568743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * independent vowel? No idea. 569743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod */ 570743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod} 571743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 572743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodstatic void 573743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodfound_standalone_cluster (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array, 574743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod unsigned int start, unsigned int end) 575743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod{ 576743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* TODO 577743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * Easiest thing to do here is to convert the NBSP to consonant and 578743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * call found_consonant_syllable. 579743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod */ 580743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod} 581743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 582743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodstatic void 583743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodfound_non_indic (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array, 584743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod unsigned int start, unsigned int end) 585743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod{ 586743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod /* Nothing to do right now. If we ever switch to using the output 587743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod * buffer in the reordering process, we'd need to next_glyph() here. */ 588743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod} 589743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 590743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod#include "hb-ot-shape-complex-indic-machine.hh" 591743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 592743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodstatic void 593743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodinitial_reordering (const hb_ot_map_t *map, 594743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod hb_face_t *face, 595743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod hb_buffer_t *buffer, 596743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod void *user_data HB_UNUSED) 597743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod{ 598b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod hb_mask_t mask_array[ARRAY_LENGTH (indic_basic_features)] = {0}; 599b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod unsigned int num_masks = ARRAY_LENGTH (indic_basic_features); 600b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod for (unsigned int i = 0; i < num_masks; i++) 60176f76812ac7cca8ac6935952a2360d5e151480faBehdad Esfahbod mask_array[i] = map->get_1_mask (indic_basic_features[i].tag); 602743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 603743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod find_syllables (map, buffer, mask_array); 604b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod} 605b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 606743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodstatic void 607743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbodfinal_reordering (const hb_ot_map_t *map, 608743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod hb_face_t *face, 609743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod hb_buffer_t *buffer, 610743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod void *user_data HB_UNUSED) 611743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod{ 612743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod HB_BUFFER_DEALLOCATE_VAR (buffer, indic_category); 613743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod HB_BUFFER_DEALLOCATE_VAR (buffer, indic_position); 614743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod} 615743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 616743807a3ce1b2229e5307a8aea074a7544623d8dBehdad Esfahbod 617b9ddbd55930228422e82b34a141ad1b6093f5376Behdad Esfahbod 618b9ddbd55930228422e82b34a141ad1b6093f5376Behdad EsfahbodHB_END_DECLS 619