3e83c365a6a46955340fc55a10b4a25095f32068
[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 /* TODO sanitizing API/constructor (make_writable_func_t) */
56 /* TODO get_table_func_t constructor */
57
58 /*
59  * GDEF
60  */
61
62 typedef enum {
63   HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0x0000,
64   HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH   = 0x0002,
65   HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE     = 0x0004,
66   HB_OT_LAYOUT_GLYPH_CLASS_MARK         = 0x0008,
67   HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT    = 0x0010
68 } hb_ot_layout_glyph_class_t;
69
70 hb_bool_t
71 hb_ot_layout_has_font_glyph_classes (hb_ot_layout_t *layout);
72
73 hb_ot_layout_glyph_class_t
74 hb_ot_layout_get_glyph_class (hb_ot_layout_t *layout,
75                               hb_codepoint_t  glyph);
76
77 void
78 hb_ot_layout_set_glyph_class (hb_ot_layout_t            *layout,
79                               hb_codepoint_t             glyph,
80                               hb_ot_layout_glyph_class_t klass);
81
82 void
83 hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
84                                   uint16_t        num_total_glyphs,
85                                   hb_codepoint_t *glyphs,
86                                   unsigned char  *klasses,
87                                   uint16_t        count);
88
89 /*
90  * GSUB/GPOS
91  */
92
93 typedef enum {
94   HB_OT_LAYOUT_TABLE_TYPE_GSUB,
95   HB_OT_LAYOUT_TABLE_TYPE_GPOS,
96   HB_OT_LAYOUT_TABLE_TYPE_NONE
97 } hb_ot_layout_table_type_t;
98
99 typedef uint32_t hb_ot_layout_feature_mask_t;
100
101 #define HB_OT_LAYOUT_NO_SCRIPT_INDEX            ((unsigned int) 0xFFFF)
102 #define HB_OT_LAYOUT_NO_FEATURE_INDEX           ((unsigned int) 0xFFFF)
103 #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX     ((unsigned int) 0xFFFF)
104 #define HB_OT_LAYOUT_TAG_DEFAULT_SCRIPT         HB_TAG ('D', 'F', 'L', 'T')
105 #define HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE       HB_TAG ('d', 'f', 'l', 't')
106
107 unsigned int
108 hb_ot_layout_table_get_script_count (hb_ot_layout_t            *layout,
109                                      hb_ot_layout_table_type_t  table_type);
110
111 hb_tag_t
112 hb_ot_layout_table_get_script_tag (hb_ot_layout_t            *layout,
113                                    hb_ot_layout_table_type_t  table_type,
114                                    unsigned int               script_index);
115
116 hb_bool_t
117 hb_ot_layout_table_find_script (hb_ot_layout_t            *layout,
118                                 hb_ot_layout_table_type_t  table_type,
119                                 hb_tag_t                   script_tag,
120                                 unsigned int              *script_index);
121
122 unsigned int
123 hb_ot_layout_table_get_feature_count (hb_ot_layout_t            *layout,
124                                       hb_ot_layout_table_type_t  table_type);
125
126 hb_tag_t
127 hb_ot_layout_table_get_feature_tag (hb_ot_layout_t            *layout,
128                                     hb_ot_layout_table_type_t  table_type,
129                                     unsigned int               feature_index);
130
131 hb_bool_t
132 hb_ot_layout_table_find_feature (hb_ot_layout_t            *layout,
133                                  hb_ot_layout_table_type_t  table_type,
134                                  hb_tag_t                   feature_tag,
135                                  unsigned int              *feature_index);
136
137 unsigned int
138 hb_ot_layout_table_get_lookup_count (hb_ot_layout_t            *layout,
139                                      hb_ot_layout_table_type_t  table_type);
140
141 unsigned int
142 hb_ot_layout_script_get_language_count (hb_ot_layout_t            *layout,
143                                         hb_ot_layout_table_type_t  table_type,
144                                         unsigned int               script_index);
145
146 hb_tag_t
147 hb_ot_layout_script_get_language_tag (hb_ot_layout_t            *layout,
148                                       hb_ot_layout_table_type_t  table_type,
149                                       unsigned int               script_index,
150                                       unsigned int               language_index);
151
152 hb_bool_t
153 hb_ot_layout_script_find_language (hb_ot_layout_t            *layout,
154                                    hb_ot_layout_table_type_t  table_type,
155                                    unsigned int               script_index,
156                                    hb_tag_t                   language_tag,
157                                    unsigned int              *language_index);
158
159 hb_bool_t
160 hb_ot_layout_language_get_required_feature_index (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                                                   unsigned int              *feature_index);
165
166 unsigned int
167 hb_ot_layout_language_get_feature_count (hb_ot_layout_t            *layout,
168                                          hb_ot_layout_table_type_t  table_type,
169                                          unsigned int               script_index,
170                                          unsigned int               language_index);
171
172 unsigned int
173 hb_ot_layout_language_get_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               num_feature);
178
179 hb_tag_t
180 hb_ot_layout_language_get_feature_tag (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                                        unsigned int               num_feature);
185
186 hb_bool_t
187 hb_ot_layout_language_find_feature (hb_ot_layout_t            *layout,
188                                     hb_ot_layout_table_type_t  table_type,
189                                     unsigned int               script_index,
190                                     unsigned int               language_index,
191                                     hb_tag_t                   feature_tag,
192                                     unsigned int              *feature_index);
193
194 unsigned int
195 hb_ot_layout_feature_get_lookup_count (hb_ot_layout_t            *layout,
196                                        hb_ot_layout_table_type_t  table_type,
197                                        unsigned int               feature_index);
198
199 unsigned int
200 hb_ot_layout_feature_get_lookup_index (hb_ot_layout_t            *layout,
201                                        hb_ot_layout_table_type_t  table_type,
202                                        unsigned int               feature_index,
203                                        unsigned int               num_lookup);
204
205 /*
206  * GSUB
207  */
208
209 hb_bool_t
210 hb_ot_layout_substitute_lookup (hb_ot_layout_t              *layout,
211                                 hb_buffer_t                 *buffer,
212                                 unsigned int                 lookup_index,
213                                 hb_ot_layout_feature_mask_t  mask);
214
215 hb_bool_t
216 hb_ot_layout_position_lookup   (hb_ot_layout_t              *layout,
217                                 hb_buffer_t                 *buffer,
218                                 unsigned int                 lookup_index,
219                                 hb_ot_layout_feature_mask_t  mask);
220
221
222
223
224
225
226
227
228
229
230 /*
231 #define PANGO_OT_ALL_GLYPHS                     ((guint) 0xFFFF)
232
233 */
234
235 HB_END_DECLS();
236
237 #endif /* HB_OT_LAYOUT_H */