![]() |
|
|||
File indexing completed on 2025-09-18 09:18:11
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 * @HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES: Only group clusters, but don't enforce monotone order. 0426 * 0427 * Data type for holding HarfBuzz's clustering behavior options. The cluster level 0428 * dictates one aspect of how HarfBuzz will treat non-base characters 0429 * during shaping. 0430 * 0431 * In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES, non-base 0432 * characters are merged into the cluster of the base character that precedes them. 0433 * There is also cluster merging every time the clusters will otherwise become non-monotone. 0434 * 0435 * In @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS, non-base characters are initially 0436 * assigned their own cluster values, which are not merged into preceding base 0437 * clusters. This allows HarfBuzz to perform additional operations like reorder 0438 * sequences of adjacent marks. The output is still monotone, but the cluster 0439 * values are more granular. 0440 * 0441 * In @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS, non-base characters are assigned their 0442 * own cluster values, which are not merged into preceding base clusters. Moreover, 0443 * the cluster values are not merged into monotone order. This is the most granular 0444 * cluster level, and it is useful for clients that need to know the exact cluster 0445 * values of each character, but is harder to use for clients, since clusters 0446 * might appear in any order. 0447 * 0448 * In @HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES, non-base characters are merged into the 0449 * cluster of the base character that precedes them. This is similar to the Unicode 0450 * Grapheme Cluster algorithm, but it is not exactly the same. The output is 0451 * not forced to be monotone. This is useful for clients that want to use HarfBuzz 0452 * as a cheap implementation of the Unicode Grapheme Cluster algorithm. 0453 * 0454 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES is the default, because it maintains 0455 * backward compatibility with older versions of HarfBuzz. New client programs that 0456 * do not need to maintain such backward compatibility are recommended to use 0457 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS instead of the default. 0458 * 0459 * Since: 0.9.42 0460 */ 0461 typedef enum { 0462 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0, 0463 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1, 0464 HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2, 0465 HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES = 3, 0466 HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES 0467 } hb_buffer_cluster_level_t; 0468 0469 /** 0470 * HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE: 0471 * @level: #hb_buffer_cluster_level_t to test 0472 * 0473 * Tests whether a cluster level groups cluster values into monotone order. 0474 * Requires that the level be valid. 0475 * 0476 * Since: 11.0.0 0477 */ 0478 #define HB_BUFFER_CLUSTER_LEVEL_IS_MONOTONE(level) \ 0479 ((bool) ((1u << (unsigned) (level)) & \ 0480 ((1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) | \ 0481 (1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS)))) 0482 0483 /** 0484 * HB_BUFFER_CLUSTER_LEVEL_IS_GRAPHEMES: 0485 * @level: #hb_buffer_cluster_level_t to test 0486 * 0487 * Tests whether a cluster level groups cluster values by graphemes. Requires 0488 * that the level be valid. 0489 * 0490 * Since: 11.0.0 0491 */ 0492 #define HB_BUFFER_CLUSTER_LEVEL_IS_GRAPHEMES(level) \ 0493 ((bool) ((1u << (unsigned) (level)) & \ 0494 ((1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES) | \ 0495 (1u << HB_BUFFER_CLUSTER_LEVEL_GRAPHEMES)))) 0496 0497 /** 0498 * HB_BUFFER_CLUSTER_LEVEL_IS_CHARACTERS 0499 * @level: #hb_buffer_cluster_level_t to test 0500 * 0501 * Tests whether a cluster level does not group cluster values by graphemes. 0502 * Requires that the level be valid. 0503 * 0504 * Since: 11.0.0 0505 */ 0506 #define HB_BUFFER_CLUSTER_LEVEL_IS_CHARACTERS(level) \ 0507 ((bool) ((1u << (unsigned) (level)) & \ 0508 ((1u << HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARCATERS) | \ 0509 (1u << HB_BUFFER_CLUSTER_LEVEL_CHARACTERS)))) 0510 0511 HB_EXTERN void 0512 hb_buffer_set_cluster_level (hb_buffer_t *buffer, 0513 hb_buffer_cluster_level_t cluster_level); 0514 0515 HB_EXTERN hb_buffer_cluster_level_t 0516 hb_buffer_get_cluster_level (const hb_buffer_t *buffer); 0517 0518 /** 0519 * HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT: 0520 * 0521 * The default code point for replacing invalid characters in a given encoding. 0522 * Set to U+FFFD REPLACEMENT CHARACTER. 0523 * 0524 * Since: 0.9.31 0525 */ 0526 #define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu 0527 0528 HB_EXTERN void 0529 hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, 0530 hb_codepoint_t replacement); 0531 0532 HB_EXTERN hb_codepoint_t 0533 hb_buffer_get_replacement_codepoint (const hb_buffer_t *buffer); 0534 0535 HB_EXTERN void 0536 hb_buffer_set_invisible_glyph (hb_buffer_t *buffer, 0537 hb_codepoint_t invisible); 0538 0539 HB_EXTERN hb_codepoint_t 0540 hb_buffer_get_invisible_glyph (const hb_buffer_t *buffer); 0541 0542 HB_EXTERN void 0543 hb_buffer_set_not_found_glyph (hb_buffer_t *buffer, 0544 hb_codepoint_t not_found); 0545 0546 HB_EXTERN hb_codepoint_t 0547 hb_buffer_get_not_found_glyph (const hb_buffer_t *buffer); 0548 0549 HB_EXTERN void 0550 hb_buffer_set_not_found_variation_selector_glyph (hb_buffer_t *buffer, 0551 hb_codepoint_t not_found_variation_selector); 0552 0553 HB_EXTERN hb_codepoint_t 0554 hb_buffer_get_not_found_variation_selector_glyph (const hb_buffer_t *buffer); 0555 0556 HB_EXTERN void 0557 hb_buffer_set_random_state (hb_buffer_t *buffer, 0558 unsigned state); 0559 0560 HB_EXTERN unsigned 0561 hb_buffer_get_random_state (const hb_buffer_t *buffer); 0562 0563 /* 0564 * Content API. 0565 */ 0566 0567 HB_EXTERN void 0568 hb_buffer_clear_contents (hb_buffer_t *buffer); 0569 0570 HB_EXTERN hb_bool_t 0571 hb_buffer_pre_allocate (hb_buffer_t *buffer, 0572 unsigned int size); 0573 0574 0575 HB_EXTERN hb_bool_t 0576 hb_buffer_allocation_successful (hb_buffer_t *buffer); 0577 0578 HB_EXTERN void 0579 hb_buffer_reverse (hb_buffer_t *buffer); 0580 0581 HB_EXTERN void 0582 hb_buffer_reverse_range (hb_buffer_t *buffer, 0583 unsigned int start, unsigned int end); 0584 0585 HB_EXTERN void 0586 hb_buffer_reverse_clusters (hb_buffer_t *buffer); 0587 0588 0589 /* Filling the buffer in */ 0590 0591 HB_EXTERN void 0592 hb_buffer_add (hb_buffer_t *buffer, 0593 hb_codepoint_t codepoint, 0594 unsigned int cluster); 0595 0596 HB_EXTERN void 0597 hb_buffer_add_utf8 (hb_buffer_t *buffer, 0598 const char *text, 0599 int text_length, 0600 unsigned int item_offset, 0601 int item_length); 0602 0603 HB_EXTERN void 0604 hb_buffer_add_utf16 (hb_buffer_t *buffer, 0605 const uint16_t *text, 0606 int text_length, 0607 unsigned int item_offset, 0608 int item_length); 0609 0610 HB_EXTERN void 0611 hb_buffer_add_utf32 (hb_buffer_t *buffer, 0612 const uint32_t *text, 0613 int text_length, 0614 unsigned int item_offset, 0615 int item_length); 0616 0617 HB_EXTERN void 0618 hb_buffer_add_latin1 (hb_buffer_t *buffer, 0619 const uint8_t *text, 0620 int text_length, 0621 unsigned int item_offset, 0622 int item_length); 0623 0624 HB_EXTERN void 0625 hb_buffer_add_codepoints (hb_buffer_t *buffer, 0626 const hb_codepoint_t *text, 0627 int text_length, 0628 unsigned int item_offset, 0629 int item_length); 0630 0631 HB_EXTERN void 0632 hb_buffer_append (hb_buffer_t *buffer, 0633 const hb_buffer_t *source, 0634 unsigned int start, 0635 unsigned int end); 0636 0637 HB_EXTERN hb_bool_t 0638 hb_buffer_set_length (hb_buffer_t *buffer, 0639 unsigned int length); 0640 0641 HB_EXTERN unsigned int 0642 hb_buffer_get_length (const hb_buffer_t *buffer); 0643 0644 /* Getting glyphs out of the buffer */ 0645 0646 HB_EXTERN hb_glyph_info_t * 0647 hb_buffer_get_glyph_infos (hb_buffer_t *buffer, 0648 unsigned int *length); 0649 0650 HB_EXTERN hb_glyph_position_t * 0651 hb_buffer_get_glyph_positions (hb_buffer_t *buffer, 0652 unsigned int *length); 0653 0654 HB_EXTERN hb_bool_t 0655 hb_buffer_has_positions (hb_buffer_t *buffer); 0656 0657 0658 HB_EXTERN void 0659 hb_buffer_normalize_glyphs (hb_buffer_t *buffer); 0660 0661 0662 /* 0663 * Serialize 0664 */ 0665 0666 /** 0667 * hb_buffer_serialize_flags_t: 0668 * @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions. 0669 * @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster. 0670 * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information. 0671 * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name. 0672 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents. 0673 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0 0674 * @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances, 0675 * glyph offsets will reflect absolute glyph positions. Since: 1.8.0 0676 * @HB_BUFFER_SERIALIZE_FLAG_DEFINED: All currently defined flags. Since: 4.4.0 0677 * 0678 * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs(). 0679 * 0680 * Since: 0.9.20 0681 */ 0682 typedef enum { /*< flags >*/ 0683 HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u, 0684 HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u, 0685 HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u, 0686 HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u, 0687 HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u, 0688 HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u, 0689 HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u, 0690 0691 HB_BUFFER_SERIALIZE_FLAG_DEFINED = 0x0000003Fu 0692 } hb_buffer_serialize_flags_t; 0693 0694 /** 0695 * hb_buffer_serialize_format_t: 0696 * @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format. 0697 * @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format. 0698 * @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format. 0699 * 0700 * The buffer serialization and de-serialization format used in 0701 * hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs(). 0702 * 0703 * Since: 0.9.2 0704 */ 0705 typedef enum { 0706 HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), 0707 HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), 0708 HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE 0709 } hb_buffer_serialize_format_t; 0710 0711 HB_EXTERN hb_buffer_serialize_format_t 0712 hb_buffer_serialize_format_from_string (const char *str, int len); 0713 0714 HB_EXTERN const char * 0715 hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); 0716 0717 HB_EXTERN const char ** 0718 hb_buffer_serialize_list_formats (void); 0719 0720 HB_EXTERN unsigned int 0721 hb_buffer_serialize_glyphs (hb_buffer_t *buffer, 0722 unsigned int start, 0723 unsigned int end, 0724 char *buf, 0725 unsigned int buf_size, 0726 unsigned int *buf_consumed, 0727 hb_font_t *font, 0728 hb_buffer_serialize_format_t format, 0729 hb_buffer_serialize_flags_t flags); 0730 0731 HB_EXTERN unsigned int 0732 hb_buffer_serialize_unicode (hb_buffer_t *buffer, 0733 unsigned int start, 0734 unsigned int end, 0735 char *buf, 0736 unsigned int buf_size, 0737 unsigned int *buf_consumed, 0738 hb_buffer_serialize_format_t format, 0739 hb_buffer_serialize_flags_t flags); 0740 0741 HB_EXTERN unsigned int 0742 hb_buffer_serialize (hb_buffer_t *buffer, 0743 unsigned int start, 0744 unsigned int end, 0745 char *buf, 0746 unsigned int buf_size, 0747 unsigned int *buf_consumed, 0748 hb_font_t *font, 0749 hb_buffer_serialize_format_t format, 0750 hb_buffer_serialize_flags_t flags); 0751 0752 HB_EXTERN hb_bool_t 0753 hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, 0754 const char *buf, 0755 int buf_len, 0756 const char **end_ptr, 0757 hb_font_t *font, 0758 hb_buffer_serialize_format_t format); 0759 0760 HB_EXTERN hb_bool_t 0761 hb_buffer_deserialize_unicode (hb_buffer_t *buffer, 0762 const char *buf, 0763 int buf_len, 0764 const char **end_ptr, 0765 hb_buffer_serialize_format_t format); 0766 0767 0768 0769 /* 0770 * Compare buffers 0771 */ 0772 0773 /** 0774 * hb_buffer_diff_flags_t: 0775 * @HB_BUFFER_DIFF_FLAG_EQUAL: equal buffers. 0776 * @HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH: buffers with different 0777 * #hb_buffer_content_type_t. 0778 * @HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH: buffers with differing length. 0779 * @HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT: `.notdef` glyph is present in the 0780 * reference buffer. 0781 * @HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT: dotted circle glyph is present 0782 * in the reference buffer. 0783 * @HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH: difference in #hb_glyph_info_t.codepoint 0784 * @HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH: difference in #hb_glyph_info_t.cluster 0785 * @HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH: difference in #hb_glyph_flags_t. 0786 * @HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH: difference in #hb_glyph_position_t. 0787 * 0788 * Flags from comparing two #hb_buffer_t's. 0789 * 0790 * Buffer with different #hb_buffer_content_type_t cannot be meaningfully 0791 * compared in any further detail. 0792 * 0793 * For buffers with differing length, the per-glyph comparison is not 0794 * attempted, though we do still scan reference buffer for dotted circle and 0795 * `.notdef` glyphs. 0796 * 0797 * If the buffers have the same length, we compare them glyph-by-glyph and 0798 * report which aspect(s) of the glyph info/position are different. 0799 * 0800 * Since: 1.5.0 0801 */ 0802 typedef enum { /*< flags >*/ 0803 HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000, 0804 0805 /* Buffers with different content_type cannot be meaningfully compared 0806 * in any further detail. */ 0807 HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001, 0808 0809 /* For buffers with differing length, the per-glyph comparison is not 0810 * attempted, though we do still scan reference for dottedcircle / .notdef 0811 * glyphs. */ 0812 HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002, 0813 0814 /* We want to know if dottedcircle / .notdef glyphs are present in the 0815 * reference, as we may not care so much about other differences in this 0816 * case. */ 0817 HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004, 0818 HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008, 0819 0820 /* If the buffers have the same length, we compare them glyph-by-glyph 0821 * and report which aspect(s) of the glyph info/position are different. */ 0822 HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010, 0823 HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020, 0824 HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040, 0825 HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080 0826 0827 } hb_buffer_diff_flags_t; 0828 0829 /* Compare the contents of two buffers, report types of differences. */ 0830 HB_EXTERN hb_buffer_diff_flags_t 0831 hb_buffer_diff (hb_buffer_t *buffer, 0832 hb_buffer_t *reference, 0833 hb_codepoint_t dottedcircle_glyph, 0834 unsigned int position_fuzz); 0835 0836 0837 /* 0838 * Tracing. 0839 */ 0840 0841 /** 0842 * hb_buffer_message_func_t: 0843 * @buffer: An #hb_buffer_t to work upon 0844 * @font: The #hb_font_t the @buffer is shaped with 0845 * @message: `NULL`-terminated message passed to the function 0846 * @user_data: User data pointer passed by the caller 0847 * 0848 * A callback method for #hb_buffer_t. The method gets called with the 0849 * #hb_buffer_t it was set on, the #hb_font_t the buffer is shaped with and a 0850 * message describing what step of the shaping process will be performed. 0851 * Returning `false` from this method will skip this shaping step and move to 0852 * the next one. 0853 * 0854 * Return value: `true` to perform the shaping step, `false` to skip it. 0855 * 0856 * Since: 1.1.3 0857 */ 0858 typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer, 0859 hb_font_t *font, 0860 const char *message, 0861 void *user_data); 0862 0863 HB_EXTERN void 0864 hb_buffer_set_message_func (hb_buffer_t *buffer, 0865 hb_buffer_message_func_t func, 0866 void *user_data, hb_destroy_func_t destroy); 0867 0868 0869 HB_END_DECLS 0870 0871 #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 |
![]() ![]() |