[HB] simplify macros
[framework/uifw/harfbuzz.git] / src / hb-ot-layout.h
1 /*
2  * Copyright (C) 2007,2008  Red Hat, Inc.
3  *
4  *  This is part of HarfBuzz, an OpenType Layout engine 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  * Red Hat Author(s): Behdad Esfahbod
25  */
26
27 #ifndef HB_OT_LAYOUT_H
28 #define HB_OT_LAYOUT_H
29
30 #include "hb-common.h"
31 #include "hb-buffer.h"
32
33 HB_BEGIN_DECLS
34
35 /*
36  * hb_ot_layout_t
37  */
38
39 typedef struct _hb_ot_layout_t hb_ot_layout_t;
40
41 hb_ot_layout_t *
42 hb_ot_layout_create (void);
43
44 hb_ot_layout_t *
45 hb_ot_layout_create_for_data (const char *font_data,
46                               int         face_index);
47
48 void
49 hb_ot_layout_destroy (hb_ot_layout_t *layout);
50
51 /* XXX */
52 void
53 hb_ot_layout_set_direction (hb_ot_layout_t *layout,
54                             hb_bool_t r2l);
55
56 void
57 hb_ot_layout_set_hinting (hb_ot_layout_t *layout,
58                           hb_bool_t hinted);
59
60 void
61 hb_ot_layout_set_scale (hb_ot_layout_t *layout,
62                         hb_16dot16_t x_scale, hb_16dot16_t y_scale);
63
64 void
65 hb_ot_layout_set_ppem (hb_ot_layout_t *layout,
66                        unsigned int x_ppem, unsigned int y_ppem);
67
68 /* TODO sanitizing API/constructor (make_writable_func_t) */
69 /* TODO get_table_func_t constructor */
70
71 /*
72  * GDEF
73  */
74
75 typedef enum {
76   HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0x0000,
77   HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH   = 0x0002,
78   HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE     = 0x0004,
79   HB_OT_LAYOUT_GLYPH_CLASS_MARK         = 0x0008,
80   HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT    = 0x0010
81 } hb_ot_layout_glyph_class_t;
82
83 hb_bool_t
84 hb_ot_layout_has_font_glyph_classes (hb_ot_layout_t *layout);
85
86 hb_ot_layout_glyph_class_t
87 hb_ot_layout_get_glyph_class (hb_ot_layout_t *layout,
88                               hb_codepoint_t  glyph);
89
90 void
91 hb_ot_layout_set_glyph_class (hb_ot_layout_t            *layout,
92                               hb_codepoint_t             glyph,
93                               hb_ot_layout_glyph_class_t klass);
94
95 void
96 hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
97                                   uint16_t        num_total_glyphs,
98                                   hb_codepoint_t *glyphs,
99                                   unsigned char  *klasses,
100                                   uint16_t        count);
101
102 /*
103  * GSUB/GPOS
104  */
105
106 typedef enum {
107   HB_OT_LAYOUT_TABLE_TYPE_GSUB,
108   HB_OT_LAYOUT_TABLE_TYPE_GPOS,
109   HB_OT_LAYOUT_TABLE_TYPE_NONE
110 } hb_ot_layout_table_type_t;
111
112 typedef uint32_t hb_ot_layout_feature_mask_t;
113
114 #define HB_OT_LAYOUT_NO_SCRIPT_INDEX            ((unsigned int) 0xFFFF)
115 #define HB_OT_LAYOUT_NO_FEATURE_INDEX           ((unsigned int) 0xFFFF)
116 #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX     ((unsigned int) 0xFFFF)
117 #define HB_OT_LAYOUT_TAG_DEFAULT_SCRIPT         HB_TAG ('D', 'F', 'L', 'T')
118 #define HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE       HB_TAG ('d', 'f', 'l', 't')
119
120 unsigned int
121 hb_ot_layout_table_get_script_count (hb_ot_layout_t            *layout,
122                                      hb_ot_layout_table_type_t  table_type);
123
124 hb_tag_t
125 hb_ot_layout_table_get_script_tag (hb_ot_layout_t            *layout,
126                                    hb_ot_layout_table_type_t  table_type,
127                                    unsigned int               script_index);
128
129 hb_bool_t
130 hb_ot_layout_table_find_script (hb_ot_layout_t            *layout,
131                                 hb_ot_layout_table_type_t  table_type,
132                                 hb_tag_t                   script_tag,
133                                 unsigned int              *script_index);
134
135 unsigned int
136 hb_ot_layout_table_get_feature_count (hb_ot_layout_t            *layout,
137                                       hb_ot_layout_table_type_t  table_type);
138
139 hb_tag_t
140 hb_ot_layout_table_get_feature_tag (hb_ot_layout_t            *layout,
141                                     hb_ot_layout_table_type_t  table_type,
142                                     unsigned int               feature_index);
143
144 hb_bool_t
145 hb_ot_layout_table_find_feature (hb_ot_layout_t            *layout,
146                                  hb_ot_layout_table_type_t  table_type,
147                                  hb_tag_t                   feature_tag,
148                                  unsigned int              *feature_index);
149
150 unsigned int
151 hb_ot_layout_table_get_lookup_count (hb_ot_layout_t            *layout,
152                                      hb_ot_layout_table_type_t  table_type);
153
154 unsigned int
155 hb_ot_layout_script_get_language_count (hb_ot_layout_t            *layout,
156                                         hb_ot_layout_table_type_t  table_type,
157                                         unsigned int               script_index);
158
159 hb_tag_t
160 hb_ot_layout_script_get_language_tag (hb_ot_layout_t            *layout,
161                                       hb_ot_layout_table_type_t  table_type,
162                                       unsigned int               script_index,
163                                       unsigned int               language_index);
164
165 hb_bool_t
166 hb_ot_layout_script_find_language (hb_ot_layout_t            *layout,
167                                    hb_ot_layout_table_type_t  table_type,
168                                    unsigned int               script_index,
169                                    hb_tag_t                   language_tag,
170                                    unsigned int              *language_index);
171
172 hb_bool_t
173 hb_ot_layout_language_get_required_feature_index (hb_ot_layout_t            *layout,
174                                                   hb_ot_layout_table_type_t  table_type,
175                                                   unsigned int               script_index,
176                                                   unsigned int               language_index,
177                                                   unsigned int              *feature_index);
178
179 unsigned int
180 hb_ot_layout_language_get_feature_count (hb_ot_layout_t            *layout,
181                                          hb_ot_layout_table_type_t  table_type,
182                                          unsigned int               script_index,
183                                          unsigned int               language_index);
184
185 unsigned int
186 hb_ot_layout_language_get_feature_index (hb_ot_layout_t            *layout,
187                                          hb_ot_layout_table_type_t  table_type,
188                                          unsigned int               script_index,
189                                          unsigned int               language_index,
190                                          unsigned int               num_feature);
191
192 hb_tag_t
193 hb_ot_layout_language_get_feature_tag (hb_ot_layout_t            *layout,
194                                        hb_ot_layout_table_type_t  table_type,
195                                        unsigned int               script_index,
196                                        unsigned int               language_index,
197                                        unsigned int               num_feature);
198
199 hb_bool_t
200 hb_ot_layout_language_find_feature (hb_ot_layout_t            *layout,
201                                     hb_ot_layout_table_type_t  table_type,
202                                     unsigned int               script_index,
203                                     unsigned int               language_index,
204                                     hb_tag_t                   feature_tag,
205                                     unsigned int              *feature_index);
206
207 unsigned int
208 hb_ot_layout_feature_get_lookup_count (hb_ot_layout_t            *layout,
209                                        hb_ot_layout_table_type_t  table_type,
210                                        unsigned int               feature_index);
211
212 unsigned int
213 hb_ot_layout_feature_get_lookup_index (hb_ot_layout_t            *layout,
214                                        hb_ot_layout_table_type_t  table_type,
215                                        unsigned int               feature_index,
216                                        unsigned int               num_lookup);
217
218 /*
219  * GSUB
220  */
221
222 hb_bool_t
223 hb_ot_layout_substitute_lookup (hb_ot_layout_t              *layout,
224                                 hb_buffer_t                 *buffer,
225                                 unsigned int                 lookup_index,
226                                 hb_ot_layout_feature_mask_t  mask);
227
228 hb_bool_t
229 hb_ot_layout_position_lookup   (hb_ot_layout_t              *layout,
230                                 hb_buffer_t                 *buffer,
231                                 unsigned int                 lookup_index,
232                                 hb_ot_layout_feature_mask_t  mask);
233
234
235
236
237
238
239
240
241
242
243 /*
244 #define PANGO_OT_ALL_GLYPHS                     ((guint) 0xFFFF)
245
246 */
247
248 HB_END_DECLS
249
250 #endif /* HB_OT_LAYOUT_H */