blob: 3de5c203fa312d81debac162af86476069aaef00 [file] [log] [blame]
Behdad Esfahbod3ed46342012-04-19 22:34:06 -04001/*
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"
Behdad Esfahbod3eb6f812012-08-02 07:37:46 -040034#include "hb-ot-shape-private.hh" /* XXX Remove */
Behdad Esfahbod3ed46342012-04-19 22:34:06 -040035
36
Behdad Esfahboddba18672012-11-12 14:48:33 -080037#define INDIC_TABLE_ELEMENT_TYPE uint16_t
Behdad Esfahbod3ed46342012-04-19 22:34:06 -040038
39/* Cateories used in the OpenType spec:
40 * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx
41 */
42/* Note: This enum is duplicated in the -machine.rl source file.
43 * Not sure how to avoid duplication. */
44enum indic_category_t {
45 OT_X = 0,
Behdad Esfahbodc16012e2013-10-18 02:27:00 +020046 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_NBSP = 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_Avag = 18, /* Avagraha. */
Behdad Esfahbod6e613f32013-10-23 23:34:13 +020064 OT_CM2 = 31 /* Consonant-Medial, second slot. */
Behdad Esfahbod3ed46342012-04-19 22:34:06 -040065};
66
67/* Visual positions in a syllable from left to right. */
68enum indic_position_t {
Behdad Esfahbod81202bd2012-07-20 15:10:02 -040069 POS_START,
70
Behdad Esfahbod3d250792012-05-10 11:37:42 +020071 POS_RA_TO_BECOME_REPH,
Behdad Esfahbod6a091df2012-05-11 21:42:27 +020072 POS_PRE_M,
Behdad Esfahboddbccf872012-05-09 17:24:39 +020073 POS_PRE_C,
Behdad Esfahbodbe8b9f52012-07-19 12:11:12 -040074
Behdad Esfahboddbccf872012-05-09 17:24:39 +020075 POS_BASE_C,
Behdad Esfahbodbe8b9f52012-07-19 12:11:12 -040076 POS_AFTER_MAIN,
77
Behdad Esfahboddbccf872012-05-09 17:24:39 +020078 POS_ABOVE_C,
Behdad Esfahbodbe8b9f52012-07-19 12:11:12 -040079
80 POS_BEFORE_SUB,
Behdad Esfahboddbccf872012-05-09 17:24:39 +020081 POS_BELOW_C,
Behdad Esfahbodbe8b9f52012-07-19 12:11:12 -040082 POS_AFTER_SUB,
83
84 POS_BEFORE_POST,
Behdad Esfahboddbccf872012-05-09 17:24:39 +020085 POS_POST_C,
Behdad Esfahbodbe8b9f52012-07-19 12:11:12 -040086 POS_AFTER_POST,
87
Behdad Esfahbod55f70eb2012-07-17 12:50:13 -040088 POS_FINAL_C,
Behdad Esfahbodbe8b9f52012-07-19 12:11:12 -040089 POS_SMVD,
Behdad Esfahbod81202bd2012-07-20 15:10:02 -040090
Behdad Esfahbodbe8b9f52012-07-19 12:11:12 -040091 POS_END
Behdad Esfahbod3ed46342012-04-19 22:34:06 -040092};
93
Behdad Esfahbodc5306b62012-05-10 12:07:33 +020094/* Categories used in IndicSyllabicCategory.txt from UCD. */
Behdad Esfahbod3ed46342012-04-19 22:34:06 -040095enum indic_syllabic_category_t {
96 INDIC_SYLLABIC_CATEGORY_OTHER = OT_X,
97
Behdad Esfahbod3c7b3642013-10-15 11:21:01 +020098 INDIC_SYLLABIC_CATEGORY_AVAGRAHA = OT_Avag,
Behdad Esfahbod3ed46342012-04-19 22:34:06 -040099 INDIC_SYLLABIC_CATEGORY_BINDU = OT_SM,
100 INDIC_SYLLABIC_CATEGORY_CONSONANT = OT_C,
101 INDIC_SYLLABIC_CATEGORY_CONSONANT_DEAD = OT_C,
Behdad Esfahbod9e1f80a2013-02-12 15:28:21 -0500102 INDIC_SYLLABIC_CATEGORY_CONSONANT_FINAL = OT_CM,
Behdad Esfahbod3ed46342012-04-19 22:34:06 -0400103 INDIC_SYLLABIC_CATEGORY_CONSONANT_HEAD_LETTER = OT_C,
Behdad Esfahbod9cac1332012-11-12 18:41:22 -0800104 INDIC_SYLLABIC_CATEGORY_CONSONANT_MEDIAL = OT_CM,
Behdad Esfahbod3ed46342012-04-19 22:34:06 -0400105 INDIC_SYLLABIC_CATEGORY_CONSONANT_PLACEHOLDER = OT_NBSP,
Behdad Esfahbod3756efa2013-10-16 19:06:29 +0200106 INDIC_SYLLABIC_CATEGORY_CONSONANT_SUBJOINED = OT_CM,
Behdad Esfahboddb8981f2012-07-17 18:17:30 -0400107 INDIC_SYLLABIC_CATEGORY_CONSONANT_REPHA = OT_Repha,
Behdad Esfahbod3ed46342012-04-19 22:34:06 -0400108 INDIC_SYLLABIC_CATEGORY_MODIFYING_LETTER = OT_X,
109 INDIC_SYLLABIC_CATEGORY_NUKTA = OT_N,
Behdad Esfahbod7d09c982012-07-16 16:45:22 -0400110 INDIC_SYLLABIC_CATEGORY_REGISTER_SHIFTER = OT_RS,
Behdad Esfahbod3ed46342012-04-19 22:34:06 -0400111 INDIC_SYLLABIC_CATEGORY_TONE_LETTER = OT_X,
Behdad Esfahbodd1870992012-11-12 18:38:06 -0800112 INDIC_SYLLABIC_CATEGORY_TONE_MARK = OT_N,
Behdad Esfahbod3ed46342012-04-19 22:34:06 -0400113 INDIC_SYLLABIC_CATEGORY_VIRAMA = OT_H,
114 INDIC_SYLLABIC_CATEGORY_VISARGA = OT_SM,
115 INDIC_SYLLABIC_CATEGORY_VOWEL = OT_V,
116 INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT = OT_M,
117 INDIC_SYLLABIC_CATEGORY_VOWEL_INDEPENDENT = OT_V
118};
119
120/* Categories used in IndicSMatraCategory.txt from UCD */
121enum indic_matra_category_t {
Behdad Esfahbod2ec934c2012-07-23 23:49:04 -0400122 INDIC_MATRA_CATEGORY_NOT_APPLICABLE = POS_END,
Behdad Esfahbod3ed46342012-04-19 22:34:06 -0400123
Behdad Esfahbod8bb32452012-07-19 12:59:06 -0400124 INDIC_MATRA_CATEGORY_LEFT = POS_PRE_C,
125 INDIC_MATRA_CATEGORY_TOP = POS_ABOVE_C,
126 INDIC_MATRA_CATEGORY_BOTTOM = POS_BELOW_C,
127 INDIC_MATRA_CATEGORY_RIGHT = POS_POST_C,
Behdad Esfahbod3ed46342012-04-19 22:34:06 -0400128
Behdad Esfahbodf83aaa32012-07-19 12:23:23 -0400129 /* These should resolve to the position of the last part of the split sequence. */
130 INDIC_MATRA_CATEGORY_BOTTOM_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT,
131 INDIC_MATRA_CATEGORY_LEFT_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT,
132 INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM = INDIC_MATRA_CATEGORY_BOTTOM,
133 INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT,
134 INDIC_MATRA_CATEGORY_TOP_AND_LEFT = INDIC_MATRA_CATEGORY_TOP,
135 INDIC_MATRA_CATEGORY_TOP_AND_LEFT_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT,
136 INDIC_MATRA_CATEGORY_TOP_AND_RIGHT = INDIC_MATRA_CATEGORY_RIGHT,
Behdad Esfahbod3ed46342012-04-19 22:34:06 -0400137
138 INDIC_MATRA_CATEGORY_INVISIBLE = INDIC_MATRA_CATEGORY_NOT_APPLICABLE,
Behdad Esfahbode67072b2012-11-14 15:00:53 -0800139 INDIC_MATRA_CATEGORY_OVERSTRUCK = POS_AFTER_MAIN,
140 INDIC_MATRA_CATEGORY_VISUAL_ORDER_LEFT = POS_PRE_M
Behdad Esfahbod3ed46342012-04-19 22:34:06 -0400141};
142
143/* Note: We use ASSERT_STATIC_EXPR_ZERO() instead of ASSERT_STATIC_EXPR() and the comma operation
144 * because gcc fails to optimize the latter and fills the table in at runtime. */
145#define INDIC_COMBINE_CATEGORIES(S,M) \
146 (ASSERT_STATIC_EXPR_ZERO (M == INDIC_MATRA_CATEGORY_NOT_APPLICABLE || (S == INDIC_SYLLABIC_CATEGORY_VIRAMA || S == INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT)) + \
Behdad Esfahboddba18672012-11-12 14:48:33 -0800147 ASSERT_STATIC_EXPR_ZERO (S < 255 && M < 255) + \
148 ((M << 8) | S))
Behdad Esfahbod3ed46342012-04-19 22:34:06 -0400149
Behdad Esfahbod3a83d332013-02-12 12:14:10 -0500150HB_INTERNAL INDIC_TABLE_ELEMENT_TYPE
151hb_indic_get_categories (hb_codepoint_t u);
Behdad Esfahbod3ed46342012-04-19 22:34:06 -0400152
153#endif /* HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH */