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 */);
125 /* Not that useful. Provides list of attach points for a glyph that a
126 * client may want to cache */
127 HB_EXTERN unsigned int
128 hb_ot_layout_get_attach_points (hb_face_t *face,
129 hb_codepoint_t glyph,
130 unsigned int start_offset,
131 unsigned int *point_count /* IN/OUT */,
132 unsigned int *point_array /* OUT */);
134 /* Ligature caret positions */
135 HB_EXTERN unsigned int
136 hb_ot_layout_get_ligature_carets (hb_font_t *font,
137 hb_direction_t direction,
138 hb_codepoint_t glyph,
139 unsigned int start_offset,
140 unsigned int *caret_count /* IN/OUT */,
141 hb_position_t *caret_array /* OUT */);
145 * GSUB/GPOS feature query and enumeration interface
148 #define HB_OT_LAYOUT_NO_SCRIPT_INDEX 0xFFFFu
149 #define HB_OT_LAYOUT_NO_FEATURE_INDEX 0xFFFFu
150 #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX 0xFFFFu
151 #define HB_OT_LAYOUT_NO_VARIATIONS_INDEX 0xFFFFFFFFu
153 HB_EXTERN unsigned int
154 hb_ot_layout_table_get_script_tags (hb_face_t *face,
156 unsigned int start_offset,
157 unsigned int *script_count /* IN/OUT */,
158 hb_tag_t *script_tags /* OUT */);
161 hb_ot_layout_table_find_script (hb_face_t *face,
164 unsigned int *script_index);
167 hb_ot_layout_table_select_script (hb_face_t *face,
169 unsigned int script_count,
170 const hb_tag_t *script_tags,
171 unsigned int *script_index /* OUT */,
172 hb_tag_t *chosen_script /* OUT */);
174 HB_EXTERN unsigned int
175 hb_ot_layout_table_get_feature_tags (hb_face_t *face,
177 unsigned int start_offset,
178 unsigned int *feature_count /* IN/OUT */,
179 hb_tag_t *feature_tags /* OUT */);
181 HB_EXTERN unsigned int
182 hb_ot_layout_script_get_language_tags (hb_face_t *face,
184 unsigned int script_index,
185 unsigned int start_offset,
186 unsigned int *language_count /* IN/OUT */,
187 hb_tag_t *language_tags /* OUT */);
190 hb_ot_layout_script_select_language (hb_face_t *face,
192 unsigned int script_index,
193 unsigned int language_count,
194 const hb_tag_t *language_tags,
195 unsigned int *language_index /* OUT */);
198 hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
200 unsigned int script_index,
201 unsigned int language_index,
202 unsigned int *feature_index);
205 hb_ot_layout_language_get_required_feature (hb_face_t *face,
207 unsigned int script_index,
208 unsigned int language_index,
209 unsigned int *feature_index,
210 hb_tag_t *feature_tag);
212 HB_EXTERN unsigned int
213 hb_ot_layout_language_get_feature_indexes (hb_face_t *face,
215 unsigned int script_index,
216 unsigned int language_index,
217 unsigned int start_offset,
218 unsigned int *feature_count /* IN/OUT */,
219 unsigned int *feature_indexes /* OUT */);
221 HB_EXTERN unsigned int
222 hb_ot_layout_language_get_feature_tags (hb_face_t *face,
224 unsigned int script_index,
225 unsigned int language_index,
226 unsigned int start_offset,
227 unsigned int *feature_count /* IN/OUT */,
228 hb_tag_t *feature_tags /* OUT */);
231 hb_ot_layout_language_find_feature (hb_face_t *face,
233 unsigned int script_index,
234 unsigned int language_index,
235 hb_tag_t feature_tag,
236 unsigned int *feature_index);
238 HB_EXTERN unsigned int
239 hb_ot_layout_feature_get_lookups (hb_face_t *face,
241 unsigned int feature_index,
242 unsigned int start_offset,
243 unsigned int *lookup_count /* IN/OUT */,
244 unsigned int *lookup_indexes /* OUT */);
246 HB_EXTERN unsigned int
247 hb_ot_layout_table_get_lookup_count (hb_face_t *face,
251 hb_ot_layout_collect_features (hb_face_t *face,
253 const hb_tag_t *scripts,
254 const hb_tag_t *languages,
255 const hb_tag_t *features,
256 hb_set_t *feature_indexes /* OUT */);
259 hb_ot_layout_collect_lookups (hb_face_t *face,
261 const hb_tag_t *scripts,
262 const hb_tag_t *languages,
263 const hb_tag_t *features,
264 hb_set_t *lookup_indexes /* OUT */);
267 hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
269 unsigned int lookup_index,
270 hb_set_t *glyphs_before, /* OUT. May be NULL */
271 hb_set_t *glyphs_input, /* OUT. May be NULL */
272 hb_set_t *glyphs_after, /* OUT. May be NULL */
273 hb_set_t *glyphs_output /* OUT. May be NULL */);
275 #ifdef HB_NOT_IMPLEMENTED
278 const hb_codepoint_t *before,
279 unsigned int before_length,
280 const hb_codepoint_t *input,
281 unsigned int input_length,
282 const hb_codepoint_t *after,
283 unsigned int after_length,
284 } hb_ot_layout_glyph_sequence_t;
287 (*hb_ot_layout_glyph_sequence_func_t) (hb_font_t *font,
289 unsigned int lookup_index,
290 const hb_ot_layout_glyph_sequence_t *sequence,
294 Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t *face,
296 unsigned int lookup_index,
297 hb_ot_layout_glyph_sequence_func_t callback,
301 /* Variations support */
304 hb_ot_layout_table_find_feature_variations (hb_face_t *face,
307 unsigned int num_coords,
308 unsigned int *variations_index /* out */);
310 HB_EXTERN unsigned int
311 hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face,
313 unsigned int feature_index,
314 unsigned int variations_index,
315 unsigned int start_offset,
316 unsigned int *lookup_count /* IN/OUT */,
317 unsigned int *lookup_indexes /* OUT */);
325 hb_ot_layout_has_substitution (hb_face_t *face);
328 hb_ot_layout_lookup_would_substitute (hb_face_t *face,
329 unsigned int lookup_index,
330 const hb_codepoint_t *glyphs,
331 unsigned int glyphs_length,
332 hb_bool_t zero_context);
335 hb_ot_layout_lookup_substitute_closure (hb_face_t *face,
336 unsigned int lookup_index,
338 /*TODO , hb_bool_t inclusive */);
341 hb_ot_layout_lookups_substitute_closure (hb_face_t *face,
342 const hb_set_t *lookups,
346 #ifdef HB_NOT_IMPLEMENTED
347 /* Note: You better have GDEF when using this API, or marks won't do much. */
349 Xhb_ot_layout_lookup_substitute (hb_font_t *font,
350 unsigned int lookup_index,
351 const hb_ot_layout_glyph_sequence_t *sequence,
352 unsigned int out_size,
353 hb_codepoint_t *glyphs_out, /* OUT */
354 unsigned int *clusters_out, /* OUT */
355 unsigned int *out_length /* OUT */);
364 hb_ot_layout_has_positioning (hb_face_t *face);
366 #ifdef HB_NOT_IMPLEMENTED
367 /* Note: You better have GDEF when using this API, or marks won't do much. */
369 Xhb_ot_layout_lookup_position (hb_font_t *font,
370 unsigned int lookup_index,
371 const hb_ot_layout_glyph_sequence_t *sequence,
372 hb_glyph_position_t *positions /* IN / OUT */);
375 /* Optical 'size' feature info. Returns true if found.
376 * https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */
378 hb_ot_layout_get_size_params (hb_face_t *face,
379 unsigned int *design_size, /* OUT. May be NULL */
380 unsigned int *subfamily_id, /* OUT. May be NULL */
381 hb_ot_name_id_t *subfamily_name_id, /* OUT. May be NULL */
382 unsigned int *range_start, /* OUT. May be NULL */
383 unsigned int *range_end /* OUT. May be NULL */);
387 hb_ot_layout_feature_get_name_ids (hb_face_t *face,
389 unsigned int feature_index,
390 hb_ot_name_id_t *label_id /* OUT. May be NULL */,
391 hb_ot_name_id_t *tooltip_id /* OUT. May be NULL */,
392 hb_ot_name_id_t *sample_id /* OUT. May be NULL */,
393 unsigned int *num_named_parameters /* OUT. May be NULL */,
394 hb_ot_name_id_t *first_param_id /* OUT. May be NULL */);
397 HB_EXTERN unsigned int
398 hb_ot_layout_feature_get_characters (hb_face_t *face,
400 unsigned int feature_index,
401 unsigned int start_offset,
402 unsigned int *char_count /* IN/OUT. May be NULL */,
403 hb_codepoint_t *characters /* OUT. May be NULL */);
410 * hb_ot_layout_baseline_tag_t:
411 * @HB_OT_LAYOUT_BASELINE_TAG_ROMAN: The baseline used by alphabetic scripts such as Latin, Cyrillic and Greek.
412 * In vertical writing mode, the alphabetic baseline for characters rotated 90 degrees clockwise.
413 * (This would not apply to alphabetic characters that remain upright in vertical writing mode, since these
414 * characters are not rotated.)
415 * @HB_OT_LAYOUT_BASELINE_TAG_HANGING: The hanging baseline. In horizontal direction, this is the horizontal
416 * line from which syllables seem, to hang in Tibetan and other similar scripts. In vertical writing mode,
417 * for Tibetan (or some other similar script) characters rotated 90 degrees clockwise.
418 * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT: Ideographic character face bottom or left edge,
419 * if the direction is horizontal or vertical, respectively.
420 * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_TOP_OR_RIGHT: Ideographic character face top or right edge,
421 * if the direction is horizontal or vertical, respectively.
422 * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_BOTTOM_OR_LEFT: Ideographic em-box bottom or left edge,
423 * if the direction is horizontal or vertical, respectively.
424 * @HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_TOP_OR_RIGHT: Ideographic em-box top or right edge baseline,
425 * if the direction is horizontal or vertical, respectively.
426 * @HB_OT_LAYOUT_BASELINE_TAG_MATH: The baseline about which mathematical characters are centered.
427 * In vertical writing mode when mathematical characters rotated 90 degrees clockwise, are centered.
429 * Baseline tags from https://docs.microsoft.com/en-us/typography/opentype/spec/baselinetags
434 HB_OT_LAYOUT_BASELINE_TAG_ROMAN = HB_TAG ('r','o','m','n'),
435 HB_OT_LAYOUT_BASELINE_TAG_HANGING = HB_TAG ('h','a','n','g'),
436 HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_BOTTOM_OR_LEFT = HB_TAG ('i','c','f','b'),
437 HB_OT_LAYOUT_BASELINE_TAG_IDEO_FACE_TOP_OR_RIGHT = HB_TAG ('i','c','f','t'),
438 HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_BOTTOM_OR_LEFT = HB_TAG ('i','d','e','o'),
439 HB_OT_LAYOUT_BASELINE_TAG_IDEO_EMBOX_TOP_OR_RIGHT = HB_TAG ('i','d','t','p'),
440 HB_OT_LAYOUT_BASELINE_TAG_MATH = HB_TAG ('m','a','t','h'),
442 _HB_OT_LAYOUT_BASELINE_TAG_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/
443 } hb_ot_layout_baseline_tag_t;
446 hb_ot_layout_get_baseline (hb_font_t *font,
447 hb_ot_layout_baseline_tag_t baseline_tag,
448 hb_direction_t direction,
450 hb_tag_t language_tag,
451 hb_position_t *coord /* OUT. May be NULL. */);
456 #endif /* HB_OT_LAYOUT_H */