Imported Upstream version 1.8.1
[platform/upstream/harfbuzz.git] / src / hb-ot-layout.h
1 /*
2  * Copyright © 2007,2008,2009  Red Hat, 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  * Red Hat Author(s): Behdad Esfahbod
25  */
26
27 #ifndef HB_OT_H_IN
28 #error "Include <hb-ot.h> instead."
29 #endif
30
31 #ifndef HB_OT_LAYOUT_H
32 #define HB_OT_LAYOUT_H
33
34 #include "hb.h"
35
36 #include "hb-ot-tag.h"
37
38 HB_BEGIN_DECLS
39
40
41 #define HB_OT_TAG_BASE HB_TAG('B','A','S','E')
42 #define HB_OT_TAG_GDEF HB_TAG('G','D','E','F')
43 #define HB_OT_TAG_GSUB HB_TAG('G','S','U','B')
44 #define HB_OT_TAG_GPOS HB_TAG('G','P','O','S')
45 #define HB_OT_TAG_JSTF HB_TAG('J','S','T','F')
46
47
48 /*
49  * GDEF
50  */
51
52 HB_EXTERN hb_bool_t
53 hb_ot_layout_has_glyph_classes (hb_face_t *face);
54
55 typedef enum {
56   HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0,
57   HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH   = 1,
58   HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE     = 2,
59   HB_OT_LAYOUT_GLYPH_CLASS_MARK         = 3,
60   HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT    = 4
61 } hb_ot_layout_glyph_class_t;
62
63 HB_EXTERN hb_ot_layout_glyph_class_t
64 hb_ot_layout_get_glyph_class (hb_face_t      *face,
65                               hb_codepoint_t  glyph);
66
67 HB_EXTERN void
68 hb_ot_layout_get_glyphs_in_class (hb_face_t                  *face,
69                                   hb_ot_layout_glyph_class_t  klass,
70                                   hb_set_t                   *glyphs /* OUT */);
71
72
73 /* Not that useful.  Provides list of attach points for a glyph that a
74  * client may want to cache */
75 HB_EXTERN unsigned int
76 hb_ot_layout_get_attach_points (hb_face_t      *face,
77                                 hb_codepoint_t  glyph,
78                                 unsigned int    start_offset,
79                                 unsigned int   *point_count /* IN/OUT */,
80                                 unsigned int   *point_array /* OUT */);
81
82 /* Ligature caret positions */
83 HB_EXTERN unsigned int
84 hb_ot_layout_get_ligature_carets (hb_font_t      *font,
85                                   hb_direction_t  direction,
86                                   hb_codepoint_t  glyph,
87                                   unsigned int    start_offset,
88                                   unsigned int   *caret_count /* IN/OUT */,
89                                   hb_position_t  *caret_array /* OUT */);
90
91
92 /*
93  * GSUB/GPOS feature query and enumeration interface
94  */
95
96 #define HB_OT_LAYOUT_NO_SCRIPT_INDEX            0xFFFFu
97 #define HB_OT_LAYOUT_NO_FEATURE_INDEX           0xFFFFu
98 #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX     0xFFFFu
99 #define HB_OT_LAYOUT_NO_VARIATIONS_INDEX        0xFFFFFFFFu
100
101 HB_EXTERN unsigned int
102 hb_ot_layout_table_get_script_tags (hb_face_t    *face,
103                                     hb_tag_t      table_tag,
104                                     unsigned int  start_offset,
105                                     unsigned int *script_count /* IN/OUT */,
106                                     hb_tag_t     *script_tags /* OUT */);
107
108 HB_EXTERN hb_bool_t
109 hb_ot_layout_table_find_script (hb_face_t    *face,
110                                 hb_tag_t      table_tag,
111                                 hb_tag_t      script_tag,
112                                 unsigned int *script_index);
113
114 /* Like find_script, but takes zero-terminated array of scripts to test */
115 HB_EXTERN hb_bool_t
116 hb_ot_layout_table_choose_script (hb_face_t      *face,
117                                   hb_tag_t        table_tag,
118                                   const hb_tag_t *script_tags,
119                                   unsigned int   *script_index,
120                                   hb_tag_t       *chosen_script);
121
122 HB_EXTERN unsigned int
123 hb_ot_layout_table_get_feature_tags (hb_face_t    *face,
124                                      hb_tag_t      table_tag,
125                                      unsigned int  start_offset,
126                                      unsigned int *feature_count /* IN/OUT */,
127                                      hb_tag_t     *feature_tags /* OUT */);
128
129 HB_EXTERN unsigned int
130 hb_ot_layout_script_get_language_tags (hb_face_t    *face,
131                                        hb_tag_t      table_tag,
132                                        unsigned int  script_index,
133                                        unsigned int  start_offset,
134                                        unsigned int *language_count /* IN/OUT */,
135                                        hb_tag_t     *language_tags /* OUT */);
136
137 HB_EXTERN hb_bool_t
138 hb_ot_layout_script_find_language (hb_face_t    *face,
139                                    hb_tag_t      table_tag,
140                                    unsigned int  script_index,
141                                    hb_tag_t      language_tag,
142                                    unsigned int *language_index);
143
144 HB_EXTERN hb_bool_t
145 hb_ot_layout_language_get_required_feature_index (hb_face_t    *face,
146                                                   hb_tag_t      table_tag,
147                                                   unsigned int  script_index,
148                                                   unsigned int  language_index,
149                                                   unsigned int *feature_index);
150
151 HB_EXTERN hb_bool_t
152 hb_ot_layout_language_get_required_feature (hb_face_t    *face,
153                                             hb_tag_t      table_tag,
154                                             unsigned int  script_index,
155                                             unsigned int  language_index,
156                                             unsigned int *feature_index,
157                                             hb_tag_t     *feature_tag);
158
159 HB_EXTERN unsigned int
160 hb_ot_layout_language_get_feature_indexes (hb_face_t    *face,
161                                            hb_tag_t      table_tag,
162                                            unsigned int  script_index,
163                                            unsigned int  language_index,
164                                            unsigned int  start_offset,
165                                            unsigned int *feature_count /* IN/OUT */,
166                                            unsigned int *feature_indexes /* OUT */);
167
168 HB_EXTERN unsigned int
169 hb_ot_layout_language_get_feature_tags (hb_face_t    *face,
170                                         hb_tag_t      table_tag,
171                                         unsigned int  script_index,
172                                         unsigned int  language_index,
173                                         unsigned int  start_offset,
174                                         unsigned int *feature_count /* IN/OUT */,
175                                         hb_tag_t     *feature_tags /* OUT */);
176
177 HB_EXTERN hb_bool_t
178 hb_ot_layout_language_find_feature (hb_face_t    *face,
179                                     hb_tag_t      table_tag,
180                                     unsigned int  script_index,
181                                     unsigned int  language_index,
182                                     hb_tag_t      feature_tag,
183                                     unsigned int *feature_index);
184
185 HB_EXTERN unsigned int
186 hb_ot_layout_feature_get_lookups (hb_face_t    *face,
187                                   hb_tag_t      table_tag,
188                                   unsigned int  feature_index,
189                                   unsigned int  start_offset,
190                                   unsigned int *lookup_count /* IN/OUT */,
191                                   unsigned int *lookup_indexes /* OUT */);
192
193 HB_EXTERN unsigned int
194 hb_ot_layout_table_get_lookup_count (hb_face_t    *face,
195                                      hb_tag_t      table_tag);
196
197
198 HB_EXTERN void
199 hb_ot_layout_collect_lookups (hb_face_t      *face,
200                               hb_tag_t        table_tag,
201                               const hb_tag_t *scripts,
202                               const hb_tag_t *languages,
203                               const hb_tag_t *features,
204                               hb_set_t       *lookup_indexes /* OUT */);
205
206 HB_EXTERN void
207 hb_ot_layout_lookup_collect_glyphs (hb_face_t    *face,
208                                     hb_tag_t      table_tag,
209                                     unsigned int  lookup_index,
210                                     hb_set_t     *glyphs_before, /* OUT. May be NULL */
211                                     hb_set_t     *glyphs_input,  /* OUT. May be NULL */
212                                     hb_set_t     *glyphs_after,  /* OUT. May be NULL */
213                                     hb_set_t     *glyphs_output  /* OUT. May be NULL */);
214
215 #ifdef HB_NOT_IMPLEMENTED
216 typedef struct
217 {
218   const hb_codepoint_t *before,
219   unsigned int          before_length,
220   const hb_codepoint_t *input,
221   unsigned int          input_length,
222   const hb_codepoint_t *after,
223   unsigned int          after_length,
224 } hb_ot_layout_glyph_sequence_t;
225
226 typedef hb_bool_t
227 (*hb_ot_layout_glyph_sequence_func_t) (hb_font_t    *font,
228                                        hb_tag_t      table_tag,
229                                        unsigned int  lookup_index,
230                                        const hb_ot_layout_glyph_sequence_t *sequence,
231                                        void         *user_data);
232
233 HB_EXTERN void
234 Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t    *face,
235                                          hb_tag_t      table_tag,
236                                          unsigned int  lookup_index,
237                                          hb_ot_layout_glyph_sequence_func_t callback,
238                                          void         *user_data);
239 #endif
240
241 /* Variations support */
242
243 HB_EXTERN hb_bool_t
244 hb_ot_layout_table_find_feature_variations (hb_face_t    *face,
245                                             hb_tag_t      table_tag,
246                                             const int    *coords,
247                                             unsigned int  num_coords,
248                                             unsigned int *variations_index /* out */);
249
250 HB_EXTERN unsigned int
251 hb_ot_layout_feature_with_variations_get_lookups (hb_face_t    *face,
252                                                   hb_tag_t      table_tag,
253                                                   unsigned int  feature_index,
254                                                   unsigned int  variations_index,
255                                                   unsigned int  start_offset,
256                                                   unsigned int *lookup_count /* IN/OUT */,
257                                                   unsigned int *lookup_indexes /* OUT */);
258
259
260 /*
261  * GSUB
262  */
263
264 HB_EXTERN hb_bool_t
265 hb_ot_layout_has_substitution (hb_face_t *face);
266
267 HB_EXTERN hb_bool_t
268 hb_ot_layout_lookup_would_substitute (hb_face_t            *face,
269                                       unsigned int          lookup_index,
270                                       const hb_codepoint_t *glyphs,
271                                       unsigned int          glyphs_length,
272                                       hb_bool_t             zero_context);
273
274 HB_EXTERN void
275 hb_ot_layout_lookup_substitute_closure (hb_face_t    *face,
276                                         unsigned int  lookup_index,
277                                         hb_set_t     *glyphs
278                                         /*TODO , hb_bool_t  inclusive */);
279
280 HB_EXTERN void
281 hb_ot_layout_lookups_substitute_closure (hb_face_t      *face,
282                                          const hb_set_t *lookups,
283                                          hb_set_t       *glyphs);
284
285
286 #ifdef HB_NOT_IMPLEMENTED
287 /* Note: You better have GDEF when using this API, or marks won't do much. */
288 HB_EXTERN hb_bool_t
289 Xhb_ot_layout_lookup_substitute (hb_font_t            *font,
290                                 unsigned int          lookup_index,
291                                 const hb_ot_layout_glyph_sequence_t *sequence,
292                                 unsigned int          out_size,
293                                 hb_codepoint_t       *glyphs_out,   /* OUT */
294                                 unsigned int         *clusters_out, /* OUT */
295                                 unsigned int         *out_length    /* OUT */);
296 #endif
297
298
299 /*
300  * GPOS
301  */
302
303 HB_EXTERN hb_bool_t
304 hb_ot_layout_has_positioning (hb_face_t *face);
305
306 #ifdef HB_NOT_IMPLEMENTED
307 /* Note: You better have GDEF when using this API, or marks won't do much. */
308 HB_EXTERN hb_bool_t
309 Xhb_ot_layout_lookup_position (hb_font_t            *font,
310                               unsigned int          lookup_index,
311                               const hb_ot_layout_glyph_sequence_t *sequence,
312                               hb_glyph_position_t  *positions /* IN / OUT */);
313 #endif
314
315 /* Optical 'size' feature info.  Returns true if found.
316  * https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */
317 HB_EXTERN hb_bool_t
318 hb_ot_layout_get_size_params (hb_face_t    *face,
319                               unsigned int *design_size,       /* OUT.  May be NULL */
320                               unsigned int *subfamily_id,      /* OUT.  May be NULL */
321                               unsigned int *subfamily_name_id, /* OUT.  May be NULL */
322                               unsigned int *range_start,       /* OUT.  May be NULL */
323                               unsigned int *range_end          /* OUT.  May be NULL */);
324
325
326 /*
327  * BASE
328  */
329 #if 0
330
331 #define HB_OT_TAG_BASE_HANG HB_TAG('h','a','n','g')
332 #define HB_OT_TAG_BASE_ICFB HB_TAG('i','c','f','b')
333 #define HB_OT_TAG_BASE_ICFT HB_TAG('i','c','f','t')
334 #define HB_OT_TAG_BASE_IDEO HB_TAG('i','d','e','o')
335 #define HB_OT_TAG_BASE_IDTB HB_TAG('i','d','t','b')
336 #define HB_OT_TAG_BASE_MATH HB_TAG('m','a','t','h')
337 #define HB_OT_TAG_BASE_ROMN HB_TAG('r','o','m','n')
338
339 #endif
340
341
342 HB_END_DECLS
343
344 #endif /* HB_OT_LAYOUT_H */