93268bae6c1e02214e7cefacd9b0b0ec14e866e0
[profile/ivi/org.tizen.video-player.git] / src / hb-ot-shape-complex-private.hh
1 /*
2  * Copyright © 2010,2011  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_PRIVATE_HH
28 #define HB_OT_SHAPE_COMPLEX_PRIVATE_HH
29
30 #include "hb-private.hh"
31
32 #include "hb-ot-map-private.hh"
33
34 HB_BEGIN_DECLS
35
36
37 /* buffer var allocations, used by all shapers */
38 #define general_category() var1.u8[0] /* unicode general_category (hb_unicode_general_category_t) */
39 #define combining_class() var1.u8[1] /* unicode combining_class (uint8_t) */
40
41
42 enum hb_ot_complex_shaper_t {
43   hb_ot_complex_shaper_default,
44   hb_ot_complex_shaper_arabic,
45   hb_ot_complex_shaper_indic
46 };
47
48 static inline hb_ot_complex_shaper_t
49 hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
50 {
51   switch ((int) props->script)
52   {
53     case HB_SCRIPT_ARABIC:
54     case HB_SCRIPT_MANDAIC:
55     case HB_SCRIPT_MONGOLIAN:
56     case HB_SCRIPT_NKO:
57     case HB_SCRIPT_SYRIAC:
58       return hb_ot_complex_shaper_arabic;
59
60     /* TODO: These are all the scripts that the ucd/IndicSyllabicCategory.txt covers.
61      * Quite possibly many of these need no shaping, and some other are encoded visually.
62      * Needs to be refined.
63      */
64     case HB_SCRIPT_BALINESE:
65     case HB_SCRIPT_BATAK:
66     case HB_SCRIPT_BENGALI:
67     case HB_SCRIPT_BRAHMI:
68     case HB_SCRIPT_BUGINESE:
69     case HB_SCRIPT_BUHID:
70     case HB_SCRIPT_CHAM:
71     case HB_SCRIPT_DEVANAGARI:
72     case HB_SCRIPT_GUJARATI:
73     case HB_SCRIPT_GURMUKHI:
74     case HB_SCRIPT_HANUNOO:
75     case HB_SCRIPT_JAVANESE:
76     case HB_SCRIPT_KAITHI:
77     case HB_SCRIPT_KANNADA:
78     case HB_SCRIPT_KAYAH_LI:
79     case HB_SCRIPT_KHAROSHTHI:
80     case HB_SCRIPT_KHMER:
81     case HB_SCRIPT_LAO:
82     case HB_SCRIPT_LEPCHA:
83     case HB_SCRIPT_LIMBU:
84     case HB_SCRIPT_MALAYALAM:
85     case HB_SCRIPT_MEETEI_MAYEK:
86     case HB_SCRIPT_MYANMAR:
87     case HB_SCRIPT_NEW_TAI_LUE:
88     case HB_SCRIPT_ORIYA:
89     case HB_SCRIPT_PHAGS_PA:
90     case HB_SCRIPT_REJANG:
91     case HB_SCRIPT_SAURASHTRA:
92     case HB_SCRIPT_SINHALA:
93     case HB_SCRIPT_SUNDANESE:
94     case HB_SCRIPT_SYLOTI_NAGRI:
95     case HB_SCRIPT_TAGALOG:
96     case HB_SCRIPT_TAGBANWA:
97     case HB_SCRIPT_TAI_LE:
98     case HB_SCRIPT_TAI_THAM:
99     case HB_SCRIPT_TAI_VIET:
100     case HB_SCRIPT_TAMIL:
101     case HB_SCRIPT_TELUGU:
102     case HB_SCRIPT_THAI:
103     case HB_SCRIPT_TIBETAN:
104       return hb_ot_complex_shaper_indic;
105
106     default:
107       return hb_ot_complex_shaper_default;
108   }
109 }
110
111
112
113 /*
114  * collect_features()
115  *
116  * Called during shape_plan().
117  *
118  * Shapers should use map to add their features and callbacks.
119  */
120
121 typedef void hb_ot_shape_complex_collect_features_func_t (hb_ot_map_builder_t *map, const hb_segment_properties_t  *props);
122 HB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_default;
123 HB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_arabic;
124 HB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_indic;
125
126 static inline void
127 hb_ot_shape_complex_collect_features (hb_ot_complex_shaper_t shaper,
128                                       hb_ot_map_builder_t *map,
129                                       const hb_segment_properties_t  *props)
130 {
131   switch (shaper) {
132     default:
133     case hb_ot_complex_shaper_default:  _hb_ot_shape_complex_collect_features_default   (map, props);   return;
134     case hb_ot_complex_shaper_arabic:   _hb_ot_shape_complex_collect_features_arabic    (map, props);   return;
135     case hb_ot_complex_shaper_indic:    _hb_ot_shape_complex_collect_features_indic     (map, props);   return;
136   }
137 }
138
139
140 /* setup_masks()
141  *
142  * Called during shape_execute().
143  *
144  * Shapers should use map to get feature masks and set on buffer.
145  */
146
147 typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer_t *buffer);
148 HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_default;
149 HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_arabic;
150 HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_indic;
151
152 static inline void
153 hb_ot_shape_complex_setup_masks (hb_ot_complex_shaper_t shaper,
154                                  hb_ot_map_t *map,
155                                  hb_buffer_t *buffer)
156 {
157   switch (shaper) {
158     default:
159     case hb_ot_complex_shaper_default:  _hb_ot_shape_complex_setup_masks_default(map, buffer);  return;
160     case hb_ot_complex_shaper_arabic:   _hb_ot_shape_complex_setup_masks_arabic (map, buffer);  return;
161     case hb_ot_complex_shaper_indic:    _hb_ot_shape_complex_setup_masks_indic  (map, buffer);  return;
162   }
163 }
164
165
166 HB_END_DECLS
167
168 #endif /* HB_OT_SHAPE_COMPLEX_PRIVATE_HH */