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-name.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 | * Script & Language tags. |
50 | */ |
51 | |
52 | #define HB_OT_TAG_DEFAULT_SCRIPT HB_TAG ('D', 'F', 'L', 'T') |
53 | #define HB_OT_TAG_DEFAULT_LANGUAGE HB_TAG ('d', 'f', 'l', 't') |
54 | |
55 | /** |
56 | * HB_OT_MAX_TAGS_PER_SCRIPT: |
57 | * |
58 | * Since: 2.0.0 |
59 | **/ |
60 | #define HB_OT_MAX_TAGS_PER_SCRIPT 3u |
61 | /** |
62 | * HB_OT_MAX_TAGS_PER_LANGUAGE: |
63 | * |
64 | * Since: 2.0.0 |
65 | **/ |
66 | #define HB_OT_MAX_TAGS_PER_LANGUAGE 3u |
67 | |
68 | HB_EXTERN void |
69 | hb_ot_tags_from_script_and_language (hb_script_t script, |
70 | hb_language_t language, |
71 | unsigned int *script_count /* IN/OUT */, |
72 | hb_tag_t *script_tags /* OUT */, |
73 | unsigned int *language_count /* IN/OUT */, |
74 | hb_tag_t *language_tags /* OUT */); |
75 | |
76 | HB_EXTERN hb_script_t |
77 | hb_ot_tag_to_script (hb_tag_t tag); |
78 | |
79 | HB_EXTERN hb_language_t |
80 | hb_ot_tag_to_language (hb_tag_t tag); |
81 | |
82 | HB_EXTERN void |
83 | hb_ot_tags_to_script_and_language (hb_tag_t script_tag, |
84 | hb_tag_t language_tag, |
85 | hb_script_t *script /* OUT */, |
86 | hb_language_t *language /* OUT */); |
87 | |
88 | |
89 | /* |
90 | * GDEF |
91 | */ |
92 | |
93 | HB_EXTERN hb_bool_t |
94 | hb_ot_layout_has_glyph_classes (hb_face_t *face); |
95 | |
96 | /** |
97 | * hb_ot_layout_glyph_class_t: |
98 | * @HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED: Glyphs not matching the other classifications |
99 | * @HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH: Spacing, single characters, capable of accepting marks |
100 | * @HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE: Glyphs that represent ligation of multiple characters |
101 | * @HB_OT_LAYOUT_GLYPH_CLASS_MARK: Non-spacing, combining glyphs that represent marks |
102 | * @HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT: Spacing glyphs that represent part of a single character |
103 | * |
104 | * The GDEF classes defined for glyphs. |
105 | * |
106 | **/ |
107 | typedef enum { |
108 | HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0, |
109 | HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 1, |
110 | HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 2, |
111 | HB_OT_LAYOUT_GLYPH_CLASS_MARK = 3, |
112 | HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT = 4 |
113 | } hb_ot_layout_glyph_class_t; |
114 | |
115 | HB_EXTERN hb_ot_layout_glyph_class_t |
116 | hb_ot_layout_get_glyph_class (hb_face_t *face, |
117 | hb_codepoint_t glyph); |
118 | |
119 | HB_EXTERN void |
120 | hb_ot_layout_get_glyphs_in_class (hb_face_t *face, |
121 | hb_ot_layout_glyph_class_t klass, |
122 | hb_set_t *glyphs /* OUT */); |
123 | |
124 | /* Not that useful. Provides list of attach points for a glyph that a |
125 | * client may want to cache */ |
126 | HB_EXTERN unsigned int |
127 | hb_ot_layout_get_attach_points (hb_face_t *face, |
128 | hb_codepoint_t glyph, |
129 | unsigned int start_offset, |
130 | unsigned int *point_count /* IN/OUT */, |
131 | unsigned int *point_array /* OUT */); |
132 | |
133 | /* Ligature caret positions */ |
134 | HB_EXTERN unsigned int |
135 | hb_ot_layout_get_ligature_carets (hb_font_t *font, |
136 | hb_direction_t direction, |
137 | hb_codepoint_t glyph, |
138 | unsigned int start_offset, |
139 | unsigned int *caret_count /* IN/OUT */, |
140 | hb_position_t *caret_array /* OUT */); |
141 | |
142 | |
143 | /* |
144 | * GSUB/GPOS feature query and enumeration interface |
145 | */ |
146 | |
147 | #define HB_OT_LAYOUT_NO_SCRIPT_INDEX 0xFFFFu |
148 | #define HB_OT_LAYOUT_NO_FEATURE_INDEX 0xFFFFu |
149 | #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX 0xFFFFu |
150 | #define HB_OT_LAYOUT_NO_VARIATIONS_INDEX 0xFFFFFFFFu |
151 | |
152 | HB_EXTERN unsigned int |
153 | hb_ot_layout_table_get_script_tags (hb_face_t *face, |
154 | hb_tag_t table_tag, |
155 | unsigned int start_offset, |
156 | unsigned int *script_count /* IN/OUT */, |
157 | hb_tag_t *script_tags /* OUT */); |
158 | |
159 | HB_EXTERN hb_bool_t |
160 | hb_ot_layout_table_find_script (hb_face_t *face, |
161 | hb_tag_t table_tag, |
162 | hb_tag_t script_tag, |
163 | unsigned int *script_index /* OUT */); |
164 | |
165 | HB_EXTERN hb_bool_t |
166 | hb_ot_layout_table_select_script (hb_face_t *face, |
167 | hb_tag_t table_tag, |
168 | unsigned int script_count, |
169 | const hb_tag_t *script_tags, |
170 | unsigned int *script_index /* OUT */, |
171 | hb_tag_t *chosen_script /* OUT */); |
172 | |
173 | HB_EXTERN unsigned int |
174 | hb_ot_layout_table_get_feature_tags (hb_face_t *face, |
175 | hb_tag_t table_tag, |
176 | unsigned int start_offset, |
177 | unsigned int *feature_count /* IN/OUT */, |
178 | hb_tag_t *feature_tags /* OUT */); |
179 | |
180 | HB_EXTERN unsigned int |
181 | hb_ot_layout_script_get_language_tags (hb_face_t *face, |
182 | hb_tag_t table_tag, |
183 | unsigned int script_index, |
184 | unsigned int start_offset, |
185 | unsigned int *language_count /* IN/OUT */, |
186 | hb_tag_t *language_tags /* OUT */); |
187 | |
188 | HB_EXTERN hb_bool_t |
189 | hb_ot_layout_script_select_language (hb_face_t *face, |
190 | hb_tag_t table_tag, |
191 | unsigned int script_index, |
192 | unsigned int language_count, |
193 | const hb_tag_t *language_tags, |
194 | unsigned int *language_index /* OUT */); |
195 | |
196 | HB_EXTERN hb_bool_t |
197 | hb_ot_layout_language_get_required_feature_index (hb_face_t *face, |
198 | hb_tag_t table_tag, |
199 | unsigned int script_index, |
200 | unsigned int language_index, |
201 | unsigned int *feature_index /* OUT */); |
202 | |
203 | HB_EXTERN hb_bool_t |
204 | hb_ot_layout_language_get_required_feature (hb_face_t *face, |
205 | hb_tag_t table_tag, |
206 | unsigned int script_index, |
207 | unsigned int language_index, |
208 | unsigned int *feature_index /* OUT */, |
209 | hb_tag_t *feature_tag /* OUT */); |
210 | |
211 | HB_EXTERN unsigned int |
212 | hb_ot_layout_language_get_feature_indexes (hb_face_t *face, |
213 | hb_tag_t table_tag, |
214 | unsigned int script_index, |
215 | unsigned int language_index, |
216 | unsigned int start_offset, |
217 | unsigned int *feature_count /* IN/OUT */, |
218 | unsigned int *feature_indexes /* OUT */); |
219 | |
220 | HB_EXTERN unsigned int |
221 | hb_ot_layout_language_get_feature_tags (hb_face_t *face, |
222 | hb_tag_t table_tag, |
223 | unsigned int script_index, |
224 | unsigned int language_index, |
225 | unsigned int start_offset, |
226 | unsigned int *feature_count /* IN/OUT */, |
227 | hb_tag_t *feature_tags /* OUT */); |
228 | |
229 | HB_EXTERN hb_bool_t |
230 | hb_ot_layout_language_find_feature (hb_face_t *face, |
231 | hb_tag_t table_tag, |
232 | unsigned int script_index, |
233 | unsigned int language_index, |
234 | hb_tag_t feature_tag, |
235 | unsigned int *feature_index /* OUT */); |
236 | |
237 | HB_EXTERN unsigned int |
238 | hb_ot_layout_feature_get_lookups (hb_face_t *face, |
239 | hb_tag_t table_tag, |
240 | unsigned int feature_index, |
241 | unsigned int start_offset, |
242 | unsigned int *lookup_count /* IN/OUT */, |
243 | unsigned int *lookup_indexes /* OUT */); |
244 | |
245 | HB_EXTERN unsigned int |
246 | hb_ot_layout_table_get_lookup_count (hb_face_t *face, |
247 | hb_tag_t table_tag); |
248 | |
249 | HB_EXTERN void |
250 | hb_ot_layout_collect_features (hb_face_t *face, |
251 | hb_tag_t table_tag, |
252 | const hb_tag_t *scripts, |
253 | const hb_tag_t *languages, |
254 | const hb_tag_t *features, |
255 | hb_set_t *feature_indexes /* OUT */); |
256 | |
257 | HB_EXTERN void |
258 | hb_ot_layout_collect_lookups (hb_face_t *face, |
259 | hb_tag_t table_tag, |
260 | const hb_tag_t *scripts, |
261 | const hb_tag_t *languages, |
262 | const hb_tag_t *features, |
263 | hb_set_t *lookup_indexes /* OUT */); |
264 | |
265 | HB_EXTERN void |
266 | hb_ot_layout_lookup_collect_glyphs (hb_face_t *face, |
267 | hb_tag_t table_tag, |
268 | unsigned int lookup_index, |
269 | hb_set_t *glyphs_before, /* OUT. May be NULL */ |
270 | hb_set_t *glyphs_input, /* OUT. May be NULL */ |
271 | hb_set_t *glyphs_after, /* OUT. May be NULL */ |
272 | hb_set_t *glyphs_output /* OUT. May be NULL */); |
273 | |
274 | #ifdef HB_NOT_IMPLEMENTED |
275 | typedef struct |
276 | { |
277 | const hb_codepoint_t *before, |
278 | unsigned int before_length, |
279 | const hb_codepoint_t *input, |
280 | unsigned int input_length, |
281 | const hb_codepoint_t *after, |
282 | unsigned int after_length, |
283 | } hb_ot_layout_glyph_sequence_t; |
284 | |
285 | typedef hb_bool_t |
286 | (*hb_ot_layout_glyph_sequence_func_t) (hb_font_t *font, |
287 | hb_tag_t table_tag, |
288 | unsigned int lookup_index, |
289 | const hb_ot_layout_glyph_sequence_t *sequence, |
290 | void *user_data); |
291 | |
292 | HB_EXTERN void |
293 | Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t *face, |
294 | hb_tag_t table_tag, |
295 | unsigned int lookup_index, |
296 | hb_ot_layout_glyph_sequence_func_t callback, |
297 | void *user_data); |
298 | #endif |
299 | |
300 | /* Variations support */ |
301 | |
302 | HB_EXTERN hb_bool_t |
303 | hb_ot_layout_table_find_feature_variations (hb_face_t *face, |
304 | hb_tag_t table_tag, |
305 | const int *coords, |
306 | unsigned int num_coords, |
307 | unsigned int *variations_index /* out */); |
308 | |
309 | HB_EXTERN unsigned int |
310 | hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, |
311 | hb_tag_t table_tag, |
312 | unsigned int feature_index, |
313 | unsigned int variations_index, |
314 | unsigned int start_offset, |
315 | unsigned int *lookup_count /* IN/OUT */, |
316 | unsigned int *lookup_indexes /* OUT */); |
317 | |
318 | |
319 | /* |
320 | * GSUB |
321 | */ |
322 | |
323 | HB_EXTERN hb_bool_t |
324 | hb_ot_layout_has_substitution (hb_face_t *face); |
325 | |
326 | HB_EXTERN unsigned |
327 | hb_ot_layout_lookup_get_glyph_alternates (hb_face_t *face, |
328 | unsigned lookup_index, |
329 | hb_codepoint_t glyph, |
330 | unsigned start_offset, |
331 | unsigned *alternate_count /* IN/OUT */, |
332 | hb_codepoint_t *alternate_glyphs /* OUT */); |
333 | |
334 | HB_EXTERN hb_bool_t |
335 | hb_ot_layout_lookup_would_substitute (hb_face_t *face, |
336 | unsigned int lookup_index, |
337 | const hb_codepoint_t *glyphs, |
338 | unsigned int glyphs_length, |
339 | hb_bool_t zero_context); |
340 | |
341 | HB_EXTERN void |
342 | hb_ot_layout_lookup_substitute_closure (hb_face_t *face, |
343 | unsigned int lookup_index, |
344 | hb_set_t *glyphs |
345 | /*TODO , hb_bool_t inclusive */); |
346 | |
347 | HB_EXTERN void |
348 | hb_ot_layout_lookups_substitute_closure (hb_face_t *face, |
349 | const hb_set_t *lookups, |
350 | hb_set_t *glyphs); |
351 | |
352 | |
353 | #ifdef HB_NOT_IMPLEMENTED |
354 | /* Note: You better have GDEF when using this API, or marks won't do much. */ |
355 | HB_EXTERN hb_bool_t |
356 | Xhb_ot_layout_lookup_substitute (hb_font_t *font, |
357 | unsigned int lookup_index, |
358 | const hb_ot_layout_glyph_sequence_t *sequence, |
359 | unsigned int out_size, |
360 | hb_codepoint_t *glyphs_out, /* OUT */ |
361 | unsigned int *clusters_out, /* OUT */ |
362 | unsigned int *out_length /* OUT */); |
363 | #endif |
364 | |
365 | |
366 | /* |
367 | * GPOS |
368 | */ |
369 | |
370 | HB_EXTERN hb_bool_t |
371 | hb_ot_layout_has_positioning (hb_face_t *face); |
372 | |
373 | #ifdef HB_NOT_IMPLEMENTED |
374 | /* Note: You better have GDEF when using this API, or marks won't do much. */ |
375 | HB_EXTERN hb_bool_t |
376 | Xhb_ot_layout_lookup_position (hb_font_t *font, |
377 | unsigned int lookup_index, |
378 | const hb_ot_layout_glyph_sequence_t *sequence, |
379 | hb_glyph_position_t *positions /* IN / OUT */); |
380 | #endif |
381 | |
382 | /* Optical 'size' feature info. Returns true if found. |
383 | * https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */ |
384 | HB_EXTERN hb_bool_t |
385 | hb_ot_layout_get_size_params (hb_face_t *face, |
386 | unsigned int *design_size, /* OUT. May be NULL */ |
387 | unsigned int *subfamily_id, /* OUT. May be NULL */ |
388 | hb_ot_name_id_t *subfamily_name_id, /* OUT. May be NULL */ |
389 | unsigned int *range_start, /* OUT. May be NULL */ |
390 | unsigned int *range_end /* OUT. May be NULL */); |
391 | |
392 | |
393 | HB_EXTERN hb_bool_t |
394 | hb_ot_layout_feature_get_name_ids (hb_face_t *face, |
395 | hb_tag_t table_tag, |
396 | unsigned int feature_index, |
397 | hb_ot_name_id_t *label_id /* OUT. May be NULL */, |
398 | hb_ot_name_id_t *tooltip_id /* OUT. May be NULL */, |
399 | hb_ot_name_id_t *sample_id /* OUT. May be NULL */, |
400 | unsigned int *num_named_parameters /* OUT. May be NULL */, |
401 | hb_ot_name_id_t *first_param_id /* OUT. May be NULL */); |
402 | |
403 | |
404 | HB_EXTERN unsigned int |
405 | hb_ot_layout_feature_get_characters (hb_face_t *face, |
406 | hb_tag_t table_tag, |
407 | unsigned int feature_index, |
408 | unsigned int start_offset, |
409 | unsigned int *char_count /* IN/OUT. May be NULL */, |
410 | hb_codepoint_t *characters /* OUT. May be NULL */); |
411 | |
412 | /* |
413 | * BASE |
414 | */ |
415 | |
416 | /** |
417 | * hb_ot_layout_baseline_tag_t: |
418 | * @HB_OT_LAYOUT_BASELINE_TAG_ROMAN: The baseline used by alphabetic scripts such as Latin, Cyrillic and Greek. |
419 | * In vertical writing mode, the alphabetic baseline for characters rotated 90 degrees clockwise. |
420 | * (This would not apply to alphabetic characters that remain upright in vertical writing mode, since these |
421 | * characters are not rotated.) |
422 | * @HB_OT_LAYOUT_BASELINE_TAG_HANGING: The hanging baseline. In horizontal direction, this is the horizontal |
423 | * line from which syllables seem, to hang in Tibetan and other similar scripts. In vertical writing mode, |
424 | * for Tibetan (or some other similar script) characters rotated 90 degrees clockwise. |
425 | * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT: Ideographic character face bottom or left edge, |
426 | * if the direction is horizontal or vertical, respectively. |
427 | * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_TOP_OR_RIGHT: Ideographic character face top or right edge, |
428 | * if the direction is horizontal or vertical, respectively. |
429 | * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_BOTTOM_OR_LEFT: Ideographic em-box bottom or left edge, |
430 | * if the direction is horizontal or vertical, respectively. |
431 | * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_TOP_OR_RIGHT: Ideographic em-box top or right edge baseline, |
432 | * if the direction is horizontal or vertical, respectively. |
433 | * @HB_OT_LAYOUT_BASELINE_TAG_MATH: The baseline about which mathematical characters are centered. |
434 | * In vertical writing mode when mathematical characters rotated 90 degrees clockwise, are centered. |
435 | * |
436 | * Baseline tags from https://docs.microsoft.com/en-us/typography/opentype/spec/baselinetags |
437 | * |
438 | * Since: 2.6.0 |
439 | */ |
440 | typedef enum { |
441 | HB_OT_LAYOUT_BASELINE_TAG_ROMAN = HB_TAG ('r','o','m','n'), |
442 | HB_OT_LAYOUT_BASELINE_TAG_HANGING = HB_TAG ('h','a','n','g'), |
443 | HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT = HB_TAG ('i','c','f','b'), |
444 | HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_TOP_OR_RIGHT = HB_TAG ('i','c','f','t'), |
445 | HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_BOTTOM_OR_LEFT = HB_TAG ('i','d','e','o'), |
446 | HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_TOP_OR_RIGHT = HB_TAG ('i','d','t','p'), |
447 | HB_OT_LAYOUT_BASELINE_TAG_MATH = HB_TAG ('m','a','t','h'), |
448 | |
449 | _HB_OT_LAYOUT_BASELINE_TAG_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/ |
450 | } hb_ot_layout_baseline_tag_t; |
451 | |
452 | HB_EXTERN hb_bool_t |
453 | hb_ot_layout_get_baseline (hb_font_t *font, |
454 | hb_ot_layout_baseline_tag_t baseline_tag, |
455 | hb_direction_t direction, |
456 | hb_tag_t script_tag, |
457 | hb_tag_t language_tag, |
458 | hb_position_t *coord /* OUT. May be NULL. */); |
459 | |
460 | HB_END_DECLS |
461 | |
462 | #endif /* HB_OT_LAYOUT_H */ |
463 | |