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 HB_EXTERN void 388 hb_buffer_set_not_found_glyph (hb_buffer_t *buffer, 389 hb_codepoint_t not_found); 390 391 HB_EXTERN hb_codepoint_t 392 hb_buffer_get_not_found_glyph (hb_buffer_t *buffer); 393 394 395 HB_EXTERN void 396 hb_buffer_reset (hb_buffer_t *buffer); 397 398 HB_EXTERN void 399 hb_buffer_clear_contents (hb_buffer_t *buffer); 400 401 HB_EXTERN hb_bool_t 402 hb_buffer_pre_allocate (hb_buffer_t *buffer, 403 unsigned int size); 404 405 406 HB_EXTERN hb_bool_t 407 hb_buffer_allocation_successful (hb_buffer_t *buffer); 408 409 HB_EXTERN void 410 hb_buffer_reverse (hb_buffer_t *buffer); 411 412 HB_EXTERN void 413 hb_buffer_reverse_range (hb_buffer_t *buffer, 414 unsigned int start, unsigned int end); 415 416 HB_EXTERN void 417 hb_buffer_reverse_clusters (hb_buffer_t *buffer); 418 419 420 /* Filling the buffer in */ 421 422 HB_EXTERN void 423 hb_buffer_add (hb_buffer_t *buffer, 424 hb_codepoint_t codepoint, 425 unsigned int cluster); 426 427 HB_EXTERN void 428 hb_buffer_add_utf8 (hb_buffer_t *buffer, 429 const char *text, 430 int text_length, 431 unsigned int item_offset, 432 int item_length); 433 434 HB_EXTERN void 435 hb_buffer_add_utf16 (hb_buffer_t *buffer, 436 const uint16_t *text, 437 int text_length, 438 unsigned int item_offset, 439 int item_length); 440 441 HB_EXTERN void 442 hb_buffer_add_utf32 (hb_buffer_t *buffer, 443 const uint32_t *text, 444 int text_length, 445 unsigned int item_offset, 446 int item_length); 447 448 HB_EXTERN void 449 hb_buffer_add_latin1 (hb_buffer_t *buffer, 450 const uint8_t *text, 451 int text_length, 452 unsigned int item_offset, 453 int item_length); 454 455 HB_EXTERN void 456 hb_buffer_add_codepoints (hb_buffer_t *buffer, 457 const hb_codepoint_t *text, 458 int text_length, 459 unsigned int item_offset, 460 int item_length); 461 462 HB_EXTERN void 463 hb_buffer_append (hb_buffer_t *buffer, 464 hb_buffer_t *source, 465 unsigned int start, 466 unsigned int end); 467 468 HB_EXTERN hb_bool_t 469 hb_buffer_set_length (hb_buffer_t *buffer, 470 unsigned int length); 471 472 HB_EXTERN unsigned int 473 hb_buffer_get_length (hb_buffer_t *buffer); 474 475 /* Getting glyphs out of the buffer */ 476 477 HB_EXTERN hb_glyph_info_t * 478 hb_buffer_get_glyph_infos (hb_buffer_t *buffer, 479 unsigned int *length); 480 481 HB_EXTERN hb_glyph_position_t * 482 hb_buffer_get_glyph_positions (hb_buffer_t *buffer, 483 unsigned int *length); 484 485 HB_EXTERN hb_bool_t 486 hb_buffer_has_positions (hb_buffer_t *buffer); 487 488 489 HB_EXTERN void 490 hb_buffer_normalize_glyphs (hb_buffer_t *buffer); 491 492 493 /* 494 * Serialize 495 */ 496 497 /** 498 * hb_buffer_serialize_flags_t: 499 * @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions. 500 * @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster. 501 * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information. 502 * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name. 503 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents. 504 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0 505 * @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances, 506 * glyph offsets will reflect absolute glyph positions. Since: 1.8.0 507 * 508 * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs(). 509 * 510 * Since: 0.9.20 511 */ 512 typedef enum { /*< flags >*/ 513 HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u, 514 HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u, 515 HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u, 516 HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u, 517 HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u, 518 HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u, 519 HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u 520 } hb_buffer_serialize_flags_t; 521 522 /** 523 * hb_buffer_serialize_format_t: 524 * @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format. 525 * @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format. 526 * @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format. 527 * 528 * The buffer serialization and de-serialization format used in 529 * hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs(). 530 * 531 * Since: 0.9.2 532 */ 533 typedef enum { 534 HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), 535 HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), 536 HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE 537 } hb_buffer_serialize_format_t; 538 539 HB_EXTERN hb_buffer_serialize_format_t 540 hb_buffer_serialize_format_from_string (const char *str, int len); 541 542 HB_EXTERN const char * 543 hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); 544 545 HB_EXTERN const char ** 546 hb_buffer_serialize_list_formats (void); 547 548 HB_EXTERN unsigned int 549 hb_buffer_serialize_glyphs (hb_buffer_t *buffer, 550 unsigned int start, 551 unsigned int end, 552 char *buf, 553 unsigned int buf_size, 554 unsigned int *buf_consumed, 555 hb_font_t *font, 556 hb_buffer_serialize_format_t format, 557 hb_buffer_serialize_flags_t flags); 558 559 HB_EXTERN unsigned int 560 hb_buffer_serialize_unicode (hb_buffer_t *buffer, 561 unsigned int start, 562 unsigned int end, 563 char *buf, 564 unsigned int buf_size, 565 unsigned int *buf_consumed, 566 hb_buffer_serialize_format_t format, 567 hb_buffer_serialize_flags_t flags); 568 569 HB_EXTERN unsigned int 570 hb_buffer_serialize (hb_buffer_t *buffer, 571 unsigned int start, 572 unsigned int end, 573 char *buf, 574 unsigned int buf_size, 575 unsigned int *buf_consumed, 576 hb_font_t *font, 577 hb_buffer_serialize_format_t format, 578 hb_buffer_serialize_flags_t flags); 579 580 HB_EXTERN hb_bool_t 581 hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, 582 const char *buf, 583 int buf_len, 584 const char **end_ptr, 585 hb_font_t *font, 586 hb_buffer_serialize_format_t format); 587 588 HB_EXTERN hb_bool_t 589 hb_buffer_deserialize_unicode (hb_buffer_t *buffer, 590 const char *buf, 591 int buf_len, 592 const char **end_ptr, 593 hb_buffer_serialize_format_t format); 594 595 596 597 /* 598 * Compare buffers 599 */ 600 601 /** 602 * hb_buffer_diff_flags_t: 603 * @HB_BUFFER_DIFF_FLAG_EQUAL: equal buffers. 604 * @HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH: buffers with different 605 * #hb_buffer_content_type_t. 606 * @HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH: buffers with differing length. 607 * @HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT: `.notdef` glyph is present in the 608 * reference buffer. 609 * @HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT: dotted circle glyph is present 610 * in the reference buffer. 611 * @HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH: difference in #hb_glyph_info_t.codepoint 612 * @HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH: difference in #hb_glyph_info_t.cluster 613 * @HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH: difference in #hb_glyph_flags_t. 614 * @HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH: difference in #hb_glyph_position_t. 615 * 616 * Flags from comparing two #hb_buffer_t's. 617 * 618 * Buffer with different #hb_buffer_content_type_t cannot be meaningfully 619 * compared in any further detail. 620 * 621 * For buffers with differing length, the per-glyph comparison is not 622 * attempted, though we do still scan reference buffer for dotted circle and 623 * `.notdef` glyphs. 624 * 625 * If the buffers have the same length, we compare them glyph-by-glyph and 626 * report which aspect(s) of the glyph info/position are different. 627 * 628 * Since: 1.5.0 629 */ 630 typedef enum { /*< flags >*/ 631 HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000, 632 633 /* Buffers with different content_type cannot be meaningfully compared 634 * in any further detail. */ 635 HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001, 636 637 /* For buffers with differing length, the per-glyph comparison is not 638 * attempted, though we do still scan reference for dottedcircle / .notdef 639 * glyphs. */ 640 HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002, 641 642 /* We want to know if dottedcircle / .notdef glyphs are present in the 643 * reference, as we may not care so much about other differences in this 644 * case. */ 645 HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004, 646 HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008, 647 648 /* If the buffers have the same length, we compare them glyph-by-glyph 649 * and report which aspect(s) of the glyph info/position are different. */ 650 HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010, 651 HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020, 652 HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040, 653 HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080 654 655 } hb_buffer_diff_flags_t; 656 657 /* Compare the contents of two buffers, report types of differences. */ 658 HB_EXTERN hb_buffer_diff_flags_t 659 hb_buffer_diff (hb_buffer_t *buffer, 660 hb_buffer_t *reference, 661 hb_codepoint_t dottedcircle_glyph, 662 unsigned int position_fuzz); 663 664 665 /* 666 * Debugging. 667 */ 668 669 /** 670 * hb_buffer_message_func_t: 671 * @buffer: An #hb_buffer_t to work upon 672 * @font: The #hb_font_t the @buffer is shaped with 673 * @message: %NULL-terminated message passed to the function 674 * @user_data: User data pointer passed by the caller 675 * 676 * A callback method for #hb_buffer_t. The method gets called with the 677 * #hb_buffer_t it was set on, the #hb_font_t the buffer is shaped with and a 678 * message describing what step of the shaping process will be performed. 679 * Returning %false from this method will skip this shaping step and move to 680 * the next one. 681 * 682 * Return value: %true to perform the shaping step, %false to skip it. 683 * 684 * Since: 1.1.3 685 */ 686 typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer, 687 hb_font_t *font, 688 const char *message, 689 void *user_data); 690 691 HB_EXTERN void 692 hb_buffer_set_message_func (hb_buffer_t *buffer, 693 hb_buffer_message_func_t func, 694 void *user_data, hb_destroy_func_t destroy); 695 696 697 HB_END_DECLS 698 699 #endif /* HB_BUFFER_H */ 700