hb-ot-shape-complex-indic-private.hh revision 3c7b3641cfb00f2c4dcc0768b9854e4f4410d15f
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#include "hb-ot-shape-private.hh" /* XXX Remove */
35
36
37#define INDIC_TABLE_ELEMENT_TYPE uint16_t
38
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,
46  OT_C,
47  OT_V,
48  OT_N,
49  OT_H,
50  OT_ZWNJ,
51  OT_ZWJ,
52  OT_M,
53  OT_SM,
54  OT_VD,
55  OT_A,
56  OT_NBSP,
57  OT_DOTTEDCIRCLE, /* Not in the spec, but special in Uniscribe. /Very very/ special! */
58  OT_RS, /* Register Shifter, used in Khmer OT spec */
59  OT_Coeng,
60  OT_Repha,
61  OT_Ra, /* Not explicitly listed in the OT spec, but used in the grammar. */
62  OT_CM,
63  OT_Avag
64};
65
66/* Visual positions in a syllable from left to right. */
67enum indic_position_t {
68  POS_START,
69
70  POS_RA_TO_BECOME_REPH,
71  POS_PRE_M,
72  POS_PRE_C,
73
74  POS_BASE_C,
75  POS_AFTER_MAIN,
76
77  POS_ABOVE_C,
78
79  POS_BEFORE_SUB,
80  POS_BELOW_C,
81  POS_AFTER_SUB,
82
83  POS_BEFORE_POST,
84  POS_POST_C,
85  POS_AFTER_POST,
86
87  POS_FINAL_C,
88  POS_SMVD,
89
90  POS_END
91};
92
93/* Categories used in IndicSyllabicCategory.txt from UCD. */
94enum indic_syllabic_category_t {
95  INDIC_SYLLABIC_CATEGORY_OTHER			= OT_X,
96
97  INDIC_SYLLABIC_CATEGORY_AVAGRAHA		= OT_Avag,
98  INDIC_SYLLABIC_CATEGORY_BINDU			= OT_SM,
99  INDIC_SYLLABIC_CATEGORY_CONSONANT		= OT_C,
100  INDIC_SYLLABIC_CATEGORY_CONSONANT_DEAD	= OT_C,
101  INDIC_SYLLABIC_CATEGORY_CONSONANT_FINAL	= OT_CM,
102  INDIC_SYLLABIC_CATEGORY_CONSONANT_HEAD_LETTER	= OT_C,
103  INDIC_SYLLABIC_CATEGORY_CONSONANT_MEDIAL	= OT_CM,
104  INDIC_SYLLABIC_CATEGORY_CONSONANT_PLACEHOLDER	= OT_NBSP,
105  INDIC_SYLLABIC_CATEGORY_CONSONANT_SUBJOINED	= OT_C,
106  INDIC_SYLLABIC_CATEGORY_CONSONANT_REPHA	= OT_Repha,
107  INDIC_SYLLABIC_CATEGORY_MODIFYING_LETTER	= OT_X,
108  INDIC_SYLLABIC_CATEGORY_NUKTA			= OT_N,
109  INDIC_SYLLABIC_CATEGORY_REGISTER_SHIFTER	= OT_RS,
110  INDIC_SYLLABIC_CATEGORY_TONE_LETTER		= OT_X,
111  INDIC_SYLLABIC_CATEGORY_TONE_MARK		= OT_N,
112  INDIC_SYLLABIC_CATEGORY_VIRAMA		= OT_H,
113  INDIC_SYLLABIC_CATEGORY_VISARGA		= OT_SM,
114  INDIC_SYLLABIC_CATEGORY_VOWEL			= OT_V,
115  INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT	= OT_M,
116  INDIC_SYLLABIC_CATEGORY_VOWEL_INDEPENDENT	= OT_V
117};
118
119/* Categories used in IndicSMatraCategory.txt from UCD */
120enum indic_matra_category_t {
121  INDIC_MATRA_CATEGORY_NOT_APPLICABLE		= POS_END,
122
123  INDIC_MATRA_CATEGORY_LEFT			= POS_PRE_C,
124  INDIC_MATRA_CATEGORY_TOP			= POS_ABOVE_C,
125  INDIC_MATRA_CATEGORY_BOTTOM			= POS_BELOW_C,
126  INDIC_MATRA_CATEGORY_RIGHT			= POS_POST_C,
127
128  /* These should resolve to the position of the last part of the split sequence. */
129  INDIC_MATRA_CATEGORY_BOTTOM_AND_RIGHT		= INDIC_MATRA_CATEGORY_RIGHT,
130  INDIC_MATRA_CATEGORY_LEFT_AND_RIGHT		= INDIC_MATRA_CATEGORY_RIGHT,
131  INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM		= INDIC_MATRA_CATEGORY_BOTTOM,
132  INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM_AND_RIGHT	= INDIC_MATRA_CATEGORY_RIGHT,
133  INDIC_MATRA_CATEGORY_TOP_AND_LEFT		= INDIC_MATRA_CATEGORY_TOP,
134  INDIC_MATRA_CATEGORY_TOP_AND_LEFT_AND_RIGHT	= INDIC_MATRA_CATEGORY_RIGHT,
135  INDIC_MATRA_CATEGORY_TOP_AND_RIGHT		= INDIC_MATRA_CATEGORY_RIGHT,
136
137  INDIC_MATRA_CATEGORY_INVISIBLE		= INDIC_MATRA_CATEGORY_NOT_APPLICABLE,
138  INDIC_MATRA_CATEGORY_OVERSTRUCK		= POS_AFTER_MAIN,
139  INDIC_MATRA_CATEGORY_VISUAL_ORDER_LEFT	= POS_PRE_M
140};
141
142/* Note: We use ASSERT_STATIC_EXPR_ZERO() instead of ASSERT_STATIC_EXPR() and the comma operation
143 * because gcc fails to optimize the latter and fills the table in at runtime. */
144#define INDIC_COMBINE_CATEGORIES(S,M) \
145  (ASSERT_STATIC_EXPR_ZERO (M == INDIC_MATRA_CATEGORY_NOT_APPLICABLE || (S == INDIC_SYLLABIC_CATEGORY_VIRAMA || S == INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT)) + \
146   ASSERT_STATIC_EXPR_ZERO (S < 255 && M < 255) + \
147   ((M << 8) | S))
148
149HB_INTERNAL INDIC_TABLE_ELEMENT_TYPE
150hb_indic_get_categories (hb_codepoint_t u);
151
152#endif /* HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH */
153