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_FLAG_PRODUCE_UNSAFE_TO_CONCAT = 0x00000040u 312 } hb_buffer_flags_t; 313 314 HB_EXTERN void 315 hb_buffer_set_flags (hb_buffer_t *buffer, 316 hb_buffer_flags_t flags); 317 318 HB_EXTERN hb_buffer_flags_t 319 hb_buffer_get_flags (hb_buffer_t *buffer); 320 321 /** 322 * hb_buffer_cluster_level_t: 323 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES: Return cluster values grouped by graphemes into 324 * monotone order. 325 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS: Return cluster values grouped into monotone order. 326 * @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values. 327 * @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level, 328 * equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES. 329 * 330 * Data type for holding HarfBuzz's clustering behavior options. The cluster level 331 * dictates one aspect of how HarfBuzz will treat non-base characters 332 * during shaping. 333 * 334 * In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES, non-base 335 * characters are merged into the cluster of the base character that precedes them. 336 * 337 * In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS, non-base characters are initially 338 * assigned their own cluster values, which are not merged into preceding base 339 * clusters. This allows HarfBuzz to perform additional operations like reorder 340 * sequences of adjacent marks. 341 * 342 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES is the default, because it maintains 343 * backward compatibility with older versions of HarfBuzz. New client programs that 344 * do not need to maintain such backward compatibility are recommended to use 345 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS instead of the default. 346 * 347 * Since: 0.9.42 348 */ 349 typedef enum { 350 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0, 351 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1, 352 HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2, 353 HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES 354 } hb_buffer_cluster_level_t; 355 356 HB_EXTERN void 357 hb_buffer_set_cluster_level (hb_buffer_t *buffer, 358 hb_buffer_cluster_level_t cluster_level); 359 360 HB_EXTERN hb_buffer_cluster_level_t 361 hb_buffer_get_cluster_level (hb_buffer_t *buffer); 362 363 /** 364 * HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT: 365 * 366 * The default code point for replacing invalid characters in a given encoding. 367 * Set to U+FFFD REPLACEMENT CHARACTER. 368 * 369 * Since: 0.9.31 370 */ 371 #define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu 372 373 HB_EXTERN void 374 hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, 375 hb_codepoint_t replacement); 376 377 HB_EXTERN hb_codepoint_t 378 hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer); 379 380 HB_EXTERN void 381 hb_buffer_set_invisible_glyph (hb_buffer_t *buffer, 382 hb_codepoint_t invisible); 383 384 HB_EXTERN hb_codepoint_t 385 hb_buffer_get_invisible_glyph (hb_buffer_t *buffer); 386 387 388 HB_EXTERN void 389 hb_buffer_reset (hb_buffer_t *buffer); 390 391 HB_EXTERN void 392 hb_buffer_clear_contents (hb_buffer_t *buffer); 393 394 HB_EXTERN hb_bool_t 395 hb_buffer_pre_allocate (hb_buffer_t *buffer, 396 unsigned int size); 397 398 399 HB_EXTERN hb_bool_t 400 hb_buffer_allocation_successful (hb_buffer_t *buffer); 401 402 HB_EXTERN void 403 hb_buffer_reverse (hb_buffer_t *buffer); 404 405 HB_EXTERN void 406 hb_buffer_reverse_range (hb_buffer_t *buffer, 407 unsigned int start, unsigned int end); 408 409 HB_EXTERN void 410 hb_buffer_reverse_clusters (hb_buffer_t *buffer); 411 412 413 /* Filling the buffer in */ 414 415 HB_EXTERN void 416 hb_buffer_add (hb_buffer_t *buffer, 417 hb_codepoint_t codepoint, 418 unsigned int cluster); 419 420 HB_EXTERN void 421 hb_buffer_add_utf8 (hb_buffer_t *buffer, 422 const char *text, 423 int text_length, 424 unsigned int item_offset, 425 int item_length); 426 427 HB_EXTERN void 428 hb_buffer_add_utf16 (hb_buffer_t *buffer, 429 const uint16_t *text, 430 int text_length, 431 unsigned int item_offset, 432 int item_length); 433 434 HB_EXTERN void 435 hb_buffer_add_utf32 (hb_buffer_t *buffer, 436 const uint32_t *text, 437 int text_length, 438 unsigned int item_offset, 439 int item_length); 440 441 HB_EXTERN void 442 hb_buffer_add_latin1 (hb_buffer_t *buffer, 443 const uint8_t *text, 444 int text_length, 445 unsigned int item_offset, 446 int item_length); 447 448 HB_EXTERN void 449 hb_buffer_add_codepoints (hb_buffer_t *buffer, 450 const hb_codepoint_t *text, 451 int text_length, 452 unsigned int item_offset, 453 int item_length); 454 455 HB_EXTERN void 456 hb_buffer_append (hb_buffer_t *buffer, 457 hb_buffer_t *source, 458 unsigned int start, 459 unsigned int end); 460 461 HB_EXTERN hb_bool_t 462 hb_buffer_set_length (hb_buffer_t *buffer, 463 unsigned int length); 464 465 HB_EXTERN unsigned int 466 hb_buffer_get_length (hb_buffer_t *buffer); 467 468 /* Getting glyphs out of the buffer */ 469 470 HB_EXTERN hb_glyph_info_t * 471 hb_buffer_get_glyph_infos (hb_buffer_t *buffer, 472 unsigned int *length); 473 474 HB_EXTERN hb_glyph_position_t * 475 hb_buffer_get_glyph_positions (hb_buffer_t *buffer, 476 unsigned int *length); 477 478 HB_EXTERN hb_bool_t 479 hb_buffer_has_positions (hb_buffer_t *buffer); 480 481 482 HB_EXTERN void 483 hb_buffer_normalize_glyphs (hb_buffer_t *buffer); 484 485 486 /* 487 * Serialize 488 */ 489 490 /** 491 * hb_buffer_serialize_flags_t: 492 * @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions. 493 * @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster. 494 * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information. 495 * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name. 496 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents. 497 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0 498 * @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances, 499 * glyph offsets will reflect absolute glyph positions. Since: 1.8.0 500 * 501 * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs(). 502 * 503 * Since: 0.9.20 504 */ 505 typedef enum { /*< flags >*/ 506 HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u, 507 HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u, 508 HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u, 509 HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u, 510 HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u, 511 HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u, 512 HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u 513 } hb_buffer_serialize_flags_t; 514 515 /** 516 * hb_buffer_serialize_format_t: 517 * @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format. 518 * @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format. 519 * @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format. 520 * 521 * The buffer serialization and de-serialization format used in 522 * hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs(). 523 * 524 * Since: 0.9.2 525 */ 526 typedef enum { 527 HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), 528 HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), 529 HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE 530 } hb_buffer_serialize_format_t; 531 532 HB_EXTERN hb_buffer_serialize_format_t 533 hb_buffer_serialize_format_from_string (const char *str, int len); 534 535 HB_EXTERN const char * 536 hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); 537 538 HB_EXTERN const char ** 539 hb_buffer_serialize_list_formats (void); 540 541 HB_EXTERN unsigned int 542 hb_buffer_serialize_glyphs (hb_buffer_t *buffer, 543 unsigned int start, 544 unsigned int end, 545 char *buf, 546 unsigned int buf_size, 547 unsigned int *buf_consumed, 548 hb_font_t *font, 549 hb_buffer_serialize_format_t format, 550 hb_buffer_serialize_flags_t flags); 551 552 HB_EXTERN unsigned int 553 hb_buffer_serialize_unicode (hb_buffer_t *buffer, 554 unsigned int start, 555 unsigned int end, 556 char *buf, 557 unsigned int buf_size, 558 unsigned int *buf_consumed, 559 hb_buffer_serialize_format_t format, 560 hb_buffer_serialize_flags_t flags); 561 562 HB_EXTERN unsigned int 563 hb_buffer_serialize (hb_buffer_t *buffer, 564 unsigned int start, 565 unsigned int end, 566 char *buf, 567 unsigned int buf_size, 568 unsigned int *buf_consumed, 569 hb_font_t *font, 570 hb_buffer_serialize_format_t format, 571 hb_buffer_serialize_flags_t flags); 572 573 HB_EXTERN hb_bool_t 574 hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, 575 const char *buf, 576 int buf_len, 577 const char **end_ptr, 578 hb_font_t *font, 579 hb_buffer_serialize_format_t format); 580 581 HB_EXTERN hb_bool_t 582 hb_buffer_deserialize_unicode (hb_buffer_t *buffer, 583 const char *buf, 584 int buf_len, 585 const char **end_ptr, 586 hb_buffer_serialize_format_t format); 587 588 589 590 /* 591 * Compare buffers 592 */ 593 594 /** 595 * hb_buffer_diff_flags_t: 596 * @HB_BUFFER_DIFF_FLAG_EQUAL: equal buffers. 597 * @HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH: buffers with different 598 * #hb_buffer_content_type_t. 599 * @HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH: buffers with differing length. 600 * @HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT: `.notdef` glyph is present in the 601 * reference buffer. 602 * @HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT: dotted circle glyph is present 603 * in the reference buffer. 604 * @HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH: difference in #hb_glyph_info_t.codepoint 605 * @HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH: difference in #hb_glyph_info_t.cluster 606 * @HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH: difference in #hb_glyph_flags_t. 607 * @HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH: difference in #hb_glyph_position_t. 608 * 609 * Flags from comparing two #hb_buffer_t's. 610 * 611 * Buffer with different #hb_buffer_content_type_t cannot be meaningfully 612 * compared in any further detail. 613 * 614 * For buffers with differing length, the per-glyph comparison is not 615 * attempted, though we do still scan reference buffer for dotted circle and 616 * `.notdef` glyphs. 617 * 618 * If the buffers have the same length, we compare them glyph-by-glyph and 619 * report which aspect(s) of the glyph info/position are different. 620 * 621 * Since: 1.5.0 622 */ 623 typedef enum { /*< flags >*/ 624 HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000, 625 626 /* Buffers with different content_type cannot be meaningfully compared 627 * in any further detail. */ 628 HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001, 629 630 /* For buffers with differing length, the per-glyph comparison is not 631 * attempted, though we do still scan reference for dottedcircle / .notdef 632 * glyphs. */ 633 HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002, 634 635 /* We want to know if dottedcircle / .notdef glyphs are present in the 636 * reference, as we may not care so much about other differences in this 637 * case. */ 638 HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004, 639 HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008, 640 641 /* If the buffers have the same length, we compare them glyph-by-glyph 642 * and report which aspect(s) of the glyph info/position are different. */ 643 HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010, 644 HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020, 645 HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040, 646 HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080 647 648 } hb_buffer_diff_flags_t; 649 650 /* Compare the contents of two buffers, report types of differences. */ 651 HB_EXTERN hb_buffer_diff_flags_t 652 hb_buffer_diff (hb_buffer_t *buffer, 653 hb_buffer_t *reference, 654 hb_codepoint_t dottedcircle_glyph, 655 unsigned int position_fuzz); 656 657 658 /* 659 * Debugging. 660 */ 661 662 /** 663 * hb_buffer_message_func_t: 664 * @buffer: An #hb_buffer_t to work upon 665 * @font: The #hb_font_t the @buffer is shaped with 666 * @message: %NULL-terminated message passed to the function 667 * @user_data: User data pointer passed by the caller 668 * 669 * A callback method for #hb_buffer_t. The method gets called with the 670 * #hb_buffer_t it was set on, the #hb_font_t the buffer is shaped with and a 671 * message describing what step of the shaping process will be performed. 672 * Returning %false from this method will skip this shaping step and move to 673 * the next one. 674 * 675 * Return value: %true to perform the shaping step, %false to skip it. 676 * 677 * Since: 1.1.3 678 */ 679 typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer, 680 hb_font_t *font, 681 const char *message, 682 void *user_data); 683 684 HB_EXTERN void 685 hb_buffer_set_message_func (hb_buffer_t *buffer, 686 hb_buffer_message_func_t func, 687 void *user_data, hb_destroy_func_t destroy); 688 689 690 HB_END_DECLS 691 692 #endif /* HB_BUFFER_H */ 693