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