![]() |
|
|||
File indexing completed on 2025-02-21 10:04:01
0001 /* 0002 * Copyright © 1998-2004 David Turner and Werner Lemberg 0003 * Copyright © 2004,2007,2009 Red Hat, Inc. 0004 * Copyright © 2011,2012 Google, Inc. 0005 * 0006 * This is part of HarfBuzz, a text shaping library. 0007 * 0008 * Permission is hereby granted, without written agreement and without 0009 * license or royalty fees, to use, copy, modify, and distribute this 0010 * software and its documentation for any purpose, provided that the 0011 * above copyright notice and the following two paragraphs appear in 0012 * all copies of this software. 0013 * 0014 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 0015 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 0016 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 0017 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 0018 * DAMAGE. 0019 * 0020 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 0021 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 0022 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 0023 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 0024 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 0025 * 0026 * Red Hat Author(s): Owen Taylor, Behdad Esfahbod 0027 * Google Author(s): Behdad Esfahbod 0028 */ 0029 0030 #if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR) 0031 #error "Include <hb.h> instead." 0032 #endif 0033 0034 #ifndef HB_BUFFER_H 0035 #define HB_BUFFER_H 0036 0037 #include "hb-common.h" 0038 #include "hb-unicode.h" 0039 #include "hb-font.h" 0040 0041 HB_BEGIN_DECLS 0042 0043 /** 0044 * hb_glyph_info_t: 0045 * @codepoint: either a Unicode code point (before shaping) or a glyph index 0046 * (after shaping). 0047 * @cluster: the index of the character in the original text that corresponds 0048 * to this #hb_glyph_info_t, or whatever the client passes to 0049 * hb_buffer_add(). More than one #hb_glyph_info_t can have the same 0050 * @cluster value, if they resulted from the same character (e.g. one 0051 * to many glyph substitution), and when more than one character gets 0052 * merged in the same glyph (e.g. many to one glyph substitution) the 0053 * #hb_glyph_info_t will have the smallest cluster value of them. 0054 * By default some characters are merged into the same cluster 0055 * (e.g. combining marks have the same cluster as their bases) 0056 * even if they are separate glyphs, hb_buffer_set_cluster_level() 0057 * allow selecting more fine-grained cluster handling. 0058 * 0059 * The #hb_glyph_info_t is the structure that holds information about the 0060 * glyphs and their relation to input text. 0061 */ 0062 typedef struct hb_glyph_info_t { 0063 hb_codepoint_t codepoint; 0064 /*< private >*/ 0065 hb_mask_t mask; 0066 /*< public >*/ 0067 uint32_t cluster; 0068 0069 /*< private >*/ 0070 hb_var_int_t var1; 0071 hb_var_int_t var2; 0072 } hb_glyph_info_t; 0073 0074 /** 0075 * hb_glyph_flags_t: 0076 * @HB_GLYPH_FLAG_UNSAFE_TO_BREAK: Indicates that if input text is broken at the 0077 * beginning of the cluster this glyph is part of, 0078 * then both sides need to be re-shaped, as the 0079 * result might be different. 0080 * On the flip side, it means that when this 0081 * flag is not present, then it is safe to break 0082 * the glyph-run at the beginning of this 0083 * cluster, and the two sides will represent the 0084 * exact same result one would get if breaking 0085 * input text at the beginning of this cluster 0086 * and shaping the two sides separately. 0087 * This can be used to optimize paragraph 0088 * layout, by avoiding re-shaping of each line 0089 * after line-breaking. 0090 * @HB_GLYPH_FLAG_UNSAFE_TO_CONCAT: Indicates that if input text is changed on one 0091 * side of the beginning of the cluster this glyph 0092 * is part of, then the shaping results for the 0093 * other side might change. 0094 * Note that the absence of this flag will NOT by 0095 * itself mean that it IS safe to concat text. 0096 * Only two pieces of text both of which clear of 0097 * this flag can be concatenated safely. 0098 * This can be used to optimize paragraph 0099 * layout, by avoiding re-shaping of each line 0100 * after line-breaking, by limiting the 0101 * reshaping to a small piece around the 0102 * breaking position only, even if the breaking 0103 * position carries the 0104 * #HB_GLYPH_FLAG_UNSAFE_TO_BREAK or when 0105 * hyphenation or other text transformation 0106 * happens at line-break position, in the following 0107 * way: 0108 * 1. Iterate back from the line-break position 0109 * until the first cluster start position that is 0110 * NOT unsafe-to-concat, 2. shape the segment from 0111 * there till the end of line, 3. check whether the 0112 * resulting glyph-run also is clear of the 0113 * unsafe-to-concat at its start-of-text position; 0114 * if it is, just splice it into place and the line 0115 * is shaped; If not, move on to a position further 0116 * back that is clear of unsafe-to-concat and retry 0117 * from there, and repeat. 0118 * At the start of next line a similar algorithm can 0119 * be implemented. That is: 1. Iterate forward from 0120 * the line-break position until the first cluster 0121 * start position that is NOT unsafe-to-concat, 2. 0122 * shape the segment from beginning of the line to 0123 * that position, 3. check whether the resulting 0124 * glyph-run also is clear of the unsafe-to-concat 0125 * at its end-of-text position; if it is, just splice 0126 * it into place and the beginning is shaped; If not, 0127 * move on to a position further forward that is clear 0128 * of unsafe-to-concat and retry up to there, and repeat. 0129 * A slight complication will arise in the 0130 * implementation of the algorithm above, 0131 * because while our buffer API has a way to 0132 * return flags for position corresponding to 0133 * start-of-text, there is currently no position 0134 * corresponding to end-of-text. This limitation 0135 * can be alleviated by shaping more text than needed 0136 * and looking for unsafe-to-concat flag within text 0137 * clusters. 0138 * The #HB_GLYPH_FLAG_UNSAFE_TO_BREAK flag will 0139 * always imply this flag. 0140 * To use this flag, you must enable the buffer flag 0141 * @HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT during 0142 * shaping, otherwise the buffer flag will not be 0143 * reliably produced. 0144 * Since: 4.0.0 0145 * @HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL: In scripts that use elongation (Arabic, 0146 Mongolian, Syriac, etc.), this flag signifies 0147 that it is safe to insert a U+0640 TATWEEL 0148 character before this cluster for elongation. 0149 This flag does not determine the 0150 script-specific elongation places, but only 0151 when it is safe to do the elongation without 0152 interrupting text shaping. 0153 Since: 5.1.0 0154 * @HB_GLYPH_FLAG_DEFINED: All the currently defined flags. 0155 * 0156 * Flags for #hb_glyph_info_t. 0157 * 0158 * Since: 1.5.0 0159 */ 0160 typedef enum { /*< flags >*/ 0161 HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001, 0162 HB_GLYPH_FLAG_UNSAFE_TO_CONCAT = 0x00000002, 0163 HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL = 0x00000004, 0164 0165 HB_GLYPH_FLAG_DEFINED = 0x00000007 /* OR of all defined flags */ 0166 } hb_glyph_flags_t; 0167 0168 HB_EXTERN hb_glyph_flags_t 0169 hb_glyph_info_get_glyph_flags (const hb_glyph_info_t *info); 0170 0171 #define hb_glyph_info_get_glyph_flags(info) \ 0172 ((hb_glyph_flags_t) ((unsigned int) (info)->mask & HB_GLYPH_FLAG_DEFINED)) 0173 0174 0175 /** 0176 * hb_glyph_position_t: 0177 * @x_advance: how much the line advances after drawing this glyph when setting 0178 * text in horizontal direction. 0179 * @y_advance: how much the line advances after drawing this glyph when setting 0180 * text in vertical direction. 0181 * @x_offset: how much the glyph moves on the X-axis before drawing it, this 0182 * should not affect how much the line advances. 0183 * @y_offset: how much the glyph moves on the Y-axis before drawing it, this 0184 * should not affect how much the line advances. 0185 * 0186 * The #hb_glyph_position_t is the structure that holds the positions of the 0187 * glyph in both horizontal and vertical directions. All positions in 0188 * #hb_glyph_position_t are relative to the current point. 0189 * 0190 */ 0191 typedef struct hb_glyph_position_t { 0192 hb_position_t x_advance; 0193 hb_position_t y_advance; 0194 hb_position_t x_offset; 0195 hb_position_t y_offset; 0196 0197 /*< private >*/ 0198 hb_var_int_t var; 0199 } hb_glyph_position_t; 0200 0201 /** 0202 * hb_segment_properties_t: 0203 * @direction: the #hb_direction_t of the buffer, see hb_buffer_set_direction(). 0204 * @script: the #hb_script_t of the buffer, see hb_buffer_set_script(). 0205 * @language: the #hb_language_t of the buffer, see hb_buffer_set_language(). 0206 * 0207 * The structure that holds various text properties of an #hb_buffer_t. Can be 0208 * set and retrieved using hb_buffer_set_segment_properties() and 0209 * hb_buffer_get_segment_properties(), respectively. 0210 */ 0211 typedef struct hb_segment_properties_t { 0212 hb_direction_t direction; 0213 hb_script_t script; 0214 hb_language_t language; 0215 /*< private >*/ 0216 void *reserved1; 0217 void *reserved2; 0218 } hb_segment_properties_t; 0219 0220 /** 0221 * HB_SEGMENT_PROPERTIES_DEFAULT: 0222 * 0223 * The default #hb_segment_properties_t of of freshly created #hb_buffer_t. 0224 */ 0225 #define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \ 0226 HB_SCRIPT_INVALID, \ 0227 HB_LANGUAGE_INVALID, \ 0228 (void *) 0, \ 0229 (void *) 0} 0230 0231 HB_EXTERN hb_bool_t 0232 hb_segment_properties_equal (const hb_segment_properties_t *a, 0233 const hb_segment_properties_t *b); 0234 0235 HB_EXTERN unsigned int 0236 hb_segment_properties_hash (const hb_segment_properties_t *p); 0237 0238 HB_EXTERN void 0239 hb_segment_properties_overlay (hb_segment_properties_t *p, 0240 const hb_segment_properties_t *src); 0241 0242 0243 /** 0244 * hb_buffer_t: 0245 * 0246 * The main structure holding the input text and its properties before shaping, 0247 * and output glyphs and their information after shaping. 0248 */ 0249 0250 typedef struct hb_buffer_t hb_buffer_t; 0251 0252 HB_EXTERN hb_buffer_t * 0253 hb_buffer_create (void); 0254 0255 HB_EXTERN hb_buffer_t * 0256 hb_buffer_create_similar (const hb_buffer_t *src); 0257 0258 HB_EXTERN void 0259 hb_buffer_reset (hb_buffer_t *buffer); 0260 0261 0262 HB_EXTERN hb_buffer_t * 0263 hb_buffer_get_empty (void); 0264 0265 HB_EXTERN hb_buffer_t * 0266 hb_buffer_reference (hb_buffer_t *buffer); 0267 0268 HB_EXTERN void 0269 hb_buffer_destroy (hb_buffer_t *buffer); 0270 0271 HB_EXTERN hb_bool_t 0272 hb_buffer_set_user_data (hb_buffer_t *buffer, 0273 hb_user_data_key_t *key, 0274 void * data, 0275 hb_destroy_func_t destroy, 0276 hb_bool_t replace); 0277 0278 HB_EXTERN void * 0279 hb_buffer_get_user_data (const hb_buffer_t *buffer, 0280 hb_user_data_key_t *key); 0281 0282 0283 /** 0284 * hb_buffer_content_type_t: 0285 * @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer. 0286 * @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping). 0287 * @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping). 0288 * 0289 * The type of #hb_buffer_t contents. 0290 */ 0291 typedef enum { 0292 HB_BUFFER_CONTENT_TYPE_INVALID = 0, 0293 HB_BUFFER_CONTENT_TYPE_UNICODE, 0294 HB_BUFFER_CONTENT_TYPE_GLYPHS 0295 } hb_buffer_content_type_t; 0296 0297 HB_EXTERN void 0298 hb_buffer_set_content_type (hb_buffer_t *buffer, 0299 hb_buffer_content_type_t content_type); 0300 0301 HB_EXTERN hb_buffer_content_type_t 0302 hb_buffer_get_content_type (const hb_buffer_t *buffer); 0303 0304 0305 HB_EXTERN void 0306 hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, 0307 hb_unicode_funcs_t *unicode_funcs); 0308 0309 HB_EXTERN hb_unicode_funcs_t * 0310 hb_buffer_get_unicode_funcs (const hb_buffer_t *buffer); 0311 0312 HB_EXTERN void 0313 hb_buffer_set_direction (hb_buffer_t *buffer, 0314 hb_direction_t direction); 0315 0316 HB_EXTERN hb_direction_t 0317 hb_buffer_get_direction (const hb_buffer_t *buffer); 0318 0319 HB_EXTERN void 0320 hb_buffer_set_script (hb_buffer_t *buffer, 0321 hb_script_t script); 0322 0323 HB_EXTERN hb_script_t 0324 hb_buffer_get_script (const hb_buffer_t *buffer); 0325 0326 HB_EXTERN void 0327 hb_buffer_set_language (hb_buffer_t *buffer, 0328 hb_language_t language); 0329 0330 0331 HB_EXTERN hb_language_t 0332 hb_buffer_get_language (const hb_buffer_t *buffer); 0333 0334 HB_EXTERN void 0335 hb_buffer_set_segment_properties (hb_buffer_t *buffer, 0336 const hb_segment_properties_t *props); 0337 0338 HB_EXTERN void 0339 hb_buffer_get_segment_properties (const hb_buffer_t *buffer, 0340 hb_segment_properties_t *props); 0341 0342 HB_EXTERN void 0343 hb_buffer_guess_segment_properties (hb_buffer_t *buffer); 0344 0345 0346 /** 0347 * hb_buffer_flags_t: 0348 * @HB_BUFFER_FLAG_DEFAULT: the default buffer flag. 0349 * @HB_BUFFER_FLAG_BOT: flag indicating that special handling of the beginning 0350 * of text paragraph can be applied to this buffer. Should usually 0351 * be set, unless you are passing to the buffer only part 0352 * of the text without the full context. 0353 * @HB_BUFFER_FLAG_EOT: flag indicating that special handling of the end of text 0354 * paragraph can be applied to this buffer, similar to 0355 * @HB_BUFFER_FLAG_BOT. 0356 * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES: 0357 * flag indication that character with Default_Ignorable 0358 * Unicode property should use the corresponding glyph 0359 * from the font, instead of hiding them (done by 0360 * replacing them with the space glyph and zeroing the 0361 * advance width.) This flag takes precedence over 0362 * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES. 0363 * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES: 0364 * flag indication that character with Default_Ignorable 0365 * Unicode property should be removed from glyph string 0366 * instead of hiding them (done by replacing them with the 0367 * space glyph and zeroing the advance width.) 0368 * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES takes 0369 * precedence over this flag. Since: 1.8.0 0370 * @HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE: 0371 * flag indicating that a dotted circle should 0372 * not be inserted in the rendering of incorrect 0373 * character sequences (such at <0905 093E>). Since: 2.4.0 0374 * @HB_BUFFER_FLAG_VERIFY: 0375 * flag indicating that the hb_shape() call and its variants 0376 * should perform various verification processes on the results 0377 * of the shaping operation on the buffer. If the verification 0378 * fails, then either a buffer message is sent, if a message 0379 * handler is installed on the buffer, or a message is written 0380 * to standard error. In either case, the shaping result might 0381 * be modified to show the failed output. Since: 3.4.0 0382 * @HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT: 0383 * flag indicating that the @HB_GLYPH_FLAG_UNSAFE_TO_CONCAT 0384 * glyph-flag should be produced by the shaper. By default 0385 * it will not be produced since it incurs a cost. Since: 4.0.0 0386 * @HB_BUFFER_FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL: 0387 * flag indicating that the @HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL 0388 * glyph-flag should be produced by the shaper. By default 0389 * it will not be produced. Since: 5.1.0 0390 * @HB_BUFFER_FLAG_DEFINED: All currently defined flags: Since: 4.4.0 0391 * 0392 * Flags for #hb_buffer_t. 0393 * 0394 * Since: 0.9.20 0395 */ 0396 typedef enum { /*< flags >*/ 0397 HB_BUFFER_FLAG_DEFAULT = 0x00000000u, 0398 HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */ 0399 HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */ 0400 HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u, 0401 HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES = 0x00000008u, 0402 HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE = 0x00000010u, 0403 HB_BUFFER_FLAG_VERIFY = 0x00000020u, 0404 HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT = 0x00000040u, 0405 HB_BUFFER_FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL = 0x00000080u, 0406 0407 HB_BUFFER_FLAG_DEFINED = 0x000000FFu 0408 } hb_buffer_flags_t; 0409 0410 HB_EXTERN void 0411 hb_buffer_set_flags (hb_buffer_t *buffer, 0412 hb_buffer_flags_t flags); 0413 0414 HB_EXTERN hb_buffer_flags_t 0415 hb_buffer_get_flags (const hb_buffer_t *buffer); 0416 0417 /** 0418 * hb_buffer_cluster_level_t: 0419 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES: Return cluster values grouped by graphemes into 0420 * monotone order. 0421 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS: Return cluster values grouped into monotone order. 0422 * @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values. 0423 * @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level, 0424 * equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES. 0425 * 0426 * Data type for holding HarfBuzz's clustering behavior options. The cluster level 0427 * dictates one aspect of how HarfBuzz will treat non-base characters 0428 * during shaping. 0429 * 0430 * In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES, non-base 0431 * characters are merged into the cluster of the base character that precedes them. 0432 * 0433 * In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS, non-base characters are initially 0434 * assigned their own cluster values, which are not merged into preceding base 0435 * clusters. This allows HarfBuzz to perform additional operations like reorder 0436 * sequences of adjacent marks. 0437 * 0438 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES is the default, because it maintains 0439 * backward compatibility with older versions of HarfBuzz. New client programs that 0440 * do not need to maintain such backward compatibility are recommended to use 0441 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS instead of the default. 0442 * 0443 * Since: 0.9.42 0444 */ 0445 typedef enum { 0446 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0, 0447 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1, 0448 HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2, 0449 HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES 0450 } hb_buffer_cluster_level_t; 0451 0452 HB_EXTERN void 0453 hb_buffer_set_cluster_level (hb_buffer_t *buffer, 0454 hb_buffer_cluster_level_t cluster_level); 0455 0456 HB_EXTERN hb_buffer_cluster_level_t 0457 hb_buffer_get_cluster_level (const hb_buffer_t *buffer); 0458 0459 /** 0460 * HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT: 0461 * 0462 * The default code point for replacing invalid characters in a given encoding. 0463 * Set to U+FFFD REPLACEMENT CHARACTER. 0464 * 0465 * Since: 0.9.31 0466 */ 0467 #define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu 0468 0469 HB_EXTERN void 0470 hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, 0471 hb_codepoint_t replacement); 0472 0473 HB_EXTERN hb_codepoint_t 0474 hb_buffer_get_replacement_codepoint (const hb_buffer_t *buffer); 0475 0476 HB_EXTERN void 0477 hb_buffer_set_invisible_glyph (hb_buffer_t *buffer, 0478 hb_codepoint_t invisible); 0479 0480 HB_EXTERN hb_codepoint_t 0481 hb_buffer_get_invisible_glyph (const hb_buffer_t *buffer); 0482 0483 HB_EXTERN void 0484 hb_buffer_set_not_found_glyph (hb_buffer_t *buffer, 0485 hb_codepoint_t not_found); 0486 0487 HB_EXTERN hb_codepoint_t 0488 hb_buffer_get_not_found_glyph (const hb_buffer_t *buffer); 0489 0490 HB_EXTERN void 0491 hb_buffer_set_not_found_variation_selector_glyph (hb_buffer_t *buffer, 0492 hb_codepoint_t not_found_variation_selector); 0493 0494 HB_EXTERN hb_codepoint_t 0495 hb_buffer_get_not_found_variation_selector_glyph (const hb_buffer_t *buffer); 0496 0497 HB_EXTERN void 0498 hb_buffer_set_random_state (hb_buffer_t *buffer, 0499 unsigned state); 0500 0501 HB_EXTERN unsigned 0502 hb_buffer_get_random_state (const hb_buffer_t *buffer); 0503 0504 /* 0505 * Content API. 0506 */ 0507 0508 HB_EXTERN void 0509 hb_buffer_clear_contents (hb_buffer_t *buffer); 0510 0511 HB_EXTERN hb_bool_t 0512 hb_buffer_pre_allocate (hb_buffer_t *buffer, 0513 unsigned int size); 0514 0515 0516 HB_EXTERN hb_bool_t 0517 hb_buffer_allocation_successful (hb_buffer_t *buffer); 0518 0519 HB_EXTERN void 0520 hb_buffer_reverse (hb_buffer_t *buffer); 0521 0522 HB_EXTERN void 0523 hb_buffer_reverse_range (hb_buffer_t *buffer, 0524 unsigned int start, unsigned int end); 0525 0526 HB_EXTERN void 0527 hb_buffer_reverse_clusters (hb_buffer_t *buffer); 0528 0529 0530 /* Filling the buffer in */ 0531 0532 HB_EXTERN void 0533 hb_buffer_add (hb_buffer_t *buffer, 0534 hb_codepoint_t codepoint, 0535 unsigned int cluster); 0536 0537 HB_EXTERN void 0538 hb_buffer_add_utf8 (hb_buffer_t *buffer, 0539 const char *text, 0540 int text_length, 0541 unsigned int item_offset, 0542 int item_length); 0543 0544 HB_EXTERN void 0545 hb_buffer_add_utf16 (hb_buffer_t *buffer, 0546 const uint16_t *text, 0547 int text_length, 0548 unsigned int item_offset, 0549 int item_length); 0550 0551 HB_EXTERN void 0552 hb_buffer_add_utf32 (hb_buffer_t *buffer, 0553 const uint32_t *text, 0554 int text_length, 0555 unsigned int item_offset, 0556 int item_length); 0557 0558 HB_EXTERN void 0559 hb_buffer_add_latin1 (hb_buffer_t *buffer, 0560 const uint8_t *text, 0561 int text_length, 0562 unsigned int item_offset, 0563 int item_length); 0564 0565 HB_EXTERN void 0566 hb_buffer_add_codepoints (hb_buffer_t *buffer, 0567 const hb_codepoint_t *text, 0568 int text_length, 0569 unsigned int item_offset, 0570 int item_length); 0571 0572 HB_EXTERN void 0573 hb_buffer_append (hb_buffer_t *buffer, 0574 const hb_buffer_t *source, 0575 unsigned int start, 0576 unsigned int end); 0577 0578 HB_EXTERN hb_bool_t 0579 hb_buffer_set_length (hb_buffer_t *buffer, 0580 unsigned int length); 0581 0582 HB_EXTERN unsigned int 0583 hb_buffer_get_length (const hb_buffer_t *buffer); 0584 0585 /* Getting glyphs out of the buffer */ 0586 0587 HB_EXTERN hb_glyph_info_t * 0588 hb_buffer_get_glyph_infos (hb_buffer_t *buffer, 0589 unsigned int *length); 0590 0591 HB_EXTERN hb_glyph_position_t * 0592 hb_buffer_get_glyph_positions (hb_buffer_t *buffer, 0593 unsigned int *length); 0594 0595 HB_EXTERN hb_bool_t 0596 hb_buffer_has_positions (hb_buffer_t *buffer); 0597 0598 0599 HB_EXTERN void 0600 hb_buffer_normalize_glyphs (hb_buffer_t *buffer); 0601 0602 0603 /* 0604 * Serialize 0605 */ 0606 0607 /** 0608 * hb_buffer_serialize_flags_t: 0609 * @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions. 0610 * @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster. 0611 * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information. 0612 * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name. 0613 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents. 0614 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0 0615 * @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances, 0616 * glyph offsets will reflect absolute glyph positions. Since: 1.8.0 0617 * @HB_BUFFER_SERIALIZE_FLAG_DEFINED: All currently defined flags. Since: 4.4.0 0618 * 0619 * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs(). 0620 * 0621 * Since: 0.9.20 0622 */ 0623 typedef enum { /*< flags >*/ 0624 HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u, 0625 HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u, 0626 HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u, 0627 HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u, 0628 HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u, 0629 HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u, 0630 HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u, 0631 0632 HB_BUFFER_SERIALIZE_FLAG_DEFINED = 0x0000003Fu 0633 } hb_buffer_serialize_flags_t; 0634 0635 /** 0636 * hb_buffer_serialize_format_t: 0637 * @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format. 0638 * @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format. 0639 * @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format. 0640 * 0641 * The buffer serialization and de-serialization format used in 0642 * hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs(). 0643 * 0644 * Since: 0.9.2 0645 */ 0646 typedef enum { 0647 HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), 0648 HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), 0649 HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE 0650 } hb_buffer_serialize_format_t; 0651 0652 HB_EXTERN hb_buffer_serialize_format_t 0653 hb_buffer_serialize_format_from_string (const char *str, int len); 0654 0655 HB_EXTERN const char * 0656 hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); 0657 0658 HB_EXTERN const char ** 0659 hb_buffer_serialize_list_formats (void); 0660 0661 HB_EXTERN unsigned int 0662 hb_buffer_serialize_glyphs (hb_buffer_t *buffer, 0663 unsigned int start, 0664 unsigned int end, 0665 char *buf, 0666 unsigned int buf_size, 0667 unsigned int *buf_consumed, 0668 hb_font_t *font, 0669 hb_buffer_serialize_format_t format, 0670 hb_buffer_serialize_flags_t flags); 0671 0672 HB_EXTERN unsigned int 0673 hb_buffer_serialize_unicode (hb_buffer_t *buffer, 0674 unsigned int start, 0675 unsigned int end, 0676 char *buf, 0677 unsigned int buf_size, 0678 unsigned int *buf_consumed, 0679 hb_buffer_serialize_format_t format, 0680 hb_buffer_serialize_flags_t flags); 0681 0682 HB_EXTERN unsigned int 0683 hb_buffer_serialize (hb_buffer_t *buffer, 0684 unsigned int start, 0685 unsigned int end, 0686 char *buf, 0687 unsigned int buf_size, 0688 unsigned int *buf_consumed, 0689 hb_font_t *font, 0690 hb_buffer_serialize_format_t format, 0691 hb_buffer_serialize_flags_t flags); 0692 0693 HB_EXTERN hb_bool_t 0694 hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, 0695 const char *buf, 0696 int buf_len, 0697 const char **end_ptr, 0698 hb_font_t *font, 0699 hb_buffer_serialize_format_t format); 0700 0701 HB_EXTERN hb_bool_t 0702 hb_buffer_deserialize_unicode (hb_buffer_t *buffer, 0703 const char *buf, 0704 int buf_len, 0705 const char **end_ptr, 0706 hb_buffer_serialize_format_t format); 0707 0708 0709 0710 /* 0711 * Compare buffers 0712 */ 0713 0714 /** 0715 * hb_buffer_diff_flags_t: 0716 * @HB_BUFFER_DIFF_FLAG_EQUAL: equal buffers. 0717 * @HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH: buffers with different 0718 * #hb_buffer_content_type_t. 0719 * @HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH: buffers with differing length. 0720 * @HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT: `.notdef` glyph is present in the 0721 * reference buffer. 0722 * @HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT: dotted circle glyph is present 0723 * in the reference buffer. 0724 * @HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH: difference in #hb_glyph_info_t.codepoint 0725 * @HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH: difference in #hb_glyph_info_t.cluster 0726 * @HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH: difference in #hb_glyph_flags_t. 0727 * @HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH: difference in #hb_glyph_position_t. 0728 * 0729 * Flags from comparing two #hb_buffer_t's. 0730 * 0731 * Buffer with different #hb_buffer_content_type_t cannot be meaningfully 0732 * compared in any further detail. 0733 * 0734 * For buffers with differing length, the per-glyph comparison is not 0735 * attempted, though we do still scan reference buffer for dotted circle and 0736 * `.notdef` glyphs. 0737 * 0738 * If the buffers have the same length, we compare them glyph-by-glyph and 0739 * report which aspect(s) of the glyph info/position are different. 0740 * 0741 * Since: 1.5.0 0742 */ 0743 typedef enum { /*< flags >*/ 0744 HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000, 0745 0746 /* Buffers with different content_type cannot be meaningfully compared 0747 * in any further detail. */ 0748 HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001, 0749 0750 /* For buffers with differing length, the per-glyph comparison is not 0751 * attempted, though we do still scan reference for dottedcircle / .notdef 0752 * glyphs. */ 0753 HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002, 0754 0755 /* We want to know if dottedcircle / .notdef glyphs are present in the 0756 * reference, as we may not care so much about other differences in this 0757 * case. */ 0758 HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004, 0759 HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008, 0760 0761 /* If the buffers have the same length, we compare them glyph-by-glyph 0762 * and report which aspect(s) of the glyph info/position are different. */ 0763 HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010, 0764 HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020, 0765 HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040, 0766 HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080 0767 0768 } hb_buffer_diff_flags_t; 0769 0770 /* Compare the contents of two buffers, report types of differences. */ 0771 HB_EXTERN hb_buffer_diff_flags_t 0772 hb_buffer_diff (hb_buffer_t *buffer, 0773 hb_buffer_t *reference, 0774 hb_codepoint_t dottedcircle_glyph, 0775 unsigned int position_fuzz); 0776 0777 0778 /* 0779 * Tracing. 0780 */ 0781 0782 /** 0783 * hb_buffer_message_func_t: 0784 * @buffer: An #hb_buffer_t to work upon 0785 * @font: The #hb_font_t the @buffer is shaped with 0786 * @message: `NULL`-terminated message passed to the function 0787 * @user_data: User data pointer passed by the caller 0788 * 0789 * A callback method for #hb_buffer_t. The method gets called with the 0790 * #hb_buffer_t it was set on, the #hb_font_t the buffer is shaped with and a 0791 * message describing what step of the shaping process will be performed. 0792 * Returning `false` from this method will skip this shaping step and move to 0793 * the next one. 0794 * 0795 * Return value: `true` to perform the shaping step, `false` to skip it. 0796 * 0797 * Since: 1.1.3 0798 */ 0799 typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer, 0800 hb_font_t *font, 0801 const char *message, 0802 void *user_data); 0803 0804 HB_EXTERN void 0805 hb_buffer_set_message_func (hb_buffer_t *buffer, 0806 hb_buffer_message_func_t func, 0807 void *user_data, hb_destroy_func_t destroy); 0808 0809 0810 HB_END_DECLS 0811 0812 #endif /* HB_BUFFER_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |