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