1 /* 2 * Copyright © 1998-2004 David Turner and Werner Lemberg 3 * Copyright © 2004,2007,2009 Red Hat, Inc. 4 * Copyright © 2011,2012 Google, Inc. 5 * 6 * This is part of HarfBuzz, a text shaping library. 7 * 8 * Permission is hereby granted, without written agreement and without 9 * license or royalty fees, to use, copy, modify, and distribute this 10 * software and its documentation for any purpose, provided that the 11 * above copyright notice and the following two paragraphs appear in 12 * all copies of this software. 13 * 14 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 15 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 16 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 17 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 18 * DAMAGE. 19 * 20 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 21 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 23 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 24 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 25 * 26 * Red Hat Author(s): Owen Taylor, Behdad Esfahbod 27 * Google Author(s): Behdad Esfahbod 28 */ 29 30 #if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR) 31 #error "Include <hb.h> instead." 32 #endif 33 34 #ifndef HB_BUFFER_H 35 #define HB_BUFFER_H 36 37 #include "hb-common.h" 38 #include "hb-unicode.h" 39 #include "hb-font.h" 40 41 HB_BEGIN_DECLS 42 43 /** 44 * hb_glyph_info_t: 45 * @codepoint: either a Unicode code point (before shaping) or a glyph index 46 * (after shaping). 47 * @cluster: the index of the character in the original text that corresponds 48 * to this #hb_glyph_info_t, or whatever the client passes to 49 * hb_buffer_add(). More than one #hb_glyph_info_t can have the same 50 * @cluster value, if they resulted from the same character (e.g. one 51 * to many glyph substitution), and when more than one character gets 52 * merged in the same glyph (e.g. many to one glyph substitution) the 53 * #hb_glyph_info_t will have the smallest cluster value of them. 54 * By default some characters are merged into the same cluster 55 * (e.g. combining marks have the same cluster as their bases) 56 * even if they are separate glyphs, hb_buffer_set_cluster_level() 57 * allow selecting more fine-grained cluster handling. 58 * 59 * The #hb_glyph_info_t is the structure that holds information about the 60 * glyphs and their relation to input text. 61 */ 62 typedef struct hb_glyph_info_t { 63 hb_codepoint_t codepoint; 64 /*< private >*/ 65 hb_mask_t mask; 66 /*< public >*/ 67 uint32_t cluster; 68 69 /*< private >*/ 70 hb_var_int_t var1; 71 hb_var_int_t var2; 72 } hb_glyph_info_t; 73 74 /** 75 * hb_glyph_flags_t: 76 * @HB_GLYPH_FLAG_UNSAFE_TO_BREAK: Indicates that if input text is broken at the 77 * beginning of the cluster this glyph is part of, 78 * then both sides need to be re-shaped, as the 79 * result might be different. On the flip side, 80 * it means that when this flag is not present, 81 * then it's safe to break the glyph-run at the 82 * beginning of this cluster, and the two sides 83 * represent the exact same result one would get 84 * if breaking input text at the beginning of 85 * this cluster and shaping the two sides 86 * separately. This can be used to optimize 87 * paragraph layout, by avoiding re-shaping 88 * of each line after line-breaking, or limiting 89 * the reshaping to a small piece around the 90 * breaking point only. 91 * @HB_GLYPH_FLAG_DEFINED: All the currently defined flags. 92 * 93 * Flags for #hb_glyph_info_t. 94 * 95 * Since: 1.5.0 96 */ 97 typedef enum { /*< flags >*/ 98 HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001, 99 100 HB_GLYPH_FLAG_DEFINED = 0x00000001 /* OR of all defined flags */ 101 } hb_glyph_flags_t; 102 103 HB_EXTERN hb_glyph_flags_t 104 hb_glyph_info_get_glyph_flags (const hb_glyph_info_t *info); 105 106 #define hb_glyph_info_get_glyph_flags(info) \ 107 ((hb_glyph_flags_t) ((unsigned int) (info)->mask & HB_GLYPH_FLAG_DEFINED)) 108 109 110 /** 111 * hb_glyph_position_t: 112 * @x_advance: how much the line advances after drawing this glyph when setting 113 * text in horizontal direction. 114 * @y_advance: how much the line advances after drawing this glyph when setting 115 * text in vertical direction. 116 * @x_offset: how much the glyph moves on the X-axis before drawing it, this 117 * should not affect how much the line advances. 118 * @y_offset: how much the glyph moves on the Y-axis before drawing it, this 119 * should not affect how much the line advances. 120 * 121 * The #hb_glyph_position_t is the structure that holds the positions of the 122 * glyph in both horizontal and vertical directions. All positions in 123 * #hb_glyph_position_t are relative to the current point. 124 * 125 */ 126 typedef struct hb_glyph_position_t { 127 hb_position_t x_advance; 128 hb_position_t y_advance; 129 hb_position_t x_offset; 130 hb_position_t y_offset; 131 132 /*< private >*/ 133 hb_var_int_t var; 134 } hb_glyph_position_t; 135 136 /** 137 * hb_segment_properties_t: 138 * @direction: the #hb_direction_t of the buffer, see hb_buffer_set_direction(). 139 * @script: the #hb_script_t of the buffer, see hb_buffer_set_script(). 140 * @language: the #hb_language_t of the buffer, see hb_buffer_set_language(). 141 * 142 * The structure that holds various text properties of an #hb_buffer_t. Can be 143 * set and retrieved using hb_buffer_set_segment_properties() and 144 * hb_buffer_get_segment_properties(), respectively. 145 */ 146 typedef struct hb_segment_properties_t { 147 hb_direction_t direction; 148 hb_script_t script; 149 hb_language_t language; 150 /*< private >*/ 151 void *reserved1; 152 void *reserved2; 153 } hb_segment_properties_t; 154 155 /** 156 * HB_SEGMENT_PROPERTIES_DEFAULT: 157 * 158 * The default #hb_segment_properties_t of of freshly created #hb_buffer_t. 159 */ 160 #define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \ 161 HB_SCRIPT_INVALID, \ 162 HB_LANGUAGE_INVALID, \ 163 (void *) 0, \ 164 (void *) 0} 165 166 HB_EXTERN hb_bool_t 167 hb_segment_properties_equal (const hb_segment_properties_t *a, 168 const hb_segment_properties_t *b); 169 170 HB_EXTERN unsigned int 171 hb_segment_properties_hash (const hb_segment_properties_t *p); 172 173 174 175 /** 176 * hb_buffer_t: 177 * 178 * The main structure holding the input text and its properties before shaping, 179 * and output glyphs and their information after shaping. 180 */ 181 182 typedef struct hb_buffer_t hb_buffer_t; 183 184 HB_EXTERN hb_buffer_t * 185 hb_buffer_create (void); 186 187 HB_EXTERN hb_buffer_t * 188 hb_buffer_get_empty (void); 189 190 HB_EXTERN hb_buffer_t * 191 hb_buffer_reference (hb_buffer_t *buffer); 192 193 HB_EXTERN void 194 hb_buffer_destroy (hb_buffer_t *buffer); 195 196 HB_EXTERN hb_bool_t 197 hb_buffer_set_user_data (hb_buffer_t *buffer, 198 hb_user_data_key_t *key, 199 void * data, 200 hb_destroy_func_t destroy, 201 hb_bool_t replace); 202 203 HB_EXTERN void * 204 hb_buffer_get_user_data (hb_buffer_t *buffer, 205 hb_user_data_key_t *key); 206 207 208 /** 209 * hb_buffer_content_type_t: 210 * @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer. 211 * @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping). 212 * @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping). 213 * 214 * The type of #hb_buffer_t contents. 215 */ 216 typedef enum { 217 HB_BUFFER_CONTENT_TYPE_INVALID = 0, 218 HB_BUFFER_CONTENT_TYPE_UNICODE, 219 HB_BUFFER_CONTENT_TYPE_GLYPHS 220 } hb_buffer_content_type_t; 221 222 HB_EXTERN void 223 hb_buffer_set_content_type (hb_buffer_t *buffer, 224 hb_buffer_content_type_t content_type); 225 226 HB_EXTERN hb_buffer_content_type_t 227 hb_buffer_get_content_type (hb_buffer_t *buffer); 228 229 230 HB_EXTERN void 231 hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, 232 hb_unicode_funcs_t *unicode_funcs); 233 234 HB_EXTERN hb_unicode_funcs_t * 235 hb_buffer_get_unicode_funcs (hb_buffer_t *buffer); 236 237 HB_EXTERN void 238 hb_buffer_set_direction (hb_buffer_t *buffer, 239 hb_direction_t direction); 240 241 HB_EXTERN hb_direction_t 242 hb_buffer_get_direction (hb_buffer_t *buffer); 243 244 HB_EXTERN void 245 hb_buffer_set_script (hb_buffer_t *buffer, 246 hb_script_t script); 247 248 HB_EXTERN hb_script_t 249 hb_buffer_get_script (hb_buffer_t *buffer); 250 251 HB_EXTERN void 252 hb_buffer_set_language (hb_buffer_t *buffer, 253 hb_language_t language); 254 255 256 HB_EXTERN hb_language_t 257 hb_buffer_get_language (hb_buffer_t *buffer); 258 259 HB_EXTERN void 260 hb_buffer_set_segment_properties (hb_buffer_t *buffer, 261 const hb_segment_properties_t *props); 262 263 HB_EXTERN void 264 hb_buffer_get_segment_properties (hb_buffer_t *buffer, 265 hb_segment_properties_t *props); 266 267 HB_EXTERN void 268 hb_buffer_guess_segment_properties (hb_buffer_t *buffer); 269 270 271 /** 272 * hb_buffer_flags_t: 273 * @HB_BUFFER_FLAG_DEFAULT: the default buffer flag. 274 * @HB_BUFFER_FLAG_BOT: flag indicating that special handling of the beginning 275 * of text paragraph can be applied to this buffer. Should usually 276 * be set, unless you are passing to the buffer only part 277 * of the text without the full context. 278 * @HB_BUFFER_FLAG_EOT: flag indicating that special handling of the end of text 279 * paragraph can be applied to this buffer, similar to 280 * @HB_BUFFER_FLAG_BOT. 281 * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES: 282 * flag indication that character with Default_Ignorable 283 * Unicode property should use the corresponding glyph 284 * from the font, instead of hiding them (done by 285 * replacing them with the space glyph and zeroing the 286 * advance width.) This flag takes precedence over 287 * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES. 288 * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES: 289 * flag indication that character with Default_Ignorable 290 * Unicode property should be removed from glyph string 291 * instead of hiding them (done by replacing them with the 292 * space glyph and zeroing the advance width.) 293 * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES takes 294 * precedence over this flag. Since: 1.8.0 295 * @HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE: 296 * flag indicating that a dotted circle should 297 * not be inserted in the rendering of incorrect 298 * character sequences (such at <0905 093E>). Since: 2.4 299 * 300 * Flags for #hb_buffer_t. 301 * 302 * Since: 0.9.20 303 */ 304 typedef enum { /*< flags >*/ 305 HB_BUFFER_FLAG_DEFAULT = 0x00000000u, 306 HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */ 307 HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */ 308 HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u, 309 HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES = 0x00000008u, 310 HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE = 0x00000010u 311 } hb_buffer_flags_t; 312 313 HB_EXTERN void 314 hb_buffer_set_flags (hb_buffer_t *buffer, 315 hb_buffer_flags_t flags); 316 317 HB_EXTERN hb_buffer_flags_t 318 hb_buffer_get_flags (hb_buffer_t *buffer); 319 320 /** 321 * hb_buffer_cluster_level_t: 322 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES: Return cluster values grouped by graphemes into 323 * monotone order. 324 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS: Return cluster values grouped into monotone order. 325 * @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values. 326 * @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level, 327 * equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES. 328 * 329 * Data type for holding HarfBuzz's clustering behavior options. The cluster level 330 * dictates one aspect of how HarfBuzz will treat non-base characters 331 * during shaping. 332 * 333 * In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES, non-base 334 * characters are merged into the cluster of the base character that precedes them. 335 * 336 * In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS, non-base characters are initially 337 * assigned their own cluster values, which are not merged into preceding base 338 * clusters. This allows HarfBuzz to perform additional operations like reorder 339 * sequences of adjacent marks. 340 * 341 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES is the default, because it maintains 342 * backward compatibility with older versions of HarfBuzz. New client programs that 343 * do not need to maintain such backward compatibility are recommended to use 344 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS instead of the default. 345 * 346 * Since: 0.9.42 347 */ 348 typedef enum { 349 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0, 350 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1, 351 HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2, 352 HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES 353 } hb_buffer_cluster_level_t; 354 355 HB_EXTERN void 356 hb_buffer_set_cluster_level (hb_buffer_t *buffer, 357 hb_buffer_cluster_level_t cluster_level); 358 359 HB_EXTERN hb_buffer_cluster_level_t 360 hb_buffer_get_cluster_level (hb_buffer_t *buffer); 361 362 /** 363 * HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT: 364 * 365 * The default code point for replacing invalid characters in a given encoding. 366 * Set to U+FFFD REPLACEMENT CHARACTER. 367 * 368 * Since: 0.9.31 369 */ 370 #define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu 371 372 HB_EXTERN void 373 hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, 374 hb_codepoint_t replacement); 375 376 HB_EXTERN hb_codepoint_t 377 hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer); 378 379 HB_EXTERN void 380 hb_buffer_set_invisible_glyph (hb_buffer_t *buffer, 381 hb_codepoint_t invisible); 382 383 HB_EXTERN hb_codepoint_t 384 hb_buffer_get_invisible_glyph (hb_buffer_t *buffer); 385 386 387 HB_EXTERN void 388 hb_buffer_reset (hb_buffer_t *buffer); 389 390 HB_EXTERN void 391 hb_buffer_clear_contents (hb_buffer_t *buffer); 392 393 HB_EXTERN hb_bool_t 394 hb_buffer_pre_allocate (hb_buffer_t *buffer, 395 unsigned int size); 396 397 398 HB_EXTERN hb_bool_t 399 hb_buffer_allocation_successful (hb_buffer_t *buffer); 400 401 HB_EXTERN void 402 hb_buffer_reverse (hb_buffer_t *buffer); 403 404 HB_EXTERN void 405 hb_buffer_reverse_range (hb_buffer_t *buffer, 406 unsigned int start, unsigned int end); 407 408 HB_EXTERN void 409 hb_buffer_reverse_clusters (hb_buffer_t *buffer); 410 411 412 /* Filling the buffer in */ 413 414 HB_EXTERN void 415 hb_buffer_add (hb_buffer_t *buffer, 416 hb_codepoint_t codepoint, 417 unsigned int cluster); 418 419 HB_EXTERN void 420 hb_buffer_add_utf8 (hb_buffer_t *buffer, 421 const char *text, 422 int text_length, 423 unsigned int item_offset, 424 int item_length); 425 426 HB_EXTERN void 427 hb_buffer_add_utf16 (hb_buffer_t *buffer, 428 const uint16_t *text, 429 int text_length, 430 unsigned int item_offset, 431 int item_length); 432 433 HB_EXTERN void 434 hb_buffer_add_utf32 (hb_buffer_t *buffer, 435 const uint32_t *text, 436 int text_length, 437 unsigned int item_offset, 438 int item_length); 439 440 HB_EXTERN void 441 hb_buffer_add_latin1 (hb_buffer_t *buffer, 442 const uint8_t *text, 443 int text_length, 444 unsigned int item_offset, 445 int item_length); 446 447 HB_EXTERN void 448 hb_buffer_add_codepoints (hb_buffer_t *buffer, 449 const hb_codepoint_t *text, 450 int text_length, 451 unsigned int item_offset, 452 int item_length); 453 454 HB_EXTERN void 455 hb_buffer_append (hb_buffer_t *buffer, 456 hb_buffer_t *source, 457 unsigned int start, 458 unsigned int end); 459 460 HB_EXTERN hb_bool_t 461 hb_buffer_set_length (hb_buffer_t *buffer, 462 unsigned int length); 463 464 HB_EXTERN unsigned int 465 hb_buffer_get_length (hb_buffer_t *buffer); 466 467 /* Getting glyphs out of the buffer */ 468 469 HB_EXTERN hb_glyph_info_t * 470 hb_buffer_get_glyph_infos (hb_buffer_t *buffer, 471 unsigned int *length); 472 473 HB_EXTERN hb_glyph_position_t * 474 hb_buffer_get_glyph_positions (hb_buffer_t *buffer, 475 unsigned int *length); 476 477 HB_EXTERN hb_bool_t 478 hb_buffer_has_positions (hb_buffer_t *buffer); 479 480 481 HB_EXTERN void 482 hb_buffer_normalize_glyphs (hb_buffer_t *buffer); 483 484 485 /* 486 * Serialize 487 */ 488 489 /** 490 * hb_buffer_serialize_flags_t: 491 * @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions. 492 * @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster. 493 * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information. 494 * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name. 495 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents. 496 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0 497 * @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances, 498 * glyph offsets will reflect absolute glyph positions. Since: 1.8.0 499 * 500 * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs(). 501 * 502 * Since: 0.9.20 503 */ 504 typedef enum { /*< flags >*/ 505 HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u, 506 HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u, 507 HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u, 508 HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u, 509 HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u, 510 HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u, 511 HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u 512 } hb_buffer_serialize_flags_t; 513 514 /** 515 * hb_buffer_serialize_format_t: 516 * @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format. 517 * @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format. 518 * @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format. 519 * 520 * The buffer serialization and de-serialization format used in 521 * hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs(). 522 * 523 * Since: 0.9.2 524 */ 525 typedef enum { 526 HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), 527 HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), 528 HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE 529 } hb_buffer_serialize_format_t; 530 531 HB_EXTERN hb_buffer_serialize_format_t 532 hb_buffer_serialize_format_from_string (const char *str, int len); 533 534 HB_EXTERN const char * 535 hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); 536 537 HB_EXTERN const char ** 538 hb_buffer_serialize_list_formats (void); 539 540 HB_EXTERN unsigned int 541 hb_buffer_serialize_glyphs (hb_buffer_t *buffer, 542 unsigned int start, 543 unsigned int end, 544 char *buf, 545 unsigned int buf_size, 546 unsigned int *buf_consumed, 547 hb_font_t *font, 548 hb_buffer_serialize_format_t format, 549 hb_buffer_serialize_flags_t flags); 550 551 HB_EXTERN unsigned int 552 hb_buffer_serialize_unicode (hb_buffer_t *buffer, 553 unsigned int start, 554 unsigned int end, 555 char *buf, 556 unsigned int buf_size, 557 unsigned int *buf_consumed, 558 hb_buffer_serialize_format_t format, 559 hb_buffer_serialize_flags_t flags); 560 561 HB_EXTERN unsigned int 562 hb_buffer_serialize (hb_buffer_t *buffer, 563 unsigned int start, 564 unsigned int end, 565 char *buf, 566 unsigned int buf_size, 567 unsigned int *buf_consumed, 568 hb_font_t *font, 569 hb_buffer_serialize_format_t format, 570 hb_buffer_serialize_flags_t flags); 571 572 HB_EXTERN hb_bool_t 573 hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, 574 const char *buf, 575 int buf_len, 576 const char **end_ptr, 577 hb_font_t *font, 578 hb_buffer_serialize_format_t format); 579 580 HB_EXTERN hb_bool_t 581 hb_buffer_deserialize_unicode (hb_buffer_t *buffer, 582 const char *buf, 583 int buf_len, 584 const char **end_ptr, 585 hb_buffer_serialize_format_t format); 586 587 588 589 /* 590 * Compare buffers 591 */ 592 593 /** 594 * hb_buffer_diff_flags_t: 595 * @HB_BUFFER_DIFF_FLAG_EQUAL: equal buffers. 596 * @HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH: buffers with different 597 * #hb_buffer_content_type_t. 598 * @HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH: buffers with differing length. 599 * @HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT: `.notdef` glyph is present in the 600 * reference buffer. 601 * @HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT: dotted circle glyph is present 602 * in the reference buffer. 603 * @HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH: difference in #hb_glyph_info_t.codepoint 604 * @HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH: difference in #hb_glyph_info_t.cluster 605 * @HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH: difference in #hb_glyph_flags_t. 606 * @HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH: difference in #hb_glyph_position_t. 607 * 608 * Flags from comparing two #hb_buffer_t's. 609 * 610 * Buffer with different #hb_buffer_content_type_t cannot be meaningfully 611 * compared in any further detail. 612 * 613 * For buffers with differing length, the per-glyph comparison is not 614 * attempted, though we do still scan reference buffer for dotted circle and 615 * `.notdef` glyphs. 616 * 617 * If the buffers have the same length, we compare them glyph-by-glyph and 618 * report which aspect(s) of the glyph info/position are different. 619 * 620 * Since: 1.5.0 621 */ 622 typedef enum { /*< flags >*/ 623 HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000, 624 625 /* Buffers with different content_type cannot be meaningfully compared 626 * in any further detail. */ 627 HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001, 628 629 /* For buffers with differing length, the per-glyph comparison is not 630 * attempted, though we do still scan reference for dottedcircle / .notdef 631 * glyphs. */ 632 HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002, 633 634 /* We want to know if dottedcircle / .notdef glyphs are present in the 635 * reference, as we may not care so much about other differences in this 636 * case. */ 637 HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004, 638 HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008, 639 640 /* If the buffers have the same length, we compare them glyph-by-glyph 641 * and report which aspect(s) of the glyph info/position are different. */ 642 HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010, 643 HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020, 644 HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040, 645 HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080 646 647 } hb_buffer_diff_flags_t; 648 649 /* Compare the contents of two buffers, report types of differences. */ 650 HB_EXTERN hb_buffer_diff_flags_t 651 hb_buffer_diff (hb_buffer_t *buffer, 652 hb_buffer_t *reference, 653 hb_codepoint_t dottedcircle_glyph, 654 unsigned int position_fuzz); 655 656 657 /* 658 * Debugging. 659 */ 660 661 /** 662 * hb_buffer_message_func_t: 663 * @buffer: An #hb_buffer_t to work upon 664 * @font: The #hb_font_t the @buffer is shaped with 665 * @message: %NULL-terminated message passed to the function 666 * @user_data: User data pointer passed by the caller 667 * 668 * A callback method for #hb_buffer_t. The method gets called with the 669 * #hb_buffer_t it was set on, the #hb_font_t the buffer is shaped with and a 670 * message describing what step of the shaping process will be performed. 671 * Returning %false from this method will skip this shaping step and move to 672 * the next one. 673 * 674 * Return value: %true to perform the shaping step, %false to skip it. 675 * 676 * Since: 1.1.3 677 */ 678 typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer, 679 hb_font_t *font, 680 const char *message, 681 void *user_data); 682 683 HB_EXTERN void 684 hb_buffer_set_message_func (hb_buffer_t *buffer, 685 hb_buffer_message_func_t func, 686 void *user_data, hb_destroy_func_t destroy); 687 688 689 HB_END_DECLS 690 691 #endif /* HB_BUFFER_H */ 692