| 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 | HB_EXTERN void |
| 198 | hb_ot_layout_collect_features (hb_face_t *face, |
| 199 | hb_tag_t table_tag, |
| 200 | const hb_tag_t *scripts, |
| 201 | const hb_tag_t *languages, |
| 202 | const hb_tag_t *features, |
| 203 | hb_set_t *feature_indexes /* OUT */); |
| 204 | |
| 205 | HB_EXTERN void |
| 206 | hb_ot_layout_collect_lookups (hb_face_t *face, |
| 207 | hb_tag_t table_tag, |
| 208 | const hb_tag_t *scripts, |
| 209 | const hb_tag_t *languages, |
| 210 | const hb_tag_t *features, |
| 211 | hb_set_t *lookup_indexes /* OUT */); |
| 212 | |
| 213 | HB_EXTERN void |
| 214 | hb_ot_layout_lookup_collect_glyphs (hb_face_t *face, |
| 215 | hb_tag_t table_tag, |
| 216 | unsigned int lookup_index, |
| 217 | hb_set_t *glyphs_before, /* OUT. May be NULL */ |
| 218 | hb_set_t *glyphs_input, /* OUT. May be NULL */ |
| 219 | hb_set_t *glyphs_after, /* OUT. May be NULL */ |
| 220 | hb_set_t *glyphs_output /* OUT. May be NULL */); |
| 221 | |
| 222 | #ifdef HB_NOT_IMPLEMENTED |
| 223 | typedef struct |
| 224 | { |
| 225 | const hb_codepoint_t *before, |
| 226 | unsigned int before_length, |
| 227 | const hb_codepoint_t *input, |
| 228 | unsigned int input_length, |
| 229 | const hb_codepoint_t *after, |
| 230 | unsigned int after_length, |
| 231 | } hb_ot_layout_glyph_sequence_t; |
| 232 | |
| 233 | typedef hb_bool_t |
| 234 | (*hb_ot_layout_glyph_sequence_func_t) (hb_font_t *font, |
| 235 | hb_tag_t table_tag, |
| 236 | unsigned int lookup_index, |
| 237 | const hb_ot_layout_glyph_sequence_t *sequence, |
| 238 | void *user_data); |
| 239 | |
| 240 | HB_EXTERN void |
| 241 | Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t *face, |
| 242 | hb_tag_t table_tag, |
| 243 | unsigned int lookup_index, |
| 244 | hb_ot_layout_glyph_sequence_func_t callback, |
| 245 | void *user_data); |
| 246 | #endif |
| 247 | |
| 248 | /* Variations support */ |
| 249 | |
| 250 | HB_EXTERN hb_bool_t |
| 251 | hb_ot_layout_table_find_feature_variations (hb_face_t *face, |
| 252 | hb_tag_t table_tag, |
| 253 | const int *coords, |
| 254 | unsigned int num_coords, |
| 255 | unsigned int *variations_index /* out */); |
| 256 | |
| 257 | HB_EXTERN unsigned int |
| 258 | hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, |
| 259 | hb_tag_t table_tag, |
| 260 | unsigned int feature_index, |
| 261 | unsigned int variations_index, |
| 262 | unsigned int start_offset, |
| 263 | unsigned int *lookup_count /* IN/OUT */, |
| 264 | unsigned int *lookup_indexes /* OUT */); |
| 265 | |
| 266 | |
| 267 | /* |
| 268 | * GSUB |
| 269 | */ |
| 270 | |
| 271 | HB_EXTERN hb_bool_t |
| 272 | hb_ot_layout_has_substitution (hb_face_t *face); |
| 273 | |
| 274 | HB_EXTERN hb_bool_t |
| 275 | hb_ot_layout_lookup_would_substitute (hb_face_t *face, |
| 276 | unsigned int lookup_index, |
| 277 | const hb_codepoint_t *glyphs, |
| 278 | unsigned int glyphs_length, |
| 279 | hb_bool_t zero_context); |
| 280 | |
| 281 | HB_EXTERN void |
| 282 | hb_ot_layout_lookup_substitute_closure (hb_face_t *face, |
| 283 | unsigned int lookup_index, |
| 284 | hb_set_t *glyphs |
| 285 | /*TODO , hb_bool_t inclusive */); |
| 286 | |
| 287 | HB_EXTERN void |
| 288 | hb_ot_layout_lookups_substitute_closure (hb_face_t *face, |
| 289 | const hb_set_t *lookups, |
| 290 | hb_set_t *glyphs); |
| 291 | |
| 292 | |
| 293 | #ifdef HB_NOT_IMPLEMENTED |
| 294 | /* Note: You better have GDEF when using this API, or marks won't do much. */ |
| 295 | HB_EXTERN hb_bool_t |
| 296 | Xhb_ot_layout_lookup_substitute (hb_font_t *font, |
| 297 | unsigned int lookup_index, |
| 298 | const hb_ot_layout_glyph_sequence_t *sequence, |
| 299 | unsigned int out_size, |
| 300 | hb_codepoint_t *glyphs_out, /* OUT */ |
| 301 | unsigned int *clusters_out, /* OUT */ |
| 302 | unsigned int *out_length /* OUT */); |
| 303 | #endif |
| 304 | |
| 305 | |
| 306 | /* |
| 307 | * GPOS |
| 308 | */ |
| 309 | |
| 310 | HB_EXTERN hb_bool_t |
| 311 | hb_ot_layout_has_positioning (hb_face_t *face); |
| 312 | |
| 313 | #ifdef HB_NOT_IMPLEMENTED |
| 314 | /* Note: You better have GDEF when using this API, or marks won't do much. */ |
| 315 | HB_EXTERN hb_bool_t |
| 316 | Xhb_ot_layout_lookup_position (hb_font_t *font, |
| 317 | unsigned int lookup_index, |
| 318 | const hb_ot_layout_glyph_sequence_t *sequence, |
| 319 | hb_glyph_position_t *positions /* IN / OUT */); |
| 320 | #endif |
| 321 | |
| 322 | /* Optical 'size' feature info. Returns true if found. |
| 323 | * https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */ |
| 324 | HB_EXTERN hb_bool_t |
| 325 | hb_ot_layout_get_size_params (hb_face_t *face, |
| 326 | unsigned int *design_size, /* OUT. May be NULL */ |
| 327 | unsigned int *subfamily_id, /* OUT. May be NULL */ |
| 328 | unsigned int *subfamily_name_id, /* OUT. May be NULL */ |
| 329 | unsigned int *range_start, /* OUT. May be NULL */ |
| 330 | unsigned int *range_end /* OUT. May be NULL */); |
| 331 | |
| 332 | |
| 333 | /* |
| 334 | * BASE |
| 335 | */ |
| 336 | #if 0 |
| 337 | |
| 338 | #define HB_OT_TAG_BASE_HANG HB_TAG('h','a','n','g') |
| 339 | #define HB_OT_TAG_BASE_ICFB HB_TAG('i','c','f','b') |
| 340 | #define HB_OT_TAG_BASE_ICFT HB_TAG('i','c','f','t') |
| 341 | #define HB_OT_TAG_BASE_IDEO HB_TAG('i','d','e','o') |
| 342 | #define HB_OT_TAG_BASE_IDTB HB_TAG('i','d','t','b') |
| 343 | #define HB_OT_TAG_BASE_MATH HB_TAG('m','a','t','h') |
| 344 | #define HB_OT_TAG_BASE_ROMN HB_TAG('r','o','m','n') |
| 345 | |
| 346 | #endif |
| 347 | |
| 348 | |
| 349 | HB_END_DECLS |
| 350 | |
| 351 | #endif /* HB_OT_LAYOUT_H */ |
| 352 | |