Git init
[external/pango1.0.git] / modules / indic / indic-ot.h
1 /* Pango
2  * indic-ot.h:
3  *
4  * Copyright (C) 2001, 2002 IBM Corporation. All Rights Reserved.
5  * Author: Eric Mader <mader@jtcsv.com>
6  *
7  * Permission is hereby granted, free of charge, to any person
8  * obtaining a copy of this software and associated documentation
9  * files (the "Software"), to deal in the Software without
10  * restriction, including without limitation the rights to use, copy,
11  * modify, merge, publish, distribute, and/or sell copies of the
12  * Software, and to permit persons to whom the Software is furnished
13  * to do so, provided that the above copyright notice(s) and this
14  * permission notice appear in all copies of the Software and that
15  * both the above copyright notice(s) and this permission notice
16  * appear in supporting documentation.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE
22  * COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR
23  * ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY
24  * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
25  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
26  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
27  * OF THIS SOFTWARE.
28  *
29  * Except as contained in this notice, the name of a copyright holder
30  * shall not be used in advertising or otherwise to promote the sale,
31  * use or other dealings in this Software without prior written
32  * authorization of the copyright holder.
33  */
34
35 #ifndef __INDIC_OT_H__
36 #define __INDIC_OT_H__
37
38 #include <pango/pango-glyph.h>
39 #include <pango/pango-types.h>
40 #include "mprefixups.h"
41
42 G_BEGIN_DECLS
43
44 #ifdef PANGO_ENABLE_ENGINE
45
46 /* Characters that get refered to by name... */
47 #define C_SIGN_ZWNJ     0x200C
48 #define C_SIGN_ZWJ      0x200D
49 #define C_DOTTED_CIRCLE 0x25CC
50
51 /*
52  * The characters that a split matra splits into.
53  * Unused characters will be zero.
54  */
55 typedef gunichar IndicOTSplitMatra[3];
56
57 /*
58  * Character class values
59  */
60 typedef enum
61 {
62   CC_RESERVED,
63   CC_MODIFYING_MARK_ABOVE,
64   CC_MODIFYING_MARK_POST,
65   CC_INDEPENDENT_VOWEL,
66   CC_CONSONANT,
67   CC_CONSONANT_WITH_NUKTA,
68   CC_NUKTA,
69   CC_DEPENDENT_VOWEL,
70   CC_VIRAMA,
71   CC_ZERO_WIDTH_MARK,
72   CC_AL_LAKUNA,
73   CC_COUNT
74 } IndicOTCharClassValues;
75
76 /*
77  * Character class flags
78  */
79 #define CF_CLASS_MASK   0x0000FFFFU
80
81 #define CF_CONSONANT    0x80000000U
82
83 #define CF_REPH         0x40000000U
84 #define CF_VATTU        0x20000000U
85 #define CF_BELOW_BASE   0x10000000U
86 #define CF_POST_BASE    0x08000000U
87
88 #define CF_MATRA_PRE    0x04000000U
89 #define CF_MATRA_BELOW  0x02000000U
90 #define CF_MATRA_ABOVE  0x01000000U
91 #define CF_MATRA_POST   0x00800000U
92 #define CF_LENGTH_MARK  0x00400000U
93
94 #define CF_INDEX_MASK   0x000F0000U
95 #define CF_INDEX_SHIFT  16
96
97 /*
98  * Character class: a character class value
99  * ORed with character class flags.
100  */
101 typedef glong IndicOTCharClass;
102
103 /*
104  * Script flags
105  */
106 #define SF_MATRAS_AFTER_BASE    0x80000000U
107 #define SF_REPH_AFTER_BELOW     0x40000000U
108 #define SF_EYELASH_RA           0x20000000U
109 #define SF_MPRE_FIXUP           0x10000000U
110 #define SF_PROCESS_ZWJ          0x08000000U
111
112 #define SF_POST_BASE_LIMIT_MASK 0x0000FFFFU
113 #define SF_NO_POST_BASE_LIMIT   0x00007FFFU
114
115 typedef guint32 IndicOTScriptFlags;
116
117 /*
118  * Bit flags for the indic feature tags
119  */
120 enum indic_glyph_feature_
121 {
122   nukt = 0x0001,
123   akhn = 0x0002,
124   rphf = 0x0004,
125   blwf = 0x0008,
126   half = 0x0010,
127   pstf = 0x0020,
128   vatu = 0x0040,
129   pres = 0x0080,
130   blws = 0x0100,
131   abvs = 0x0200,
132   psts = 0x0400,
133   haln = 0x0800,
134   blwm = 0x1000,
135   abvm = 0x2000,
136   dist = 0x4000,
137   junk = 0x8000,
138   init = 0x10000
139 };
140
141 /*
142  * Complement of the feature flags that
143  * will be assigned to specific glyphs.
144  *
145  * The names come from the ICU implementation,
146  * which listed the actual tags in an order
147  * such that tags could be assigned using the
148  * address of the first one: &tags[0], &tags[1],
149  * &tags[2], &tags[3]. The name of each set here
150  * is the name of the first tag in the ICU list.
151  */
152 enum indic_glyph_property_
153 {
154   rphf_p = (junk | dist | init),
155   blwf_p = (junk | dist | init | rphf),
156   half_p = (junk | dist | init | rphf | blwf),
157   pstf_p = (junk | dist | init | rphf | blwf | half),
158   nukt_p = (junk | dist | init | rphf | blwf | half | pstf)
159 };
160
161 /*
162  * Macros to test the charClass flags for various things.
163  */
164 #define IS_VM_ABOVE(charClass) ((charClass & CF_CLASS_MASK) == CC_MODIFYING_MARK_ABOVE)
165 #define IS_VM_POST(charClass) ((charClass & CF_CLASS_MASK) == CC_MODIFYING_MARK_POST)
166 #define IS_CONSONANT(charClass) ((charClass & CF_CONSONANT) != 0)
167 #define IS_REPH(charClass) ((charClass & CF_REPH) != 0)
168 #define IS_NUKTA(charClass) ((charClass & CF_CLASS_MASK) == CC_NUKTA)
169 #define IS_VIRAMA(charClass) ((charClass & CF_CLASS_MASK) == CC_VIRAMA)
170 #define IS_AL_LAKUNA(charClass) ((charClass & CF_CLASS_MASK) == CC_AL_LAKUNA)
171 #define IS_VATTU(charClass) ((charClass & CF_VATTU) != 0)
172 #define IS_MATRA(charClass) ((charClass & CF_CLASS_MASK) == CC_DEPENDENT_VOWEL)
173 #define IS_SPLIT_MATRA(charClass) ((charClass & CF_INDEX_MASK) != 0)
174 #define IS_M_PRE(charClass) ((charClass & CF_MATRA_PRE) != 0)
175 #define IS_M_BELOW(charClass) ((charClass & CF_MATRA_BELOW) != 0)
176 #define IS_M_ABOVE(charClass) ((charClass & CF_MATRA_ABOVE) != 0)
177 #define IS_M_POST(charClass) ((charClass & CF_MATRA_POST) != 0)
178 #define IS_LENGTH_MARK(charClass) ((charClass & CF_LENGTH_MARK) != 0)
179 #define HAS_POST_OR_BELOW_BASE_FORM(charClass) ((charClass & (CF_POST_BASE | CF_BELOW_BASE)) != 0)
180 #define HAS_POST_BASE_FORM(charClass) ((charClass & CF_POST_BASE) != 0)
181 #define HAS_BELOW_BASE_FORM(charClass) ((charClass & CF_BELOW_BASE) != 0)
182
183 struct _IndicOTClassTable
184 {
185   gunichar            firstChar;
186   gunichar            lastChar;
187   glong               worstCaseExpansion;
188   IndicOTScriptFlags  scriptFlags;
189
190   const IndicOTCharClass  *charClasses;
191   const IndicOTSplitMatra *splitMatraTable;
192 };
193
194 typedef struct _IndicOTClassTable IndicOTClassTable;
195
196 extern const IndicOTClassTable deva_class_table;
197 extern const IndicOTClassTable beng_class_table;
198 extern const IndicOTClassTable guru_class_table;
199 extern const IndicOTClassTable gujr_class_table;
200 extern const IndicOTClassTable orya_class_table;
201 extern const IndicOTClassTable taml_class_table;
202 extern const IndicOTClassTable telu_class_table;
203 extern const IndicOTClassTable knda_class_table;
204 extern const IndicOTClassTable mlym_class_table;
205 extern const IndicOTClassTable sinh_class_table;
206
207 const IndicOTSplitMatra *indic_ot_get_split_matra(const IndicOTClassTable *class_table, IndicOTCharClass char_class);
208
209 IndicOTCharClass indic_ot_get_char_class(const IndicOTClassTable *class_table, gunichar ch);
210
211 gboolean indic_ot_is_vm_above(const IndicOTClassTable *class_table, gunichar ch);
212 gboolean indic_ot_is_vm_post(const IndicOTClassTable *class_table, gunichar ch);
213 gboolean indic_ot_is_consonant(const IndicOTClassTable *class_table, gunichar ch);
214 gboolean indic_ot_is_reph(const IndicOTClassTable *class_table, gunichar ch);
215 gboolean indic_ot_is_virama(const IndicOTClassTable *class_table, gunichar ch);
216 gboolean indic_ot_is_al_lakuna(const IndicOTClassTable *class_table, gunichar ch);
217 gboolean indic_ot_is_nukta(const IndicOTClassTable *class_table, gunichar ch);
218 gboolean indic_ot_is_vattu(const IndicOTClassTable *class_table, gunichar ch);
219 gboolean indic_ot_is_matra(const IndicOTClassTable *class_table, gunichar ch);
220 gboolean indic_ot_is_split_matra(const IndicOTClassTable *class_table, gunichar ch);
221 gboolean indic_ot_is_m_pre(const IndicOTClassTable *class_table, gunichar ch);
222 gboolean indic_ot_is_m_below(const IndicOTClassTable *class_table, gunichar ch);
223 gboolean indic_ot_is_m_above(const IndicOTClassTable *class_table, gunichar ch);
224 gboolean indic_ot_is_m_post(const IndicOTClassTable *class_table, gunichar ch);
225 gboolean indic_ot_is_length_mark(const IndicOTClassTable *class_table, gunichar ch);
226 gboolean indic_ot_has_post_or_below_base_form(const IndicOTClassTable *class_table, gunichar ch);
227 gboolean indic_ot_has_post_base_form(const IndicOTClassTable *class_table, gunichar ch);
228 gboolean indic_ot_has_below_base_form(const IndicOTClassTable *class_table, gunichar ch);
229
230 glong indic_ot_find_syllable(const IndicOTClassTable *class_table, const gunichar *chars, glong prev, glong char_count);
231
232 glong indic_ot_reorder(const gunichar *chars, const glong *utf8_offsets, glong char_count, const IndicOTClassTable *class_table, gunichar *out_chars, glong *char_indices, gulong *char_tags, MPreFixups **outMPreFixups);
233
234 #endif /* PANGO_ENABLE_ENGINE */
235
236 G_END_DECLS
237
238 #endif /* __INDIC_OT_H__ */