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-shape-private.hh"
33 #include "hb-ot-shape-normalize-private.hh"
37 /* buffer var allocations, used by complex shapers */
38 #define complex_var_u8_0() var2.u8[2]
39 #define complex_var_u8_1() var2.u8[3]
43 /* Master OT shaper list */
44 #define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \
45 HB_COMPLEX_SHAPER_IMPLEMENT (default) /* should be first */ \
46 HB_COMPLEX_SHAPER_IMPLEMENT (arabic) \
47 HB_COMPLEX_SHAPER_IMPLEMENT (indic) \
48 HB_COMPLEX_SHAPER_IMPLEMENT (thai) \
49 /* ^--- Add new shapers here */
52 struct hb_ot_complex_shaper_t
57 * Called during shape_plan().
58 * Shapers should use plan->map to add their features and callbacks.
60 void (*collect_features) (hb_ot_shape_planner_t *plan);
62 /* override_features()
63 * Called during shape_plan().
64 * Shapers should use plan->map to override features and add callbacks after
65 * common features are added.
67 void (*override_features) (hb_ot_shape_planner_t *plan);
71 * Called at the end of shape_plan().
72 * Whatever shapers return will be accessible through plan->data later.
73 * If NULL is returned, means a plan failure.
75 void *(*data_create) (const hb_ot_shape_plan_t *plan);
78 * Called when the shape_plan is being destroyed.
79 * plan->data is passed here for destruction.
80 * If NULL is returned, means a plan failure.
82 void (*data_destroy) (void *data);
86 * Called during shape().
87 * Shapers can use to modify text before shaping starts.
89 void (*preprocess_text) (const hb_ot_shape_plan_t *plan,
94 /* normalization_preference()
95 * Called during shape().
97 hb_ot_shape_normalization_mode_t
98 (*normalization_preference) (const hb_ot_shape_plan_t *plan);
101 * Called during shape().
102 * Shapers should use map to get feature masks and set on buffer.
103 * Shapers may NOT modify characters.
105 void (*setup_masks) (const hb_ot_shape_plan_t *plan,
109 bool zero_width_attached_marks;
112 #define HB_COMPLEX_SHAPER_IMPLEMENT(name) extern HB_INTERNAL const hb_ot_complex_shaper_t _hb_ot_complex_shaper_##name;
113 HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
114 #undef HB_COMPLEX_SHAPER_IMPLEMENT
117 static inline const hb_ot_complex_shaper_t *
118 hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
120 switch ((hb_tag_t) props->script)
123 return &_hb_ot_complex_shaper_default;
126 /* Unicode-1.1 additions */
127 case HB_SCRIPT_ARABIC:
128 case HB_SCRIPT_MONGOLIAN:
129 case HB_SCRIPT_SYRIAC:
131 /* Unicode-5.0 additions */
134 /* Unicode-6.0 additions */
135 case HB_SCRIPT_MANDAIC:
137 return &_hb_ot_complex_shaper_arabic;
140 /* Unicode-1.1 additions */
144 return &_hb_ot_complex_shaper_thai;
148 /* ^--- Add new shapers here */
154 * These disabled scripts are listed in ucd/IndicSyllabicCategory.txt, but according
155 * to Martin Hosken and Jonathan Kew do not require complex shaping.
157 * TODO We should automate figuring out which scripts do not need complex shaping
159 * TODO We currently keep data for these scripts in our indic table. Need to fix the
160 * generator to not do that.
166 /* Unicode-3.2 additions */
167 case HB_SCRIPT_BUHID:
168 case HB_SCRIPT_HANUNOO:
170 /* Unicode-5.1 additions */
171 case HB_SCRIPT_SAURASHTRA:
173 /* Unicode-5.2 additions */
174 case HB_SCRIPT_MEETEI_MAYEK:
176 /* Unicode-6.0 additions */
177 case HB_SCRIPT_BATAK:
178 case HB_SCRIPT_BRAHMI:
183 /* Unicode-1.1 additions */
184 /* These have their own shaper now. */
188 /* Unicode-2.0 additions */
189 case HB_SCRIPT_TIBETAN:
191 /* Unicode-3.2 additions */
192 case HB_SCRIPT_TAGALOG:
193 case HB_SCRIPT_TAGBANWA:
195 /* Unicode-4.0 additions */
196 case HB_SCRIPT_LIMBU:
197 case HB_SCRIPT_TAI_LE:
199 /* Unicode-4.1 additions */
200 case HB_SCRIPT_SYLOTI_NAGRI:
202 /* Unicode-5.0 additions */
203 case HB_SCRIPT_PHAGS_PA:
205 /* Unicode-5.1 additions */
206 case HB_SCRIPT_KAYAH_LI:
208 /* Unicode-5.2 additions */
209 case HB_SCRIPT_TAI_VIET:
212 /* May need Indic treatment in the future? */
214 /* Unicode-3.0 additions */
215 case HB_SCRIPT_MYANMAR:
220 /* Unicode-1.1 additions */
221 case HB_SCRIPT_BENGALI:
222 case HB_SCRIPT_DEVANAGARI:
223 case HB_SCRIPT_GUJARATI:
224 case HB_SCRIPT_GURMUKHI:
225 case HB_SCRIPT_KANNADA:
226 case HB_SCRIPT_MALAYALAM:
227 case HB_SCRIPT_ORIYA:
228 case HB_SCRIPT_TAMIL:
229 case HB_SCRIPT_TELUGU:
231 /* Unicode-3.0 additions */
232 case HB_SCRIPT_KHMER:
233 case HB_SCRIPT_SINHALA:
235 /* Unicode-4.1 additions */
236 case HB_SCRIPT_BUGINESE:
237 case HB_SCRIPT_KHAROSHTHI:
238 case HB_SCRIPT_NEW_TAI_LUE:
240 /* Unicode-5.0 additions */
241 case HB_SCRIPT_BALINESE:
243 /* Unicode-5.1 additions */
245 case HB_SCRIPT_LEPCHA:
246 case HB_SCRIPT_REJANG:
247 case HB_SCRIPT_SUNDANESE:
249 /* Unicode-5.2 additions */
250 case HB_SCRIPT_JAVANESE:
251 case HB_SCRIPT_KAITHI:
252 case HB_SCRIPT_TAI_THAM:
254 /* Unicode-6.1 additions */
255 case HB_SCRIPT_CHAKMA:
256 case HB_SCRIPT_SHARADA:
257 case HB_SCRIPT_TAKRI:
259 return &_hb_ot_complex_shaper_indic;
264 #endif /* HB_OT_SHAPE_COMPLEX_PRIVATE_HH */