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 typedef enum { 97 HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0, 98 HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 1, 99 HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 2, 100 HB_OT_LAYOUT_GLYPH_CLASS_MARK = 3, 101 HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT = 4 102 } hb_ot_layout_glyph_class_t; 103 104 HB_EXTERN hb_ot_layout_glyph_class_t 105 hb_ot_layout_get_glyph_class (hb_face_t *face, 106 hb_codepoint_t glyph); 107 108 HB_EXTERN void 109 hb_ot_layout_get_glyphs_in_class (hb_face_t *face, 110 hb_ot_layout_glyph_class_t klass, 111 hb_set_t *glyphs /* OUT */); 112 113 114 /* Not that useful. Provides list of attach points for a glyph that a 115 * client may want to cache */ 116 HB_EXTERN unsigned int 117 hb_ot_layout_get_attach_points (hb_face_t *face, 118 hb_codepoint_t glyph, 119 unsigned int start_offset, 120 unsigned int *point_count /* IN/OUT */, 121 unsigned int *point_array /* OUT */); 122 123 /* Ligature caret positions */ 124 HB_EXTERN unsigned int 125 hb_ot_layout_get_ligature_carets (hb_font_t *font, 126 hb_direction_t direction, 127 hb_codepoint_t glyph, 128 unsigned int start_offset, 129 unsigned int *caret_count /* IN/OUT */, 130 hb_position_t *caret_array /* OUT */); 131 132 133 /* 134 * GSUB/GPOS feature query and enumeration interface 135 */ 136 137 #define HB_OT_LAYOUT_NO_SCRIPT_INDEX 0xFFFFu 138 #define HB_OT_LAYOUT_NO_FEATURE_INDEX 0xFFFFu 139 #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX 0xFFFFu 140 #define HB_OT_LAYOUT_NO_VARIATIONS_INDEX 0xFFFFFFFFu 141 142 HB_EXTERN unsigned int 143 hb_ot_layout_table_get_script_tags (hb_face_t *face, 144 hb_tag_t table_tag, 145 unsigned int start_offset, 146 unsigned int *script_count /* IN/OUT */, 147 hb_tag_t *script_tags /* OUT */); 148 149 HB_EXTERN hb_bool_t 150 hb_ot_layout_table_find_script (hb_face_t *face, 151 hb_tag_t table_tag, 152 hb_tag_t script_tag, 153 unsigned int *script_index); 154 155 HB_EXTERN hb_bool_t 156 hb_ot_layout_table_select_script (hb_face_t *face, 157 hb_tag_t table_tag, 158 unsigned int script_count, 159 const hb_tag_t *script_tags, 160 unsigned int *script_index /* OUT */, 161 hb_tag_t *chosen_script /* OUT */); 162 163 HB_EXTERN unsigned int 164 hb_ot_layout_table_get_feature_tags (hb_face_t *face, 165 hb_tag_t table_tag, 166 unsigned int start_offset, 167 unsigned int *feature_count /* IN/OUT */, 168 hb_tag_t *feature_tags /* OUT */); 169 170 HB_EXTERN unsigned int 171 hb_ot_layout_script_get_language_tags (hb_face_t *face, 172 hb_tag_t table_tag, 173 unsigned int script_index, 174 unsigned int start_offset, 175 unsigned int *language_count /* IN/OUT */, 176 hb_tag_t *language_tags /* OUT */); 177 178 HB_EXTERN hb_bool_t 179 hb_ot_layout_script_select_language (hb_face_t *face, 180 hb_tag_t table_tag, 181 unsigned int script_index, 182 unsigned int language_count, 183 const hb_tag_t *language_tags, 184 unsigned int *language_index /* OUT */); 185 186 HB_EXTERN hb_bool_t 187 hb_ot_layout_language_get_required_feature_index (hb_face_t *face, 188 hb_tag_t table_tag, 189 unsigned int script_index, 190 unsigned int language_index, 191 unsigned int *feature_index); 192 193 HB_EXTERN hb_bool_t 194 hb_ot_layout_language_get_required_feature (hb_face_t *face, 195 hb_tag_t table_tag, 196 unsigned int script_index, 197 unsigned int language_index, 198 unsigned int *feature_index, 199 hb_tag_t *feature_tag); 200 201 HB_EXTERN unsigned int 202 hb_ot_layout_language_get_feature_indexes (hb_face_t *face, 203 hb_tag_t table_tag, 204 unsigned int script_index, 205 unsigned int language_index, 206 unsigned int start_offset, 207 unsigned int *feature_count /* IN/OUT */, 208 unsigned int *feature_indexes /* OUT */); 209 210 HB_EXTERN unsigned int 211 hb_ot_layout_language_get_feature_tags (hb_face_t *face, 212 hb_tag_t table_tag, 213 unsigned int script_index, 214 unsigned int language_index, 215 unsigned int start_offset, 216 unsigned int *feature_count /* IN/OUT */, 217 hb_tag_t *feature_tags /* OUT */); 218 219 HB_EXTERN hb_bool_t 220 hb_ot_layout_language_find_feature (hb_face_t *face, 221 hb_tag_t table_tag, 222 unsigned int script_index, 223 unsigned int language_index, 224 hb_tag_t feature_tag, 225 unsigned int *feature_index); 226 227 HB_EXTERN unsigned int 228 hb_ot_layout_feature_get_lookups (hb_face_t *face, 229 hb_tag_t table_tag, 230 unsigned int feature_index, 231 unsigned int start_offset, 232 unsigned int *lookup_count /* IN/OUT */, 233 unsigned int *lookup_indexes /* OUT */); 234 235 HB_EXTERN unsigned int 236 hb_ot_layout_table_get_lookup_count (hb_face_t *face, 237 hb_tag_t table_tag); 238 239 HB_EXTERN void 240 hb_ot_layout_collect_features (hb_face_t *face, 241 hb_tag_t table_tag, 242 const hb_tag_t *scripts, 243 const hb_tag_t *languages, 244 const hb_tag_t *features, 245 hb_set_t *feature_indexes /* OUT */); 246 247 HB_EXTERN void 248 hb_ot_layout_collect_lookups (hb_face_t *face, 249 hb_tag_t table_tag, 250 const hb_tag_t *scripts, 251 const hb_tag_t *languages, 252 const hb_tag_t *features, 253 hb_set_t *lookup_indexes /* OUT */); 254 255 HB_EXTERN void 256 hb_ot_layout_lookup_collect_glyphs (hb_face_t *face, 257 hb_tag_t table_tag, 258 unsigned int lookup_index, 259 hb_set_t *glyphs_before, /* OUT. May be NULL */ 260 hb_set_t *glyphs_input, /* OUT. May be NULL */ 261 hb_set_t *glyphs_after, /* OUT. May be NULL */ 262 hb_set_t *glyphs_output /* OUT. May be NULL */); 263 264 #ifdef HB_NOT_IMPLEMENTED 265 typedef struct 266 { 267 const hb_codepoint_t *before, 268 unsigned int before_length, 269 const hb_codepoint_t *input, 270 unsigned int input_length, 271 const hb_codepoint_t *after, 272 unsigned int after_length, 273 } hb_ot_layout_glyph_sequence_t; 274 275 typedef hb_bool_t 276 (*hb_ot_layout_glyph_sequence_func_t) (hb_font_t *font, 277 hb_tag_t table_tag, 278 unsigned int lookup_index, 279 const hb_ot_layout_glyph_sequence_t *sequence, 280 void *user_data); 281 282 HB_EXTERN void 283 Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t *face, 284 hb_tag_t table_tag, 285 unsigned int lookup_index, 286 hb_ot_layout_glyph_sequence_func_t callback, 287 void *user_data); 288 #endif 289 290 /* Variations support */ 291 292 HB_EXTERN hb_bool_t 293 hb_ot_layout_table_find_feature_variations (hb_face_t *face, 294 hb_tag_t table_tag, 295 const int *coords, 296 unsigned int num_coords, 297 unsigned int *variations_index /* out */); 298 299 HB_EXTERN unsigned int 300 hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, 301 hb_tag_t table_tag, 302 unsigned int feature_index, 303 unsigned int variations_index, 304 unsigned int start_offset, 305 unsigned int *lookup_count /* IN/OUT */, 306 unsigned int *lookup_indexes /* OUT */); 307 308 309 /* 310 * GSUB 311 */ 312 313 HB_EXTERN hb_bool_t 314 hb_ot_layout_has_substitution (hb_face_t *face); 315 316 HB_EXTERN hb_bool_t 317 hb_ot_layout_lookup_would_substitute (hb_face_t *face, 318 unsigned int lookup_index, 319 const hb_codepoint_t *glyphs, 320 unsigned int glyphs_length, 321 hb_bool_t zero_context); 322 323 HB_EXTERN void 324 hb_ot_layout_lookup_substitute_closure (hb_face_t *face, 325 unsigned int lookup_index, 326 hb_set_t *glyphs 327 /*TODO , hb_bool_t inclusive */); 328 329 HB_EXTERN void 330 hb_ot_layout_lookups_substitute_closure (hb_face_t *face, 331 const hb_set_t *lookups, 332 hb_set_t *glyphs); 333 334 335 #ifdef HB_NOT_IMPLEMENTED 336 /* Note: You better have GDEF when using this API, or marks won't do much. */ 337 HB_EXTERN hb_bool_t 338 Xhb_ot_layout_lookup_substitute (hb_font_t *font, 339 unsigned int lookup_index, 340 const hb_ot_layout_glyph_sequence_t *sequence, 341 unsigned int out_size, 342 hb_codepoint_t *glyphs_out, /* OUT */ 343 unsigned int *clusters_out, /* OUT */ 344 unsigned int *out_length /* OUT */); 345 #endif 346 347 348 /* 349 * GPOS 350 */ 351 352 HB_EXTERN hb_bool_t 353 hb_ot_layout_has_positioning (hb_face_t *face); 354 355 #ifdef HB_NOT_IMPLEMENTED 356 /* Note: You better have GDEF when using this API, or marks won't do much. */ 357 HB_EXTERN hb_bool_t 358 Xhb_ot_layout_lookup_position (hb_font_t *font, 359 unsigned int lookup_index, 360 const hb_ot_layout_glyph_sequence_t *sequence, 361 hb_glyph_position_t *positions /* IN / OUT */); 362 #endif 363 364 /* Optical 'size' feature info. Returns true if found. 365 * https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */ 366 HB_EXTERN hb_bool_t 367 hb_ot_layout_get_size_params (hb_face_t *face, 368 unsigned int *design_size, /* OUT. May be NULL */ 369 unsigned int *subfamily_id, /* OUT. May be NULL */ 370 hb_ot_name_id_t *subfamily_name_id, /* OUT. May be NULL */ 371 unsigned int *range_start, /* OUT. May be NULL */ 372 unsigned int *range_end /* OUT. May be NULL */); 373 374 375 HB_EXTERN hb_bool_t 376 hb_ot_layout_feature_get_name_ids (hb_face_t *face, 377 hb_tag_t table_tag, 378 unsigned int feature_index, 379 hb_ot_name_id_t *label_id /* OUT. May be NULL */, 380 hb_ot_name_id_t *tooltip_id /* OUT. May be NULL */, 381 hb_ot_name_id_t *sample_id /* OUT. May be NULL */, 382 unsigned int *num_named_parameters /* OUT. May be NULL */, 383 hb_ot_name_id_t *first_param_id /* OUT. May be NULL */); 384 385 386 HB_EXTERN unsigned int 387 hb_ot_layout_feature_get_characters (hb_face_t *face, 388 hb_tag_t table_tag, 389 unsigned int feature_index, 390 unsigned int start_offset, 391 unsigned int *char_count /* IN/OUT. May be NULL */, 392 hb_codepoint_t *characters /* OUT. May be NULL */); 393 394 HB_END_DECLS 395 396 #endif /* HB_OT_LAYOUT_H */ 397