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