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 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 43 | |
Behdad Esfahbod | 1bc1cb3 | 2012-06-16 15:21:55 -0400 | [diff] [blame] | 44 | typedef struct hb_glyph_info_t { |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 45 | hb_codepoint_t codepoint; |
Behdad Esfahbod | 468769b | 2009-08-08 16:53:23 -0400 | [diff] [blame] | 46 | hb_mask_t mask; |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 47 | uint32_t cluster; |
Behdad Esfahbod | b54cd07 | 2011-04-15 19:12:01 -0400 | [diff] [blame] | 48 | |
| 49 | /*< private >*/ |
Behdad Esfahbod | 6cb8c34 | 2010-10-27 14:27:03 -0400 | [diff] [blame] | 50 | hb_var_int_t var1; |
| 51 | hb_var_int_t var2; |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 52 | } hb_glyph_info_t; |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 53 | |
Behdad Esfahbod | 1bc1cb3 | 2012-06-16 15:21:55 -0400 | [diff] [blame] | 54 | typedef struct hb_glyph_position_t { |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 55 | hb_position_t x_advance; |
| 56 | hb_position_t y_advance; |
Behdad Esfahbod | 9bef361 | 2009-11-05 12:20:11 -0500 | [diff] [blame] | 57 | hb_position_t x_offset; |
| 58 | hb_position_t y_offset; |
Behdad Esfahbod | b54cd07 | 2011-04-15 19:12:01 -0400 | [diff] [blame] | 59 | |
| 60 | /*< private >*/ |
Behdad Esfahbod | 88474c6 | 2010-10-27 14:42:15 -0400 | [diff] [blame] | 61 | hb_var_int_t var; |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 62 | } hb_glyph_position_t; |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 63 | |
| 64 | |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 65 | typedef struct hb_segment_properties_t { |
| 66 | hb_direction_t direction; |
| 67 | hb_script_t script; |
| 68 | hb_language_t language; |
| 69 | /*< private >*/ |
| 70 | void *reserved1; |
| 71 | void *reserved2; |
| 72 | } hb_segment_properties_t; |
| 73 | |
| 74 | #define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \ |
| 75 | HB_SCRIPT_INVALID, \ |
| 76 | HB_LANGUAGE_INVALID, \ |
| 77 | NULL, \ |
| 78 | NULL} |
| 79 | |
| 80 | hb_bool_t |
| 81 | hb_segment_properties_equal (const hb_segment_properties_t *a, |
| 82 | const hb_segment_properties_t *b); |
| 83 | |
| 84 | unsigned int |
| 85 | hb_segment_properties_hash (const hb_segment_properties_t *p); |
| 86 | |
| 87 | |
| 88 | |
| 89 | /* |
| 90 | * hb_buffer_t |
| 91 | */ |
| 92 | |
| 93 | typedef struct hb_buffer_t hb_buffer_t; |
| 94 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 95 | hb_buffer_t * |
Behdad Esfahbod | e6c09cd | 2011-08-17 19:07:59 +0200 | [diff] [blame] | 96 | hb_buffer_create (void); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 97 | |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 98 | hb_buffer_t * |
Behdad Esfahbod | 80a6833 | 2011-05-11 18:14:44 -0400 | [diff] [blame] | 99 | hb_buffer_get_empty (void); |
| 100 | |
| 101 | hb_buffer_t * |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 102 | hb_buffer_reference (hb_buffer_t *buffer); |
| 103 | |
Behdad Esfahbod | a8abb8b | 2007-10-11 00:07:58 +0000 | [diff] [blame] | 104 | void |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 105 | hb_buffer_destroy (hb_buffer_t *buffer); |
| 106 | |
Behdad Esfahbod | 5fa849b | 2011-04-27 21:46:01 -0400 | [diff] [blame] | 107 | hb_bool_t |
| 108 | hb_buffer_set_user_data (hb_buffer_t *buffer, |
| 109 | hb_user_data_key_t *key, |
| 110 | void * data, |
Behdad Esfahbod | 33ccc77 | 2011-08-09 00:43:24 +0200 | [diff] [blame] | 111 | hb_destroy_func_t destroy, |
| 112 | hb_bool_t replace); |
Behdad Esfahbod | 5fa849b | 2011-04-27 21:46:01 -0400 | [diff] [blame] | 113 | |
| 114 | void * |
| 115 | hb_buffer_get_user_data (hb_buffer_t *buffer, |
| 116 | hb_user_data_key_t *key); |
| 117 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 118 | |
Behdad Esfahbod | 92f9bfe | 2012-11-13 16:50:45 -0800 | [diff] [blame] | 119 | typedef enum { |
| 120 | HB_BUFFER_CONTENT_TYPE_INVALID = 0, |
| 121 | HB_BUFFER_CONTENT_TYPE_UNICODE, |
| 122 | HB_BUFFER_CONTENT_TYPE_GLYPHS |
| 123 | } hb_buffer_content_type_t; |
| 124 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 125 | void |
Behdad Esfahbod | 96fdc04 | 2012-09-06 22:26:16 -0400 | [diff] [blame] | 126 | hb_buffer_set_content_type (hb_buffer_t *buffer, |
| 127 | hb_buffer_content_type_t content_type); |
| 128 | |
| 129 | hb_buffer_content_type_t |
| 130 | hb_buffer_get_content_type (hb_buffer_t *buffer); |
| 131 | |
| 132 | |
| 133 | void |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 134 | hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, |
| 135 | hb_unicode_funcs_t *unicode_funcs); |
| 136 | |
| 137 | hb_unicode_funcs_t * |
| 138 | hb_buffer_get_unicode_funcs (hb_buffer_t *buffer); |
| 139 | |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 140 | void |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 141 | hb_buffer_set_direction (hb_buffer_t *buffer, |
| 142 | hb_direction_t direction); |
| 143 | |
| 144 | hb_direction_t |
| 145 | hb_buffer_get_direction (hb_buffer_t *buffer); |
| 146 | |
Behdad Esfahbod | ae070b7 | 2009-11-04 20:29:54 -0500 | [diff] [blame] | 147 | void |
| 148 | hb_buffer_set_script (hb_buffer_t *buffer, |
| 149 | hb_script_t script); |
| 150 | |
| 151 | hb_script_t |
| 152 | hb_buffer_get_script (hb_buffer_t *buffer); |
| 153 | |
| 154 | void |
| 155 | hb_buffer_set_language (hb_buffer_t *buffer, |
| 156 | hb_language_t language); |
| 157 | |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 158 | |
Behdad Esfahbod | ae070b7 | 2009-11-04 20:29:54 -0500 | [diff] [blame] | 159 | hb_language_t |
| 160 | hb_buffer_get_language (hb_buffer_t *buffer); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 161 | |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 162 | void |
| 163 | hb_buffer_set_segment_properties (hb_buffer_t *buffer, |
| 164 | const hb_segment_properties_t *props); |
| 165 | |
| 166 | void |
| 167 | hb_buffer_get_segment_properties (hb_buffer_t *buffer, |
| 168 | hb_segment_properties_t *props); |
| 169 | |
| 170 | void |
Behdad Esfahbod | 3f82f8f | 2012-11-15 18:45:31 -0800 | [diff] [blame] | 171 | hb_buffer_guess_segment_properties (hb_buffer_t *buffer); |
Behdad Esfahbod | f306410 | 2012-11-15 18:39:46 -0800 | [diff] [blame] | 172 | |
Behdad Esfahbod | 92f9bfe | 2012-11-13 16:50:45 -0800 | [diff] [blame] | 173 | |
| 174 | typedef enum { |
| 175 | HB_BUFFER_FLAGS_DEFAULT = 0x00000000, |
| 176 | HB_BUFFER_FLAG_BOT = 0x00000001, /* Beginning-of-text */ |
| 177 | HB_BUFFER_FLAG_EOT = 0x00000002, /* End-of-text */ |
| 178 | HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004 |
| 179 | } hb_buffer_flags_t; |
| 180 | |
Behdad Esfahbod | 0c7df22 | 2012-11-13 14:42:35 -0800 | [diff] [blame] | 181 | void |
| 182 | hb_buffer_set_flags (hb_buffer_t *buffer, |
| 183 | hb_buffer_flags_t flags); |
| 184 | |
| 185 | hb_buffer_flags_t |
| 186 | hb_buffer_get_flags (hb_buffer_t *buffer); |
| 187 | |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 188 | |
Behdad Esfahbod | c910bec | 2011-04-13 15:49:06 -0400 | [diff] [blame] | 189 | /* Resets the buffer. Afterwards it's as if it was just created, |
| 190 | * except that it has a larger buffer allocated perhaps... */ |
| 191 | void |
| 192 | hb_buffer_reset (hb_buffer_t *buffer); |
| 193 | |
Behdad Esfahbod | 82ecaff | 2012-11-13 13:57:52 -0800 | [diff] [blame] | 194 | /* Like reset, but does NOT clear unicode_funcs. */ |
| 195 | void |
Behdad Esfahbod | 1172dc7 | 2013-01-07 16:46:37 -0600 | [diff] [blame] | 196 | hb_buffer_clear_contents (hb_buffer_t *buffer); |
Behdad Esfahbod | 82ecaff | 2012-11-13 13:57:52 -0800 | [diff] [blame] | 197 | |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 198 | /* Returns false if allocation failed */ |
Behdad Esfahbod | a6a79df | 2010-05-14 23:20:16 -0400 | [diff] [blame] | 199 | hb_bool_t |
Ryan Lortie | 02a534b | 2011-04-15 18:34:45 -0400 | [diff] [blame] | 200 | hb_buffer_pre_allocate (hb_buffer_t *buffer, |
| 201 | unsigned int size); |
Behdad Esfahbod | f9cd101 | 2009-07-28 15:43:34 -0400 | [diff] [blame] | 202 | |
Behdad Esfahbod | aab0de5 | 2011-04-19 00:32:19 -0400 | [diff] [blame] | 203 | |
Behdad Esfahbod | 0594a24 | 2012-06-05 20:35:40 -0400 | [diff] [blame] | 204 | /* Returns false if allocation has failed before */ |
Behdad Esfahbod | aab0de5 | 2011-04-19 00:32:19 -0400 | [diff] [blame] | 205 | hb_bool_t |
| 206 | hb_buffer_allocation_successful (hb_buffer_t *buffer); |
| 207 | |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 208 | void |
| 209 | hb_buffer_reverse (hb_buffer_t *buffer); |
| 210 | |
Behdad Esfahbod | ff44f88 | 2009-11-06 19:48:16 -0500 | [diff] [blame] | 211 | void |
| 212 | hb_buffer_reverse_clusters (hb_buffer_t *buffer); |
| 213 | |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 214 | |
| 215 | /* Filling the buffer in */ |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 216 | |
Behdad Esfahbod | f9cd101 | 2009-07-28 15:43:34 -0400 | [diff] [blame] | 217 | void |
Behdad Esfahbod | f85faee | 2011-04-19 00:38:01 -0400 | [diff] [blame] | 218 | hb_buffer_add (hb_buffer_t *buffer, |
| 219 | hb_codepoint_t codepoint, |
Behdad Esfahbod | f85faee | 2011-04-19 00:38:01 -0400 | [diff] [blame] | 220 | unsigned int cluster); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 221 | |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 222 | void |
| 223 | hb_buffer_add_utf8 (hb_buffer_t *buffer, |
| 224 | const char *text, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 225 | int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 226 | unsigned int item_offset, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 227 | int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 228 | |
| 229 | void |
| 230 | hb_buffer_add_utf16 (hb_buffer_t *buffer, |
| 231 | const uint16_t *text, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 232 | int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 233 | unsigned int item_offset, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 234 | int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 235 | |
| 236 | void |
| 237 | hb_buffer_add_utf32 (hb_buffer_t *buffer, |
| 238 | const uint32_t *text, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 239 | int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 240 | unsigned int item_offset, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 241 | int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 242 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 243 | |
Behdad Esfahbod | c910bec | 2011-04-13 15:49:06 -0400 | [diff] [blame] | 244 | /* Clears any new items added at the end */ |
| 245 | hb_bool_t |
| 246 | hb_buffer_set_length (hb_buffer_t *buffer, |
| 247 | unsigned int length); |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 248 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 249 | /* Return value valid as long as buffer not modified */ |
| 250 | unsigned int |
Behdad Esfahbod | 3d14528 | 2009-11-06 15:13:17 -0500 | [diff] [blame] | 251 | hb_buffer_get_length (hb_buffer_t *buffer); |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 252 | |
Behdad Esfahbod | c910bec | 2011-04-13 15:49:06 -0400 | [diff] [blame] | 253 | /* Getting glyphs out of the buffer */ |
| 254 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 255 | /* Return value valid as long as buffer not modified */ |
| 256 | hb_glyph_info_t * |
Ryan Lortie | 70566be | 2011-04-15 18:32:36 -0400 | [diff] [blame] | 257 | hb_buffer_get_glyph_infos (hb_buffer_t *buffer, |
| 258 | unsigned int *length); |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 259 | |
| 260 | /* Return value valid as long as buffer not modified */ |
| 261 | hb_glyph_position_t * |
Ryan Lortie | 70566be | 2011-04-15 18:32:36 -0400 | [diff] [blame] | 262 | hb_buffer_get_glyph_positions (hb_buffer_t *buffer, |
| 263 | unsigned int *length); |
Behdad Esfahbod | 02a3706 | 2009-07-29 18:41:25 -0400 | [diff] [blame] | 264 | |
| 265 | |
Behdad Esfahbod | 39b1783 | 2012-07-17 17:09:29 -0400 | [diff] [blame] | 266 | /* Reorders a glyph buffer to have canonical in-cluster glyph order / position. |
| 267 | * The resulting clusters should behave identical to pre-reordering clusters. |
| 268 | * NOTE: This has nothing to do with Unicode normalization. */ |
| 269 | void |
| 270 | hb_buffer_normalize_glyphs (hb_buffer_t *buffer); |
| 271 | |
Behdad Esfahbod | 39b1783 | 2012-07-17 17:09:29 -0400 | [diff] [blame] | 272 | |
Behdad Esfahbod | c54599a | 2012-11-15 16:14:23 -0800 | [diff] [blame] | 273 | /* |
| 274 | * Serialize |
| 275 | */ |
Behdad Esfahbod | 39b1783 | 2012-07-17 17:09:29 -0400 | [diff] [blame] | 276 | |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 277 | typedef enum { |
| 278 | HB_BUFFER_SERIALIZE_FLAGS_DEFAULT = 0x00000000, |
| 279 | HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001, |
| 280 | HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002, |
| 281 | HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004 |
| 282 | } hb_buffer_serialize_flags_t; |
| 283 | |
| 284 | typedef enum { |
| 285 | HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), |
| 286 | HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), |
| 287 | HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE |
| 288 | } hb_buffer_serialize_format_t; |
| 289 | |
| 290 | /* len=-1 means str is NUL-terminated. */ |
| 291 | hb_buffer_serialize_format_t |
| 292 | hb_buffer_serialize_format_from_string (const char *str, int len); |
| 293 | |
| 294 | const char * |
| 295 | hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); |
| 296 | |
Behdad Esfahbod | 072ae7a | 2012-11-15 13:14:12 -0800 | [diff] [blame] | 297 | const char ** |
| 298 | hb_buffer_serialize_list_formats (void); |
| 299 | |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 300 | /* Returns number of items, starting at start, that were serialized. */ |
| 301 | unsigned int |
| 302 | hb_buffer_serialize_glyphs (hb_buffer_t *buffer, |
| 303 | unsigned int start, |
| 304 | unsigned int end, |
| 305 | char *buf, |
| 306 | unsigned int buf_size, |
Behdad Esfahbod | bcc8f32 | 2013-02-27 12:02:42 -0500 | [diff] [blame] | 307 | unsigned int *buf_consumed, /* May be NULL */ |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 308 | hb_font_t *font, /* May be NULL */ |
| 309 | hb_buffer_serialize_format_t format, |
| 310 | hb_buffer_serialize_flags_t flags); |
| 311 | |
| 312 | hb_bool_t |
| 313 | hb_buffer_deserialize_glyphs (hb_buffer_t *buffer, |
| 314 | const char *buf, |
Behdad Esfahbod | e54dd26 | 2013-02-27 13:01:02 -0500 | [diff] [blame] | 315 | int buf_len, /* -1 means nul-terminated */ |
Behdad Esfahbod | 847794e | 2013-02-27 17:59:28 -0500 | [diff] [blame] | 316 | const char **end_ptr, /* May be NULL */ |
Behdad Esfahbod | f9edf16 | 2012-11-15 12:14:09 -0800 | [diff] [blame] | 317 | hb_font_t *font, /* May be NULL */ |
| 318 | hb_buffer_serialize_format_t format); |
| 319 | |
| 320 | |
Behdad Esfahbod | f96ffd4 | 2009-05-24 15:01:16 -0400 | [diff] [blame] | 321 | HB_END_DECLS |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 322 | |
Behdad Esfahbod | 5c0adce | 2009-05-20 05:42:12 -0400 | [diff] [blame] | 323 | #endif /* HB_BUFFER_H */ |