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_GDEF HB_TAG('G','D','E','F') 42 #define HB_OT_TAG_GSUB HB_TAG('G','S','U','B') 43 #define HB_OT_TAG_GPOS HB_TAG('G','P','O','S') 44 #define HB_OT_TAG_JSTF HB_TAG('J','S','T','F') 45 46 47 /* 48 * GDEF 49 */ 50 51 HB_EXTERN hb_bool_t 52 hb_ot_layout_has_glyph_classes (hb_face_t *face); 53 54 typedef enum { 55 HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0, 56 HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 1, 57 HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 2, 58 HB_OT_LAYOUT_GLYPH_CLASS_MARK = 3, 59 HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT = 4 60 } hb_ot_layout_glyph_class_t; 61 62 HB_EXTERN hb_ot_layout_glyph_class_t 63 hb_ot_layout_get_glyph_class (hb_face_t *face, 64 hb_codepoint_t glyph); 65 66 HB_EXTERN void 67 hb_ot_layout_get_glyphs_in_class (hb_face_t *face, 68 hb_ot_layout_glyph_class_t klass, 69 hb_set_t *glyphs /* OUT */); 70 71 72 /* Not that useful. Provides list of attach points for a glyph that a 73 * client may want to cache */ 74 HB_EXTERN unsigned int 75 hb_ot_layout_get_attach_points (hb_face_t *face, 76 hb_codepoint_t glyph, 77 unsigned int start_offset, 78 unsigned int *point_count /* IN/OUT */, 79 unsigned int *point_array /* OUT */); 80 81 /* Ligature caret positions */ 82 HB_EXTERN unsigned int 83 hb_ot_layout_get_ligature_carets (hb_font_t *font, 84 hb_direction_t direction, 85 hb_codepoint_t glyph, 86 unsigned int start_offset, 87 unsigned int *caret_count /* IN/OUT */, 88 hb_position_t *caret_array /* OUT */); 89 90 91 /* 92 * GSUB/GPOS feature query and enumeration interface 93 */ 94 95 #define HB_OT_LAYOUT_NO_SCRIPT_INDEX 0xFFFFu 96 #define HB_OT_LAYOUT_NO_FEATURE_INDEX 0xFFFFu 97 #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX 0xFFFFu 98 #define HB_OT_LAYOUT_NO_VARIATIONS_INDEX 0xFFFFFFFFu 99 100 HB_EXTERN unsigned int 101 hb_ot_layout_table_get_script_tags (hb_face_t *face, 102 hb_tag_t table_tag, 103 unsigned int start_offset, 104 unsigned int *script_count /* IN/OUT */, 105 hb_tag_t *script_tags /* OUT */); 106 107 HB_EXTERN hb_bool_t 108 hb_ot_layout_table_find_script (hb_face_t *face, 109 hb_tag_t table_tag, 110 hb_tag_t script_tag, 111 unsigned int *script_index); 112 113 /* Like find_script, but takes zero-terminated array of scripts to test */ 114 HB_EXTERN hb_bool_t 115 hb_ot_layout_table_choose_script (hb_face_t *face, 116 hb_tag_t table_tag, 117 const hb_tag_t *script_tags, 118 unsigned int *script_index, 119 hb_tag_t *chosen_script); 120 121 HB_EXTERN unsigned int 122 hb_ot_layout_table_get_feature_tags (hb_face_t *face, 123 hb_tag_t table_tag, 124 unsigned int start_offset, 125 unsigned int *feature_count /* IN/OUT */, 126 hb_tag_t *feature_tags /* OUT */); 127 128 HB_EXTERN unsigned int 129 hb_ot_layout_script_get_language_tags (hb_face_t *face, 130 hb_tag_t table_tag, 131 unsigned int script_index, 132 unsigned int start_offset, 133 unsigned int *language_count /* IN/OUT */, 134 hb_tag_t *language_tags /* OUT */); 135 136 HB_EXTERN hb_bool_t 137 hb_ot_layout_script_find_language (hb_face_t *face, 138 hb_tag_t table_tag, 139 unsigned int script_index, 140 hb_tag_t language_tag, 141 unsigned int *language_index); 142 143 HB_EXTERN hb_bool_t 144 hb_ot_layout_language_get_required_feature_index (hb_face_t *face, 145 hb_tag_t table_tag, 146 unsigned int script_index, 147 unsigned int language_index, 148 unsigned int *feature_index); 149 150 HB_EXTERN hb_bool_t 151 hb_ot_layout_language_get_required_feature (hb_face_t *face, 152 hb_tag_t table_tag, 153 unsigned int script_index, 154 unsigned int language_index, 155 unsigned int *feature_index, 156 hb_tag_t *feature_tag); 157 158 HB_EXTERN unsigned int 159 hb_ot_layout_language_get_feature_indexes (hb_face_t *face, 160 hb_tag_t table_tag, 161 unsigned int script_index, 162 unsigned int language_index, 163 unsigned int start_offset, 164 unsigned int *feature_count /* IN/OUT */, 165 unsigned int *feature_indexes /* OUT */); 166 167 HB_EXTERN unsigned int 168 hb_ot_layout_language_get_feature_tags (hb_face_t *face, 169 hb_tag_t table_tag, 170 unsigned int script_index, 171 unsigned int language_index, 172 unsigned int start_offset, 173 unsigned int *feature_count /* IN/OUT */, 174 hb_tag_t *feature_tags /* OUT */); 175 176 HB_EXTERN hb_bool_t 177 hb_ot_layout_language_find_feature (hb_face_t *face, 178 hb_tag_t table_tag, 179 unsigned int script_index, 180 unsigned int language_index, 181 hb_tag_t feature_tag, 182 unsigned int *feature_index); 183 184 HB_EXTERN unsigned int 185 hb_ot_layout_feature_get_lookups (hb_face_t *face, 186 hb_tag_t table_tag, 187 unsigned int feature_index, 188 unsigned int start_offset, 189 unsigned int *lookup_count /* IN/OUT */, 190 unsigned int *lookup_indexes /* OUT */); 191 192 HB_EXTERN unsigned int 193 hb_ot_layout_table_get_lookup_count (hb_face_t *face, 194 hb_tag_t table_tag); 195 196 197 HB_EXTERN void 198 hb_ot_layout_collect_lookups (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 *lookup_indexes /* OUT */); 204 205 HB_EXTERN void 206 hb_ot_layout_lookup_collect_glyphs (hb_face_t *face, 207 hb_tag_t table_tag, 208 unsigned int lookup_index, 209 hb_set_t *glyphs_before, /* OUT. May be NULL */ 210 hb_set_t *glyphs_input, /* OUT. May be NULL */ 211 hb_set_t *glyphs_after, /* OUT. May be NULL */ 212 hb_set_t *glyphs_output /* OUT. May be NULL */); 213 214 #ifdef HB_NOT_IMPLEMENTED 215 typedef struct 216 { 217 const hb_codepoint_t *before, 218 unsigned int before_length, 219 const hb_codepoint_t *input, 220 unsigned int input_length, 221 const hb_codepoint_t *after, 222 unsigned int after_length, 223 } hb_ot_layout_glyph_sequence_t; 224 225 typedef hb_bool_t 226 (*hb_ot_layout_glyph_sequence_func_t) (hb_font_t *font, 227 hb_tag_t table_tag, 228 unsigned int lookup_index, 229 const hb_ot_layout_glyph_sequence_t *sequence, 230 void *user_data); 231 232 HB_EXTERN void 233 Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t *face, 234 hb_tag_t table_tag, 235 unsigned int lookup_index, 236 hb_ot_layout_glyph_sequence_func_t callback, 237 void *user_data); 238 #endif 239 240 /* Variations support */ 241 242 HB_EXTERN hb_bool_t 243 hb_ot_layout_table_find_feature_variations (hb_face_t *face, 244 hb_tag_t table_tag, 245 const int *coords, 246 unsigned int num_coords, 247 unsigned int *variations_index /* out */); 248 249 HB_EXTERN unsigned int 250 hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face, 251 hb_tag_t table_tag, 252 unsigned int feature_index, 253 unsigned int variations_index, 254 unsigned int start_offset, 255 unsigned int *lookup_count /* IN/OUT */, 256 unsigned int *lookup_indexes /* OUT */); 257 258 259 /* 260 * GSUB 261 */ 262 263 HB_EXTERN hb_bool_t 264 hb_ot_layout_has_substitution (hb_face_t *face); 265 266 HB_EXTERN hb_bool_t 267 hb_ot_layout_lookup_would_substitute (hb_face_t *face, 268 unsigned int lookup_index, 269 const hb_codepoint_t *glyphs, 270 unsigned int glyphs_length, 271 hb_bool_t zero_context); 272 273 HB_EXTERN void 274 hb_ot_layout_lookup_substitute_closure (hb_face_t *face, 275 unsigned int lookup_index, 276 hb_set_t *glyphs 277 /*TODO , hb_bool_t inclusive */); 278 279 #ifdef HB_NOT_IMPLEMENTED 280 /* Note: You better have GDEF when using this API, or marks won't do much. */ 281 HB_EXTERN hb_bool_t 282 Xhb_ot_layout_lookup_substitute (hb_font_t *font, 283 unsigned int lookup_index, 284 const hb_ot_layout_glyph_sequence_t *sequence, 285 unsigned int out_size, 286 hb_codepoint_t *glyphs_out, /* OUT */ 287 unsigned int *clusters_out, /* OUT */ 288 unsigned int *out_length /* OUT */); 289 #endif 290 291 292 /* 293 * GPOS 294 */ 295 296 HB_EXTERN hb_bool_t 297 hb_ot_layout_has_positioning (hb_face_t *face); 298 299 #ifdef HB_NOT_IMPLEMENTED 300 /* Note: You better have GDEF when using this API, or marks won't do much. */ 301 HB_EXTERN hb_bool_t 302 Xhb_ot_layout_lookup_position (hb_font_t *font, 303 unsigned int lookup_index, 304 const hb_ot_layout_glyph_sequence_t *sequence, 305 hb_glyph_position_t *positions /* IN / OUT */); 306 #endif 307 308 /* Optical 'size' feature info. Returns true if found. 309 * http://www.microsoft.com/typography/otspec/features_pt.htm#size */ 310 HB_EXTERN hb_bool_t 311 hb_ot_layout_get_size_params (hb_face_t *face, 312 unsigned int *design_size, /* OUT. May be NULL */ 313 unsigned int *subfamily_id, /* OUT. May be NULL */ 314 unsigned int *subfamily_name_id, /* OUT. May be NULL */ 315 unsigned int *range_start, /* OUT. May be NULL */ 316 unsigned int *range_end /* OUT. May be NULL */); 317 318 319 HB_END_DECLS 320 321 #endif /* HB_OT_LAYOUT_H */ 322