2 * Copyright © 2010,2011,2012 Google, Inc.
4 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
24 * Google Author(s): Behdad Esfahbod
27 #ifndef HB_OT_SHAPE_COMPLEX_PRIVATE_HH
28 #define HB_OT_SHAPE_COMPLEX_PRIVATE_HH
30 #include "hb-private.hh"
32 #include "hb-ot-map-private.hh"
33 #include "hb-ot-shape-normalize-private.hh"
37 /* buffer var allocations, used during the entire shaping process */
38 #define unicode_props0() var1.u8[0]
39 #define unicode_props1() var1.u8[1]
41 /* buffer var allocations, used during the GSUB/GPOS processing */
42 #define props_cache() var1.u16[1] /* GSUB/GPOS glyph_props cache */
43 #define syllable() var2.u8[0] /* GSUB/GPOS shaping boundaries */
44 #define lig_props() var2.u8[1] /* GSUB/GPOS ligature tracking */
46 /* buffer var allocations, used by complex shapers */
47 #define complex_var_persistent_u8_0() var2.u8[2]
48 #define complex_var_persistent_u8_1() var2.u8[3]
49 #define complex_var_temporary_u8() var2.u8[0]
52 #define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \
53 HB_COMPLEX_SHAPER_IMPLEMENT (default) /* should be first */ \
54 HB_COMPLEX_SHAPER_IMPLEMENT (arabic) \
55 HB_COMPLEX_SHAPER_IMPLEMENT (hangul) \
56 HB_COMPLEX_SHAPER_IMPLEMENT (indic) \
57 HB_COMPLEX_SHAPER_IMPLEMENT (thai) \
58 /* ^--- Add new shapers here */
60 enum hb_ot_complex_shaper_t {
61 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) hb_ot_complex_shaper_##name,
62 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
63 /* Just here to avoid enum trailing comma: */
64 hb_ot_complex_shaper_generic = hb_ot_complex_shaper_default
65 #undef HB_COMPLEX_SHAPER_IMPLEMENT
68 static inline hb_ot_complex_shaper_t
69 hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
71 switch ((hb_tag_t) props->script)
74 return hb_ot_complex_shaper_default;
77 /* Unicode-1.1 additions */
78 case HB_SCRIPT_ARABIC:
79 case HB_SCRIPT_MONGOLIAN:
80 case HB_SCRIPT_SYRIAC:
82 /* Unicode-5.0 additions */
85 /* Unicode-6.0 additions */
86 case HB_SCRIPT_MANDAIC:
88 return hb_ot_complex_shaper_arabic;
91 /* Unicode-1.1 additions */
92 case HB_SCRIPT_HANGUL:
94 return hb_ot_complex_shaper_hangul;
97 /* Unicode-1.1 additions */
101 return hb_ot_complex_shaper_thai;
105 /* ^--- Add new shapers here */
111 * These disabled scripts are listed in ucd/IndicSyllabicCategory.txt, but according
112 * to Martin Hosken and Jonathan Kew do not require complex shaping.
114 * TODO We should automate figuring out which scripts do not need complex shaping
116 * TODO We currently keep data for these scripts in our indic table. Need to fix the
117 * generator to not do that.
123 /* Unicode-3.2 additions */
124 case HB_SCRIPT_BUHID:
125 case HB_SCRIPT_HANUNOO:
127 /* Unicode-5.1 additions */
128 case HB_SCRIPT_SAURASHTRA:
130 /* Unicode-5.2 additions */
131 case HB_SCRIPT_MEETEI_MAYEK:
133 /* Unicode-6.0 additions */
134 case HB_SCRIPT_BATAK:
135 case HB_SCRIPT_BRAHMI:
140 /* Unicode-1.1 additions */
141 /* These have their own shaper now. */
145 /* Unicode-2.0 additions */
146 case HB_SCRIPT_TIBETAN:
148 /* Unicode-3.2 additions */
149 case HB_SCRIPT_TAGALOG:
150 case HB_SCRIPT_TAGBANWA:
152 /* Unicode-4.0 additions */
153 case HB_SCRIPT_LIMBU:
154 case HB_SCRIPT_TAI_LE:
156 /* Unicode-4.1 additions */
157 case HB_SCRIPT_SYLOTI_NAGRI:
159 /* Unicode-5.0 additions */
160 case HB_SCRIPT_PHAGS_PA:
162 /* Unicode-5.1 additions */
163 case HB_SCRIPT_KAYAH_LI:
165 /* Unicode-5.2 additions */
166 case HB_SCRIPT_TAI_VIET:
169 /* May need Indic treatment in the future? */
171 /* Unicode-3.0 additions */
172 case HB_SCRIPT_MYANMAR:
177 /* Unicode-1.1 additions */
178 case HB_SCRIPT_BENGALI:
179 case HB_SCRIPT_DEVANAGARI:
180 case HB_SCRIPT_GUJARATI:
181 case HB_SCRIPT_GURMUKHI:
182 case HB_SCRIPT_KANNADA:
183 case HB_SCRIPT_MALAYALAM:
184 case HB_SCRIPT_ORIYA:
185 case HB_SCRIPT_TAMIL:
186 case HB_SCRIPT_TELUGU:
188 /* Unicode-3.0 additions */
189 case HB_SCRIPT_KHMER:
190 case HB_SCRIPT_SINHALA:
192 /* Unicode-4.1 additions */
193 case HB_SCRIPT_BUGINESE:
194 case HB_SCRIPT_KHAROSHTHI:
195 case HB_SCRIPT_NEW_TAI_LUE:
197 /* Unicode-5.0 additions */
198 case HB_SCRIPT_BALINESE:
200 /* Unicode-5.1 additions */
202 case HB_SCRIPT_LEPCHA:
203 case HB_SCRIPT_REJANG:
204 case HB_SCRIPT_SUNDANESE:
206 /* Unicode-5.2 additions */
207 case HB_SCRIPT_JAVANESE:
208 case HB_SCRIPT_KAITHI:
209 case HB_SCRIPT_TAI_THAM:
211 /* Unicode-6.1 additions */
212 case HB_SCRIPT_CHAKMA:
213 case HB_SCRIPT_SHARADA:
214 case HB_SCRIPT_TAKRI:
216 return hb_ot_complex_shaper_indic;
218 /* ^--- Add new shapers here */
227 * Called during shape_plan().
229 * Shapers should use map to add their features and callbacks.
232 typedef void hb_ot_shape_complex_collect_features_func_t (hb_ot_map_builder_t *map, const hb_segment_properties_t *props);
233 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
234 HB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_##name;
235 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
236 #undef HB_COMPLEX_SHAPER_IMPLEMENT
239 hb_ot_shape_complex_collect_features (hb_ot_complex_shaper_t shaper,
240 hb_ot_map_builder_t *map,
241 const hb_segment_properties_t *props)
245 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
246 case hb_ot_complex_shaper_##name: _hb_ot_shape_complex_collect_features_##name (map, props); return;
247 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
248 #undef HB_COMPLEX_SHAPER_IMPLEMENT
254 * normalization_preference()
256 * Called during shape_execute().
258 * Shapers should return true if it prefers decomposed (NFD) input rather than precomposed (NFC).
261 typedef hb_ot_shape_normalization_mode_t hb_ot_shape_complex_normalization_preference_func_t (void);
262 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
263 HB_INTERNAL hb_ot_shape_complex_normalization_preference_func_t _hb_ot_shape_complex_normalization_preference_##name;
264 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
265 #undef HB_COMPLEX_SHAPER_IMPLEMENT
267 static inline hb_ot_shape_normalization_mode_t
268 hb_ot_shape_complex_normalization_preference (hb_ot_complex_shaper_t shaper)
272 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
273 case hb_ot_complex_shaper_##name: return _hb_ot_shape_complex_normalization_preference_##name ();
274 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
275 #undef HB_COMPLEX_SHAPER_IMPLEMENT
282 * Called during shape_execute().
284 * Shapers should use map to get feature masks and set on buffer.
287 typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font);
288 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
289 HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_##name;
290 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
291 #undef HB_COMPLEX_SHAPER_IMPLEMENT
294 hb_ot_shape_complex_setup_masks (hb_ot_complex_shaper_t shaper,
301 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
302 case hb_ot_complex_shaper_##name: _hb_ot_shape_complex_setup_masks_##name (map, buffer, font); return;
303 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
304 #undef HB_COMPLEX_SHAPER_IMPLEMENT
310 #endif /* HB_OT_SHAPE_COMPLEX_PRIVATE_HH */