2 * Copyright © 2007,2008,2009 Red Hat, Inc.
4 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
24 * Red Hat Author(s): Behdad Esfahbod
28 #error "Include <hb-ot.h> instead."
31 #ifndef HB_OT_LAYOUT_H
32 #define HB_OT_LAYOUT_H
36 #include "hb-ot-name.h"
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')
49 * Script & Language tags.
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')
56 * HB_OT_MAX_TAGS_PER_SCRIPT:
60 #define HB_OT_MAX_TAGS_PER_SCRIPT 3u
62 * HB_OT_MAX_TAGS_PER_LANGUAGE:
66 #define HB_OT_MAX_TAGS_PER_LANGUAGE 3u
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 */);
77 hb_ot_tag_to_script (hb_tag_t tag);
79 HB_EXTERN hb_language_t
80 hb_ot_tag_to_language (hb_tag_t tag);
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 */);
94 hb_ot_layout_has_glyph_classes (hb_face_t *face);
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
104 * The GDEF classes defined for glyphs.
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;
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);
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 */);
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 */);
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 */);
144 * GSUB/GPOS feature query and enumeration interface
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
152 HB_EXTERN unsigned int
153 hb_ot_layout_table_get_script_tags (hb_face_t *face,
155 unsigned int start_offset,
156 unsigned int *script_count /* IN/OUT */,
157 hb_tag_t *script_tags /* OUT */);
160 hb_ot_layout_table_find_script (hb_face_t *face,
163 unsigned int *script_index /* OUT */);
166 hb_ot_layout_table_select_script (hb_face_t *face,
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 */);
173 HB_EXTERN unsigned int
174 hb_ot_layout_table_get_feature_tags (hb_face_t *face,
176 unsigned int start_offset,
177 unsigned int *feature_count /* IN/OUT */,
178 hb_tag_t *feature_tags /* OUT */);
180 HB_EXTERN unsigned int
181 hb_ot_layout_script_get_language_tags (hb_face_t *face,
183 unsigned int script_index,
184 unsigned int start_offset,
185 unsigned int *language_count /* IN/OUT */,
186 hb_tag_t *language_tags /* OUT */);
189 hb_ot_layout_script_select_language (hb_face_t *face,
191 unsigned int script_index,
192 unsigned int language_count,
193 const hb_tag_t *language_tags,
194 unsigned int *language_index /* OUT */);
197 hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
199 unsigned int script_index,
200 unsigned int language_index,
201 unsigned int *feature_index /* OUT */);
204 hb_ot_layout_language_get_required_feature (hb_face_t *face,
206 unsigned int script_index,
207 unsigned int language_index,
208 unsigned int *feature_index /* OUT */,
209 hb_tag_t *feature_tag /* OUT */);
211 HB_EXTERN unsigned int
212 hb_ot_layout_language_get_feature_indexes (hb_face_t *face,
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 */);
220 HB_EXTERN unsigned int
221 hb_ot_layout_language_get_feature_tags (hb_face_t *face,
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 */);
230 hb_ot_layout_language_find_feature (hb_face_t *face,
232 unsigned int script_index,
233 unsigned int language_index,
234 hb_tag_t feature_tag,
235 unsigned int *feature_index /* OUT */);
237 HB_EXTERN unsigned int
238 hb_ot_layout_feature_get_lookups (hb_face_t *face,
240 unsigned int feature_index,
241 unsigned int start_offset,
242 unsigned int *lookup_count /* IN/OUT */,
243 unsigned int *lookup_indexes /* OUT */);
245 HB_EXTERN unsigned int
246 hb_ot_layout_table_get_lookup_count (hb_face_t *face,
250 hb_ot_layout_collect_features (hb_face_t *face,
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 */);
258 hb_ot_layout_collect_lookups (hb_face_t *face,
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 */);
265 #ifdef HB_EXPERIMENTAL_API
267 hb_ot_layout_closure_lookups (hb_face_t *face,
269 const hb_set_t *glyphs,
270 hb_set_t *lookup_indexes /* IN/OUT */);
273 hb_ot_layout_closure_features (hb_face_t *face,
275 const hb_map_t *lookup_indexes, /* IN */
276 hb_set_t *feature_indexes /* OUT */);
280 hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
282 unsigned int lookup_index,
283 hb_set_t *glyphs_before, /* OUT. May be NULL */
284 hb_set_t *glyphs_input, /* OUT. May be NULL */
285 hb_set_t *glyphs_after, /* OUT. May be NULL */
286 hb_set_t *glyphs_output /* OUT. May be NULL */);
288 #ifdef HB_NOT_IMPLEMENTED
291 const hb_codepoint_t *before,
292 unsigned int before_length,
293 const hb_codepoint_t *input,
294 unsigned int input_length,
295 const hb_codepoint_t *after,
296 unsigned int after_length,
297 } hb_ot_layout_glyph_sequence_t;
300 (*hb_ot_layout_glyph_sequence_func_t) (hb_font_t *font,
302 unsigned int lookup_index,
303 const hb_ot_layout_glyph_sequence_t *sequence,
307 Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t *face,
309 unsigned int lookup_index,
310 hb_ot_layout_glyph_sequence_func_t callback,
314 /* Variations support */
317 hb_ot_layout_table_find_feature_variations (hb_face_t *face,
320 unsigned int num_coords,
321 unsigned int *variations_index /* out */);
323 HB_EXTERN unsigned int
324 hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face,
326 unsigned int feature_index,
327 unsigned int variations_index,
328 unsigned int start_offset,
329 unsigned int *lookup_count /* IN/OUT */,
330 unsigned int *lookup_indexes /* OUT */);
338 hb_ot_layout_has_substitution (hb_face_t *face);
341 hb_ot_layout_lookup_would_substitute (hb_face_t *face,
342 unsigned int lookup_index,
343 const hb_codepoint_t *glyphs,
344 unsigned int glyphs_length,
345 hb_bool_t zero_context);
348 hb_ot_layout_lookup_substitute_closure (hb_face_t *face,
349 unsigned int lookup_index,
351 /*TODO , hb_bool_t inclusive */);
354 hb_ot_layout_lookups_substitute_closure (hb_face_t *face,
355 const hb_set_t *lookups,
359 #ifdef HB_NOT_IMPLEMENTED
360 /* Note: You better have GDEF when using this API, or marks won't do much. */
362 Xhb_ot_layout_lookup_substitute (hb_font_t *font,
363 unsigned int lookup_index,
364 const hb_ot_layout_glyph_sequence_t *sequence,
365 unsigned int out_size,
366 hb_codepoint_t *glyphs_out, /* OUT */
367 unsigned int *clusters_out, /* OUT */
368 unsigned int *out_length /* OUT */);
377 hb_ot_layout_has_positioning (hb_face_t *face);
379 #ifdef HB_NOT_IMPLEMENTED
380 /* Note: You better have GDEF when using this API, or marks won't do much. */
382 Xhb_ot_layout_lookup_position (hb_font_t *font,
383 unsigned int lookup_index,
384 const hb_ot_layout_glyph_sequence_t *sequence,
385 hb_glyph_position_t *positions /* IN / OUT */);
388 /* Optical 'size' feature info. Returns true if found.
389 * https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */
391 hb_ot_layout_get_size_params (hb_face_t *face,
392 unsigned int *design_size, /* OUT. May be NULL */
393 unsigned int *subfamily_id, /* OUT. May be NULL */
394 hb_ot_name_id_t *subfamily_name_id, /* OUT. May be NULL */
395 unsigned int *range_start, /* OUT. May be NULL */
396 unsigned int *range_end /* OUT. May be NULL */);
400 hb_ot_layout_feature_get_name_ids (hb_face_t *face,
402 unsigned int feature_index,
403 hb_ot_name_id_t *label_id /* OUT. May be NULL */,
404 hb_ot_name_id_t *tooltip_id /* OUT. May be NULL */,
405 hb_ot_name_id_t *sample_id /* OUT. May be NULL */,
406 unsigned int *num_named_parameters /* OUT. May be NULL */,
407 hb_ot_name_id_t *first_param_id /* OUT. May be NULL */);
410 HB_EXTERN unsigned int
411 hb_ot_layout_feature_get_characters (hb_face_t *face,
413 unsigned int feature_index,
414 unsigned int start_offset,
415 unsigned int *char_count /* IN/OUT. May be NULL */,
416 hb_codepoint_t *characters /* OUT. May be NULL */);
423 * hb_ot_layout_baseline_tag_t:
424 * @HB_OT_LAYOUT_BASELINE_TAG_ROMAN: The baseline used by alphabetic scripts such as Latin, Cyrillic and Greek.
425 * In vertical writing mode, the alphabetic baseline for characters rotated 90 degrees clockwise.
426 * (This would not apply to alphabetic characters that remain upright in vertical writing mode, since these
427 * characters are not rotated.)
428 * @HB_OT_LAYOUT_BASELINE_TAG_HANGING: The hanging baseline. In horizontal direction, this is the horizontal
429 * line from which syllables seem, to hang in Tibetan and other similar scripts. In vertical writing mode,
430 * for Tibetan (or some other similar script) characters rotated 90 degrees clockwise.
431 * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT: Ideographic character face bottom or left edge,
432 * if the direction is horizontal or vertical, respectively.
433 * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_TOP_OR_RIGHT: Ideographic character face top or right edge,
434 * if the direction is horizontal or vertical, respectively.
435 * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_BOTTOM_OR_LEFT: Ideographic em-box bottom or left edge,
436 * if the direction is horizontal or vertical, respectively.
437 * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_TOP_OR_RIGHT: Ideographic em-box top or right edge baseline,
438 * if the direction is horizontal or vertical, respectively.
439 * @HB_OT_LAYOUT_BASELINE_TAG_MATH: The baseline about which mathematical characters are centered.
440 * In vertical writing mode when mathematical characters rotated 90 degrees clockwise, are centered.
442 * Baseline tags from https://docs.microsoft.com/en-us/typography/opentype/spec/baselinetags
447 HB_OT_LAYOUT_BASELINE_TAG_ROMAN = HB_TAG ('r','o','m','n'),
448 HB_OT_LAYOUT_BASELINE_TAG_HANGING = HB_TAG ('h','a','n','g'),
449 HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT = HB_TAG ('i','c','f','b'),
450 HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_TOP_OR_RIGHT = HB_TAG ('i','c','f','t'),
451 HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_BOTTOM_OR_LEFT = HB_TAG ('i','d','e','o'),
452 HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_TOP_OR_RIGHT = HB_TAG ('i','d','t','p'),
453 HB_OT_LAYOUT_BASELINE_TAG_MATH = HB_TAG ('m','a','t','h'),
455 _HB_OT_LAYOUT_BASELINE_TAG_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/
456 } hb_ot_layout_baseline_tag_t;
459 hb_ot_layout_get_baseline (hb_font_t *font,
460 hb_ot_layout_baseline_tag_t baseline_tag,
461 hb_direction_t direction,
463 hb_tag_t language_tag,
464 hb_position_t *coord /* OUT. May be NULL. */);
469 #endif /* HB_OT_LAYOUT_H */