Behdad Esfahbod | a2a9a02 | 2008-01-15 22:46:32 +0000 | [diff] [blame] | 1 | /* |
Behdad Esfahbod | 2409d5f | 2011-04-21 17:14:28 -0400 | [diff] [blame] | 2 | * Copyright © 1998-2004 David Turner and Werner Lemberg |
| 3 | * Copyright © 2004,2007,2009 Red Hat, Inc. |
Behdad Esfahbod | 05207a7 | 2012-09-25 17:44:53 -0400 | [diff] [blame] | 4 | * Copyright © 2011,2012 Google, Inc. |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 5 | * |
Behdad Esfahbod | 8f0d7e0 | 2011-04-15 18:59:56 -0400 | [diff] [blame] | 6 | * This is part of HarfBuzz, a text shaping library. |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 7 | * |
Behdad Esfahbod | a2a9a02 | 2008-01-15 22:46:32 +0000 | [diff] [blame] | 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. |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 13 | * |
Behdad Esfahbod | a2a9a02 | 2008-01-15 22:46:32 +0000 | [diff] [blame] | 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 |
Behdad Esfahbod | c910bec | 2011-04-13 15:49:06 -0400 | [diff] [blame] | 27 | * Google Author(s): Behdad Esfahbod |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 28 | */ |
Behdad Esfahbod | a2a9a02 | 2008-01-15 22:46:32 +0000 | [diff] [blame] | 29 | |
Behdad Esfahbod | d1c9eb4 | 2012-04-12 13:17:44 -0400 | [diff] [blame] | 30 | #ifndef HB_H_IN |
| 31 | #error "Include <hb.h> instead." |
| 32 | #endif |
| 33 | |
Behdad Esfahbod | 5c0adce | 2009-05-20 05:42:12 -0400 | [diff] [blame] | 34 | #ifndef HB_BUFFER_H |
| 35 | #define HB_BUFFER_H |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 36 | |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 37 | #include "hb-common.h" |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 38 | #include "hb-unicode.h" |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 39 | #include "hb-font.h" |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 40 | |
Behdad Esfahbod | f96ffd4 | 2009-05-24 15:01:16 -0400 | [diff] [blame] | 41 | HB_BEGIN_DECLS |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 42 | |
Khaled Hosny | fb192c2 | 2015-12-30 15:05:50 +0400 | [diff] [blame] | 43 | /** |
| 44 | * hb_glyph_info_t: |
| 45 | * @codepoint: either a Unicode code point (before shaping) or a glyph index |
| 46 | * (after shaping). |
Khaled Hosny | fb192c2 | 2015-12-30 15:05:50 +0400 | [diff] [blame] | 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 |
Behdad Esfahbod | 97624d9 | 2016-01-11 12:58:45 +0000 | [diff] [blame] | 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. |
Khaled Hosny | fb192c2 | 2015-12-30 15:05:50 +0400 | [diff] [blame] | 58 | * |
Khaled Hosny | 9ab9f97 | 2016-01-01 20:38:21 +0400 | [diff] [blame] | 59 | * The #hb_glyph_info_t is the structure that holds information about the |
Khaled Hosny | fb192c2 | 2015-12-30 15:05:50 +0400 | [diff] [blame] | 60 | * glyphs and their relation to input text. |
Khaled Hosny | fb192c2 | 2015-12-30 15:05:50 +0400 | [diff] [blame] | 61 | */ |
Behdad Esfahbod | 55bae68 | 2018-09-24 10:43:06 -0400 | [diff] [blame] | 62 | typedef struct hb_glyph_info_t |
| 63 | { |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 64 | hb_codepoint_t codepoint; |
Behdad Esfahbod | 1dd1e56 | 2018-09-30 18:25:58 +0200 | [diff] [blame] | 65 | /*< private >*/ |
Behdad Esfahbod | 55bae68 | 2018-09-24 10:43:06 -0400 | [diff] [blame] | 66 | hb_mask_t mask; |
Behdad Esfahbod | 1dd1e56 | 2018-09-30 18:25:58 +0200 | [diff] [blame] | 67 | /*< public >*/ |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 68 | uint32_t cluster; |
Behdad Esfahbod | b54cd07 | 2011-04-15 19:12:01 -0400 | [diff] [blame] | 69 | |
| 70 | /*< private >*/ |
Behdad Esfahbod | 6cb8c34 | 2010-10-27 14:27:03 -0400 | [diff] [blame] | 71 | hb_var_int_t var1; |
| 72 | hb_var_int_t var2; |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 73 | } hb_glyph_info_t; |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 74 | |
bungeman | 671f0a7 | 2018-02-01 13:31:25 -0500 | [diff] [blame] | 75 | /** |
| 76 | * hb_glyph_flags_t: |
Behdad Esfahbod | 3b7aa65 | 2018-02-09 15:43:20 -0600 | [diff] [blame] | 77 | * @HB_GLYPH_FLAG_UNSAFE_TO_BREAK: Indicates that if input text is broken at the |
| 78 | * beginning of the cluster this glyph is part of, |
| 79 | * then both sides need to be re-shaped, as the |
| 80 | * result might be different. On the flip side, |
| 81 | * it means that when this flag is not present, |
| 82 | * then it's safe to break the glyph-run at the |
| 83 | * beginning of this cluster, and the two sides |
| 84 | * represent the exact same result one would get |
| 85 | * if breaking input text at the beginning of |
Behdad Esfahbod | d45f240 | 2018-02-09 15:51:45 -0600 | [diff] [blame] | 86 | * this cluster and shaping the two sides |
Behdad Esfahbod | 3b7aa65 | 2018-02-09 15:43:20 -0600 | [diff] [blame] | 87 | * separately. This can be used to optimize |
| 88 | * paragraph layout, by avoiding re-shaping |
| 89 | * of each line after line-breaking, or limiting |
| 90 | * the reshaping to a small piece around the |
| 91 | * breaking point only. |
Behdad Esfahbod | 1e39833 | 2018-10-20 16:56:06 -0700 | [diff] [blame] | 92 | * @HB_GLYPH_FLAG_DEFINED: All the currently defined flags. |
Behdad Esfahbod | 1a2eb10 | 2018-11-19 12:36:56 -0500 | [diff] [blame] | 93 | * |
| 94 | * Since: 1.5.0 |
bungeman | 671f0a7 | 2018-02-01 13:31:25 -0500 | [diff] [blame] | 95 | */ |
Behdad Esfahbod | 40bd7e9 | 2016-05-02 14:47:45 +0200 | [diff] [blame] | 96 | typedef enum { /*< flags >*/ |
Behdad Esfahbod | 5287ccc | 2017-08-10 14:25:53 -0700 | [diff] [blame] | 97 | HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001, |
| 98 | |
Behdad Esfahbod | 1e39833 | 2018-10-20 16:56:06 -0700 | [diff] [blame] | 99 | HB_GLYPH_FLAG_DEFINED = 0x00000001 /* OR of all defined flags */ |
Behdad Esfahbod | 40bd7e9 | 2016-05-02 14:47:45 +0200 | [diff] [blame] | 100 | } hb_glyph_flags_t; |
| 101 | |
Behdad Esfahbod | b2dd0c1 | 2017-08-23 13:12:54 -0700 | [diff] [blame] | 102 | HB_EXTERN hb_glyph_flags_t |
| 103 | hb_glyph_info_get_glyph_flags (const hb_glyph_info_t *info); |
| 104 | |
| 105 | #define hb_glyph_info_get_glyph_flags(info) \ |
| 106 | ((hb_glyph_flags_t) ((unsigned int) (info)->mask & HB_GLYPH_FLAG_DEFINED)) |
| 107 | |
| 108 | |
Khaled Hosny | fb192c2 | 2015-12-30 15:05:50 +0400 | [diff] [blame] | 109 | /** |
| 110 | * hb_glyph_position_t: |
| 111 | * @x_advance: how much the line advances after drawing this glyph when setting |
| 112 | * text in horizontal direction. |
| 113 | * @y_advance: how much the line advances after drawing this glyph when setting |
| 114 | * text in vertical direction. |
| 115 | * @x_offset: how much the glyph moves on the X-axis before drawing it, this |
| 116 | * should not affect how much the line advances. |
| 117 | * @y_offset: how much the glyph moves on the Y-axis before drawing it, this |
| 118 | * should not affect how much the line advances. |
| 119 | * |
| 120 | * The #hb_glyph_position_t is the structure that holds the positions of the |
| 121 | * glyph in both horizontal and vertical directions. All positions in |
| 122 | * #hb_glyph_position_t are relative to the current point. |
| 123 | * |
| 124 | */ |
Behdad Esfahbod | 1bc1cb3 | 2012-06-16 15:21:55 -0400 | [diff] [blame] | 125 | typedef struct hb_glyph_position_t { |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 126 | hb_position_t x_advance; |
| 127 | hb_position_t y_advance; |
Behdad Esfahbod | 9bef361 | 2009-11-05 12:20:11 -0500 | [diff] [blame] | 128 | hb_position_t x_offset; |
| 129 | hb_position_t y_offset; |
Behdad Esfahbod | b54cd07 | 2011-04-15 19:12:01 -0400 | [diff] [blame] | 130 | |
| 131 | /*< private >*/ |
Behdad Esfahbod | 88474c6 | 2010-10-27 14:42:15 -0400 | [diff] [blame] | 132 | hb_var_int_t var; |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 133 | } hb_glyph_position_t; |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 134 | |
Khaled Hosny | 9ab9f97 | 2016-01-01 20:38:21 +0400 | [diff] [blame] | 135 | /** |
| 136 | * hb_segment_properties_t: |
| 137 | * @direction: the #hb_direction_t of the buffer, see hb_buffer_set_direction(). |
| 138 | * @script: the #hb_script_t of the buffer, see hb_buffer_set_script(). |
| 139 | * @language: the #hb_language_t of the buffer, see hb_buffer_set_language(). |
| 140 | * |
| 141 | * The structure that holds various text properties of an #hb_buffer_t. Can be |
| 142 | * set and retrieved using hb_buffer_set_segment_properties() and |
| 143 | * hb_buffer_get_segment_properties(), respectively. |
| 144 | */ |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 145 | typedef struct hb_segment_properties_t { |
| 146 | hb_direction_t direction; |
| 147 | hb_script_t script; |
| 148 | hb_language_t language; |
| 149 | /*< private >*/ |
| 150 | void *reserved1; |
| 151 | void *reserved2; |
| 152 | } hb_segment_properties_t; |
| 153 | |
| 154 | #define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \ |
| 155 | HB_SCRIPT_INVALID, \ |
| 156 | HB_LANGUAGE_INVALID, \ |
Behdad Esfahbod | fbb937b | 2017-10-15 12:04:16 +0200 | [diff] [blame] | 157 | (void *) 0, \ |
| 158 | (void *) 0} |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 159 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 160 | HB_EXTERN hb_bool_t |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 161 | hb_segment_properties_equal (const hb_segment_properties_t *a, |
| 162 | const hb_segment_properties_t *b); |
| 163 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 164 | HB_EXTERN unsigned int |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 165 | hb_segment_properties_hash (const hb_segment_properties_t *p); |
| 166 | |
| 167 | |
| 168 | |
Khaled Hosny | 9ab9f97 | 2016-01-01 20:38:21 +0400 | [diff] [blame] | 169 | /** |
| 170 | * hb_buffer_t: |
| 171 | * |
| 172 | * The main structure holding the input text and its properties before shaping, |
| 173 | * and output glyphs and their information after shaping. |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 174 | */ |
| 175 | |
| 176 | typedef struct hb_buffer_t hb_buffer_t; |
| 177 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 178 | HB_EXTERN hb_buffer_t * |
Behdad Esfahbod | e6c09cd | 2011-08-17 19:07:59 +0200 | [diff] [blame] | 179 | hb_buffer_create (void); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 180 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 181 | HB_EXTERN hb_buffer_t * |
Behdad Esfahbod | 80a6833 | 2011-05-11 18:14:44 -0400 | [diff] [blame] | 182 | hb_buffer_get_empty (void); |
| 183 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 184 | HB_EXTERN hb_buffer_t * |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 185 | hb_buffer_reference (hb_buffer_t *buffer); |
| 186 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 187 | HB_EXTERN void |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 188 | hb_buffer_destroy (hb_buffer_t *buffer); |
| 189 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 190 | HB_EXTERN hb_bool_t |
Behdad Esfahbod | 5fa849b | 2011-04-27 21:46:01 -0400 | [diff] [blame] | 191 | hb_buffer_set_user_data (hb_buffer_t *buffer, |
| 192 | hb_user_data_key_t *key, |
| 193 | void * data, |
Behdad Esfahbod | 33ccc77 | 2011-08-09 00:43:24 +0200 | [diff] [blame] | 194 | hb_destroy_func_t destroy, |
| 195 | hb_bool_t replace); |
Behdad Esfahbod | 5fa849b | 2011-04-27 21:46:01 -0400 | [diff] [blame] | 196 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 197 | HB_EXTERN void * |
Behdad Esfahbod | 5fa849b | 2011-04-27 21:46:01 -0400 | [diff] [blame] | 198 | hb_buffer_get_user_data (hb_buffer_t *buffer, |
| 199 | hb_user_data_key_t *key); |
| 200 | |
Behdad Esfahbod | 39a9749 | 2017-08-11 15:52:06 -0700 | [diff] [blame] | 201 | |
Khaled Hosny | 8ab797c | 2015-12-29 17:42:16 +0400 | [diff] [blame] | 202 | /** |
| 203 | * hb_buffer_content_type_t: |
| 204 | * @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer. |
| 205 | * @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping). |
| 206 | * @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping). |
| 207 | */ |
Behdad Esfahbod | 92f9bfe | 2012-11-13 16:50:45 -0800 | [diff] [blame] | 208 | typedef enum { |
| 209 | HB_BUFFER_CONTENT_TYPE_INVALID = 0, |
| 210 | HB_BUFFER_CONTENT_TYPE_UNICODE, |
| 211 | HB_BUFFER_CONTENT_TYPE_GLYPHS |
| 212 | } hb_buffer_content_type_t; |
| 213 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 214 | HB_EXTERN void |
Behdad Esfahbod | 96fdc04 | 2012-09-06 22:26:16 -0400 | [diff] [blame] | 215 | hb_buffer_set_content_type (hb_buffer_t *buffer, |
| 216 | hb_buffer_content_type_t content_type); |
| 217 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 218 | HB_EXTERN hb_buffer_content_type_t |
Behdad Esfahbod | 96fdc04 | 2012-09-06 22:26:16 -0400 | [diff] [blame] | 219 | hb_buffer_get_content_type (hb_buffer_t *buffer); |
| 220 | |
| 221 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 222 | HB_EXTERN void |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 223 | hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, |
| 224 | hb_unicode_funcs_t *unicode_funcs); |
| 225 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 226 | HB_EXTERN hb_unicode_funcs_t * |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 227 | hb_buffer_get_unicode_funcs (hb_buffer_t *buffer); |
| 228 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 229 | HB_EXTERN void |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 230 | hb_buffer_set_direction (hb_buffer_t *buffer, |
| 231 | hb_direction_t direction); |
| 232 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 233 | HB_EXTERN hb_direction_t |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 234 | hb_buffer_get_direction (hb_buffer_t *buffer); |
| 235 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 236 | HB_EXTERN void |
Behdad Esfahbod | ae070b7 | 2009-11-04 20:29:54 -0500 | [diff] [blame] | 237 | hb_buffer_set_script (hb_buffer_t *buffer, |
| 238 | hb_script_t script); |
| 239 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 240 | HB_EXTERN hb_script_t |
Behdad Esfahbod | ae070b7 | 2009-11-04 20:29:54 -0500 | [diff] [blame] | 241 | hb_buffer_get_script (hb_buffer_t *buffer); |
| 242 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 243 | HB_EXTERN void |
Behdad Esfahbod | ae070b7 | 2009-11-04 20:29:54 -0500 | [diff] [blame] | 244 | hb_buffer_set_language (hb_buffer_t *buffer, |
| 245 | hb_language_t language); |
| 246 | |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 247 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 248 | HB_EXTERN hb_language_t |
Behdad Esfahbod | ae070b7 | 2009-11-04 20:29:54 -0500 | [diff] [blame] | 249 | hb_buffer_get_language (hb_buffer_t *buffer); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 250 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 251 | HB_EXTERN void |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 252 | hb_buffer_set_segment_properties (hb_buffer_t *buffer, |
| 253 | const hb_segment_properties_t *props); |
| 254 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 255 | HB_EXTERN void |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 256 | hb_buffer_get_segment_properties (hb_buffer_t *buffer, |
| 257 | hb_segment_properties_t *props); |
| 258 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 259 | HB_EXTERN void |
Behdad Esfahbod | 3f82f8f | 2012-11-15 18:45:31 -0800 | [diff] [blame] | 260 | hb_buffer_guess_segment_properties (hb_buffer_t *buffer); |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 261 | |
Behdad Esfahbod | 92f9bfe | 2012-11-13 16:50:45 -0800 | [diff] [blame] | 262 | |
Khaled Hosny | fb192c2 | 2015-12-30 15:05:50 +0400 | [diff] [blame] | 263 | /** |
| 264 | * hb_buffer_flags_t: |
| 265 | * @HB_BUFFER_FLAG_DEFAULT: the default buffer flag. |
| 266 | * @HB_BUFFER_FLAG_BOT: flag indicating that special handling of the beginning |
Behdad Esfahbod | 97624d9 | 2016-01-11 12:58:45 +0000 | [diff] [blame] | 267 | * of text paragraph can be applied to this buffer. Should usually |
| 268 | * be set, unless you are passing to the buffer only part |
Khaled Hosny | fb192c2 | 2015-12-30 15:05:50 +0400 | [diff] [blame] | 269 | * of the text without the full context. |
| 270 | * @HB_BUFFER_FLAG_EOT: flag indicating that special handling of the end of text |
Behdad Esfahbod | 97624d9 | 2016-01-11 12:58:45 +0000 | [diff] [blame] | 271 | * paragraph can be applied to this buffer, similar to |
Bruce Mitchener | 19a93fc | 2018-01-21 20:40:34 +0700 | [diff] [blame] | 272 | * @HB_BUFFER_FLAG_BOT. |
Khaled Hosny | fb192c2 | 2015-12-30 15:05:50 +0400 | [diff] [blame] | 273 | * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES: |
Behdad Esfahbod | 97624d9 | 2016-01-11 12:58:45 +0000 | [diff] [blame] | 274 | * flag indication that character with Default_Ignorable |
Khaled Hosny | fb192c2 | 2015-12-30 15:05:50 +0400 | [diff] [blame] | 275 | * Unicode property should use the corresponding glyph |
Behdad Esfahbod | 3b1e97f | 2018-01-10 03:35:20 +0100 | [diff] [blame] | 276 | * from the font, instead of hiding them (done by |
| 277 | * replacing them with the space glyph and zeroing the |
Bruce Mitchener | 19a93fc | 2018-01-21 20:40:34 +0700 | [diff] [blame] | 278 | * advance width.) This flag takes precedence over |
Behdad Esfahbod | 3b1e97f | 2018-01-10 03:35:20 +0100 | [diff] [blame] | 279 | * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES. |
| 280 | * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES: |
| 281 | * flag indication that character with Default_Ignorable |
| 282 | * Unicode property should be removed from glyph string |
| 283 | * instead of hiding them (done by replacing them with the |
| 284 | * space glyph and zeroing the advance width.) |
| 285 | * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES takes |
| 286 | * precedence over this flag. Since: 1.8.0 |
Eric Muller | 30d7c40 | 2019-02-09 02:55:27 -0800 | [diff] [blame] | 287 | * @HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE: |
| 288 | * flag indicating that a dotted circle should |
| 289 | * not be inserted in the rendering of incorrect |
Behdad Esfahbod | d6fc1d4 | 2019-03-28 21:21:26 -0700 | [diff] [blame] | 290 | * character sequences (such at <0905 093E>). Since: 2.4 |
Khaled Hosny | fb192c2 | 2015-12-30 15:05:50 +0400 | [diff] [blame] | 291 | * |
Behdad Esfahbod | b881142 | 2015-09-03 15:53:22 +0430 | [diff] [blame] | 292 | * Since: 0.9.20 |
| 293 | */ |
Behdad Esfahbod | 4dc798d | 2013-08-26 20:39:00 -0400 | [diff] [blame] | 294 | typedef enum { /*< flags >*/ |
Behdad Esfahbod | 11fb16c | 2013-10-17 20:57:57 +0200 | [diff] [blame] | 295 | HB_BUFFER_FLAG_DEFAULT = 0x00000000u, |
| 296 | HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */ |
| 297 | HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */ |
Behdad Esfahbod | 3b1e97f | 2018-01-10 03:35:20 +0100 | [diff] [blame] | 298 | HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u, |
Eric Muller | 30d7c40 | 2019-02-09 02:55:27 -0800 | [diff] [blame] | 299 | HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES = 0x00000008u, |
| 300 | HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE = 0x00000010u |
Behdad Esfahbod | 92f9bfe | 2012-11-13 16:50:45 -0800 | [diff] [blame] | 301 | } hb_buffer_flags_t; |
| 302 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 303 | HB_EXTERN void |
Behdad Esfahbod | 0c7df22 | 2012-11-13 14:42:35 -0800 | [diff] [blame] | 304 | hb_buffer_set_flags (hb_buffer_t *buffer, |
| 305 | hb_buffer_flags_t flags); |
| 306 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 307 | HB_EXTERN hb_buffer_flags_t |
Behdad Esfahbod | 0c7df22 | 2012-11-13 14:42:35 -0800 | [diff] [blame] | 308 | hb_buffer_get_flags (hb_buffer_t *buffer); |
| 309 | |
Behdad Esfahbod | 55bae68 | 2018-09-24 10:43:06 -0400 | [diff] [blame] | 310 | /** |
| 311 | * hb_buffer_cluster_level_t: |
| 312 | * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES: Return cluster values grouped by graphemes into |
| 313 | * monotone order. |
| 314 | * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS: Return cluster values grouped into monotone order. |
| 315 | * @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values. |
| 316 | * @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level, |
| 317 | * equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES. |
| 318 | * |
Behdad Esfahbod | b881142 | 2015-09-03 15:53:22 +0430 | [diff] [blame] | 319 | * Since: 0.9.42 |
| 320 | */ |
Behdad Esfahbod | 376d587 | 2015-07-22 16:51:12 +0100 | [diff] [blame] | 321 | typedef enum { |
| 322 | HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0, |
| 323 | HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1, |
| 324 | HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2, |
| 325 | HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES |
| 326 | } hb_buffer_cluster_level_t; |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 327 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 328 | HB_EXTERN void |
Behdad Esfahbod | 376d587 | 2015-07-22 16:51:12 +0100 | [diff] [blame] | 329 | hb_buffer_set_cluster_level (hb_buffer_t *buffer, |
| 330 | hb_buffer_cluster_level_t cluster_level); |
| 331 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 332 | HB_EXTERN hb_buffer_cluster_level_t |
Behdad Esfahbod | 376d587 | 2015-07-22 16:51:12 +0100 | [diff] [blame] | 333 | hb_buffer_get_cluster_level (hb_buffer_t *buffer); |
Behdad Esfahbod | 976c8f4 | 2014-07-16 15:34:20 -0400 | [diff] [blame] | 334 | |
Khaled Hosny | 9ab9f97 | 2016-01-01 20:38:21 +0400 | [diff] [blame] | 335 | /** |
| 336 | * HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT: |
| 337 | * |
| 338 | * The default code point for replacing invalid characters in a given encoding. |
| 339 | * Set to U+FFFD REPLACEMENT CHARACTER. |
| 340 | * |
| 341 | * Since: 0.9.31 |
| 342 | */ |
Behdad Esfahbod | 976c8f4 | 2014-07-16 15:34:20 -0400 | [diff] [blame] | 343 | #define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu |
| 344 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 345 | HB_EXTERN void |
Behdad Esfahbod | 976c8f4 | 2014-07-16 15:34:20 -0400 | [diff] [blame] | 346 | hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, |
| 347 | hb_codepoint_t replacement); |
| 348 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 349 | HB_EXTERN hb_codepoint_t |
Behdad Esfahbod | 976c8f4 | 2014-07-16 15:34:20 -0400 | [diff] [blame] | 350 | hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer); |
| 351 | |
Behdad Esfahbod | 71b65eb | 2018-10-07 18:41:52 +0200 | [diff] [blame] | 352 | HB_EXTERN void |
Behdad Esfahbod | e42cd58 | 2018-10-07 20:46:11 -0400 | [diff] [blame] | 353 | hb_buffer_set_invisible_glyph (hb_buffer_t *buffer, |
| 354 | hb_codepoint_t invisible); |
Behdad Esfahbod | 71b65eb | 2018-10-07 18:41:52 +0200 | [diff] [blame] | 355 | |
| 356 | HB_EXTERN hb_codepoint_t |
Behdad Esfahbod | e42cd58 | 2018-10-07 20:46:11 -0400 | [diff] [blame] | 357 | hb_buffer_get_invisible_glyph (hb_buffer_t *buffer); |
Behdad Esfahbod | 71b65eb | 2018-10-07 18:41:52 +0200 | [diff] [blame] | 358 | |
Behdad Esfahbod | 976c8f4 | 2014-07-16 15:34:20 -0400 | [diff] [blame] | 359 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 360 | HB_EXTERN void |
Behdad Esfahbod | c910bec | 2011-04-13 15:49:06 -0400 | [diff] [blame] | 361 | hb_buffer_reset (hb_buffer_t *buffer); |
| 362 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 363 | HB_EXTERN void |
Behdad Esfahbod | 1172dc7 | 2013-01-07 16:46:37 -0600 | [diff] [blame] | 364 | hb_buffer_clear_contents (hb_buffer_t *buffer); |
Behdad Esfahbod | 82ecaff | 2012-11-13 13:57:52 -0800 | [diff] [blame] | 365 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 366 | HB_EXTERN hb_bool_t |
Ryan Lortie | 02a534b | 2011-04-15 18:34:45 -0400 | [diff] [blame] | 367 | hb_buffer_pre_allocate (hb_buffer_t *buffer, |
| 368 | unsigned int size); |
Behdad Esfahbod | f9cd101 | 2009-07-28 15:43:34 -0400 | [diff] [blame] | 369 | |
Behdad Esfahbod | aab0de5 | 2011-04-19 00:32:19 -0400 | [diff] [blame] | 370 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 371 | HB_EXTERN hb_bool_t |
Behdad Esfahbod | aab0de5 | 2011-04-19 00:32:19 -0400 | [diff] [blame] | 372 | hb_buffer_allocation_successful (hb_buffer_t *buffer); |
| 373 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 374 | HB_EXTERN void |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 375 | hb_buffer_reverse (hb_buffer_t *buffer); |
| 376 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 377 | HB_EXTERN void |
Behdad Esfahbod | 81bedda | 2015-04-30 13:04:16 -0400 | [diff] [blame] | 378 | hb_buffer_reverse_range (hb_buffer_t *buffer, |
| 379 | unsigned int start, unsigned int end); |
| 380 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 381 | HB_EXTERN void |
Behdad Esfahbod | ff44f88 | 2009-11-06 19:48:16 -0500 | [diff] [blame] | 382 | hb_buffer_reverse_clusters (hb_buffer_t *buffer); |
| 383 | |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 384 | |
| 385 | /* Filling the buffer in */ |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 386 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 387 | HB_EXTERN void |
Behdad Esfahbod | f85faee | 2011-04-19 00:38:01 -0400 | [diff] [blame] | 388 | hb_buffer_add (hb_buffer_t *buffer, |
| 389 | hb_codepoint_t codepoint, |
Behdad Esfahbod | f85faee | 2011-04-19 00:38:01 -0400 | [diff] [blame] | 390 | unsigned int cluster); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 391 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 392 | HB_EXTERN void |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 393 | hb_buffer_add_utf8 (hb_buffer_t *buffer, |
| 394 | const char *text, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 395 | int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 396 | unsigned int item_offset, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 397 | int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 398 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 399 | HB_EXTERN void |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 400 | hb_buffer_add_utf16 (hb_buffer_t *buffer, |
| 401 | const uint16_t *text, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 402 | int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 403 | unsigned int item_offset, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 404 | int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 405 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 406 | HB_EXTERN void |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 407 | hb_buffer_add_utf32 (hb_buffer_t *buffer, |
| 408 | const uint32_t *text, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 409 | int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 410 | unsigned int item_offset, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 411 | int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 412 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 413 | HB_EXTERN void |
Behdad Esfahbod | 61820bc | 2015-01-26 14:25:52 -0800 | [diff] [blame] | 414 | hb_buffer_add_latin1 (hb_buffer_t *buffer, |
| 415 | const uint8_t *text, |
| 416 | int text_length, |
| 417 | unsigned int item_offset, |
| 418 | int item_length); |
| 419 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 420 | HB_EXTERN void |
Behdad Esfahbod | bcba8b4 | 2014-07-16 14:59:04 -0400 | [diff] [blame] | 421 | hb_buffer_add_codepoints (hb_buffer_t *buffer, |
| 422 | const hb_codepoint_t *text, |
| 423 | int text_length, |
| 424 | unsigned int item_offset, |
| 425 | int item_length); |
| 426 | |
Behdad Esfahbod | 39a9749 | 2017-08-11 15:52:06 -0700 | [diff] [blame] | 427 | HB_EXTERN void |
| 428 | hb_buffer_append (hb_buffer_t *buffer, |
| 429 | hb_buffer_t *source, |
| 430 | unsigned int start, |
| 431 | unsigned int end); |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 432 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 433 | HB_EXTERN hb_bool_t |
Behdad Esfahbod | c910bec | 2011-04-13 15:49:06 -0400 | [diff] [blame] | 434 | hb_buffer_set_length (hb_buffer_t *buffer, |
| 435 | unsigned int length); |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 436 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 437 | HB_EXTERN unsigned int |
Behdad Esfahbod | 3d14528 | 2009-11-06 15:13:17 -0500 | [diff] [blame] | 438 | hb_buffer_get_length (hb_buffer_t *buffer); |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 439 | |
Behdad Esfahbod | c910bec | 2011-04-13 15:49:06 -0400 | [diff] [blame] | 440 | /* Getting glyphs out of the buffer */ |
| 441 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 442 | HB_EXTERN hb_glyph_info_t * |
Ryan Lortie | 70566be | 2011-04-15 18:32:36 -0400 | [diff] [blame] | 443 | hb_buffer_get_glyph_infos (hb_buffer_t *buffer, |
Ebrahim Byagowi | a0b4ac4 | 2019-08-24 17:57:14 +0430 | [diff] [blame] | 444 | unsigned int *length); |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 445 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 446 | HB_EXTERN hb_glyph_position_t * |
Ryan Lortie | 70566be | 2011-04-15 18:32:36 -0400 | [diff] [blame] | 447 | hb_buffer_get_glyph_positions (hb_buffer_t *buffer, |
Ebrahim Byagowi | a0b4ac4 | 2019-08-24 17:57:14 +0430 | [diff] [blame] | 448 | unsigned int *length); |
Behdad Esfahbod | 02a3706 | 2009-07-29 18:41:25 -0400 | [diff] [blame] | 449 | |
| 450 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 451 | HB_EXTERN void |
Behdad Esfahbod | 39b1783 | 2012-07-17 17:09:29 -0400 | [diff] [blame] | 452 | hb_buffer_normalize_glyphs (hb_buffer_t *buffer); |
| 453 | |
Behdad Esfahbod | 39b1783 | 2012-07-17 17:09:29 -0400 | [diff] [blame] | 454 | |
Behdad Esfahbod | c54599a | 2012-11-15 16:14:23 -0800 | [diff] [blame] | 455 | /* |
| 456 | * Serialize |
| 457 | */ |
Behdad Esfahbod | 39b1783 | 2012-07-17 17:09:29 -0400 | [diff] [blame] | 458 | |
Khaled Hosny | 9ab9f97 | 2016-01-01 20:38:21 +0400 | [diff] [blame] | 459 | /** |
| 460 | * hb_buffer_serialize_flags_t: |
| 461 | * @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions. |
| 462 | * @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster. |
| 463 | * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information. |
| 464 | * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name. |
| 465 | * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents. |
Behdad Esfahbod | 71fd632 | 2018-01-10 02:20:14 +0100 | [diff] [blame] | 466 | * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0 |
Khaled Hosny | 0b22da9 | 2018-01-10 07:12:07 +0200 | [diff] [blame] | 467 | * @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances, |
| 468 | * glyph offsets will reflect absolute glyph positions. Since: 1.8.0 |
Khaled Hosny | 9ab9f97 | 2016-01-01 20:38:21 +0400 | [diff] [blame] | 469 | * |
| 470 | * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs(). |
| 471 | * |
Behdad Esfahbod | b881142 | 2015-09-03 15:53:22 +0430 | [diff] [blame] | 472 | * Since: 0.9.20 |
| 473 | */ |
Behdad Esfahbod | 4dc798d | 2013-08-26 20:39:00 -0400 | [diff] [blame] | 474 | typedef enum { /*< flags >*/ |
Behdad Esfahbod | 11fb16c | 2013-10-17 20:57:57 +0200 | [diff] [blame] | 475 | HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u, |
| 476 | HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u, |
| 477 | HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u, |
Behdad Esfahbod | fdd1770 | 2015-08-24 13:49:55 +0100 | [diff] [blame] | 478 | HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u, |
Behdad Esfahbod | 40bd7e9 | 2016-05-02 14:47:45 +0200 | [diff] [blame] | 479 | HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u, |
Behdad Esfahbod | 71fd632 | 2018-01-10 02:20:14 +0100 | [diff] [blame] | 480 | HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u, |
| 481 | HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 482 | } hb_buffer_serialize_flags_t; |
| 483 | |
Khaled Hosny | 9ab9f97 | 2016-01-01 20:38:21 +0400 | [diff] [blame] | 484 | /** |
| 485 | * hb_buffer_serialize_format_t: |
| 486 | * @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format. |
| 487 | * @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format. |
Behdad Esfahbod | 97624d9 | 2016-01-11 12:58:45 +0000 | [diff] [blame] | 488 | * @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format. |
Khaled Hosny | 9ab9f97 | 2016-01-01 20:38:21 +0400 | [diff] [blame] | 489 | * |
| 490 | * The buffer serialization and de-serialization format used in |
| 491 | * hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs(). |
| 492 | * |
| 493 | * Since: 0.9.2 |
| 494 | */ |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 495 | typedef enum { |
| 496 | HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), |
| 497 | HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), |
| 498 | HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE |
| 499 | } hb_buffer_serialize_format_t; |
| 500 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 501 | HB_EXTERN hb_buffer_serialize_format_t |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 502 | hb_buffer_serialize_format_from_string (const char *str, int len); |
| 503 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 504 | HB_EXTERN const char * |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 505 | hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); |
| 506 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 507 | HB_EXTERN const char ** |
Behdad Esfahbod | 072ae7a | 2012-11-15 13:14:12 -0800 | [diff] [blame] | 508 | hb_buffer_serialize_list_formats (void); |
| 509 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 510 | HB_EXTERN unsigned int |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 511 | hb_buffer_serialize_glyphs (hb_buffer_t *buffer, |
| 512 | unsigned int start, |
| 513 | unsigned int end, |
| 514 | char *buf, |
| 515 | unsigned int buf_size, |
Khaled Hosny | 9ab9f97 | 2016-01-01 20:38:21 +0400 | [diff] [blame] | 516 | unsigned int *buf_consumed, |
| 517 | hb_font_t *font, |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 518 | hb_buffer_serialize_format_t format, |
| 519 | hb_buffer_serialize_flags_t flags); |
| 520 | |
Chun-wei Fan | 835bbdc | 2015-11-19 18:34:12 +0800 | [diff] [blame] | 521 | HB_EXTERN hb_bool_t |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 522 | hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, |
| 523 | const char *buf, |
Khaled Hosny | 9ab9f97 | 2016-01-01 20:38:21 +0400 | [diff] [blame] | 524 | int buf_len, |
| 525 | const char **end_ptr, |
| 526 | hb_font_t *font, |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 527 | hb_buffer_serialize_format_t format); |
| 528 | |
| 529 | |
Behdad Esfahbod | 0475ef2 | 2015-12-18 18:17:07 +0000 | [diff] [blame] | 530 | /* |
Jonathan Kew | 331d66c | 2014-07-19 23:09:09 +0100 | [diff] [blame] | 531 | * Compare buffers |
| 532 | */ |
| 533 | |
| 534 | typedef enum { /*< flags >*/ |
| 535 | HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000, |
| 536 | |
| 537 | /* Buffers with different content_type cannot be meaningfully compared |
| 538 | * in any further detail. */ |
Behdad Esfahbod | d03f11f | 2017-09-04 20:14:13 -0700 | [diff] [blame] | 539 | HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001, |
Jonathan Kew | 331d66c | 2014-07-19 23:09:09 +0100 | [diff] [blame] | 540 | |
| 541 | /* For buffers with differing length, the per-glyph comparison is not |
| 542 | * attempted, though we do still scan reference for dottedcircle / .notdef |
| 543 | * glyphs. */ |
Behdad Esfahbod | d03f11f | 2017-09-04 20:14:13 -0700 | [diff] [blame] | 544 | HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002, |
Jonathan Kew | 331d66c | 2014-07-19 23:09:09 +0100 | [diff] [blame] | 545 | |
| 546 | /* We want to know if dottedcircle / .notdef glyphs are present in the |
| 547 | * reference, as we may not care so much about other differences in this |
| 548 | * case. */ |
| 549 | HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004, |
| 550 | HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008, |
| 551 | |
| 552 | /* If the buffers have the same length, we compare them glyph-by-glyph |
| 553 | * and report which aspect(s) of the glyph info/position are different. */ |
| 554 | HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010, |
Behdad Esfahbod | 338e61a | 2017-08-14 12:36:38 -0700 | [diff] [blame] | 555 | HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020, |
Behdad Esfahbod | 3e8f4f1 | 2017-08-22 17:56:25 -0700 | [diff] [blame] | 556 | HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040, |
Jonathan Kew | 331d66c | 2014-07-19 23:09:09 +0100 | [diff] [blame] | 557 | HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080 |
| 558 | |
| 559 | } hb_buffer_diff_flags_t; |
| 560 | |
| 561 | /* Compare the contents of two buffers, report types of differences. */ |
fanc999 | 48a9406 | 2017-10-07 18:57:14 +0800 | [diff] [blame] | 562 | HB_EXTERN hb_buffer_diff_flags_t |
Jonathan Kew | 331d66c | 2014-07-19 23:09:09 +0100 | [diff] [blame] | 563 | hb_buffer_diff (hb_buffer_t *buffer, |
| 564 | hb_buffer_t *reference, |
| 565 | hb_codepoint_t dottedcircle_glyph, |
| 566 | unsigned int position_fuzz); |
| 567 | |
| 568 | |
| 569 | /* |
Behdad Esfahbod | 0475ef2 | 2015-12-18 18:17:07 +0000 | [diff] [blame] | 570 | * Debugging. |
| 571 | */ |
| 572 | |
| 573 | typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer, |
| 574 | hb_font_t *font, |
| 575 | const char *message, |
| 576 | void *user_data); |
| 577 | |
| 578 | HB_EXTERN void |
| 579 | hb_buffer_set_message_func (hb_buffer_t *buffer, |
| 580 | hb_buffer_message_func_t func, |
| 581 | void *user_data, hb_destroy_func_t destroy); |
| 582 | |
| 583 | |
Behdad Esfahbod | f96ffd4 | 2009-05-24 15:01:16 -0400 | [diff] [blame] | 584 | HB_END_DECLS |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 585 | |
Behdad Esfahbod | 5c0adce | 2009-05-20 05:42:12 -0400 | [diff] [blame] | 586 | #endif /* HB_BUFFER_H */ |