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. |
| 4 | * Copyright © 2011 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 | 5c0adce | 2009-05-20 05:42:12 -0400 | [diff] [blame] | 30 | #ifndef HB_BUFFER_H |
| 31 | #define HB_BUFFER_H |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 32 | |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 33 | #include "hb-common.h" |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 34 | #include "hb-unicode.h" |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 35 | |
Behdad Esfahbod | f96ffd4 | 2009-05-24 15:01:16 -0400 | [diff] [blame] | 36 | HB_BEGIN_DECLS |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 37 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 38 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 39 | typedef struct _hb_buffer_t hb_buffer_t; |
| 40 | |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 41 | typedef struct _hb_glyph_info_t { |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 42 | hb_codepoint_t codepoint; |
Behdad Esfahbod | 468769b | 2009-08-08 16:53:23 -0400 | [diff] [blame] | 43 | hb_mask_t mask; |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 44 | uint32_t cluster; |
Behdad Esfahbod | b54cd07 | 2011-04-15 19:12:01 -0400 | [diff] [blame] | 45 | |
| 46 | /*< private >*/ |
Behdad Esfahbod | 6cb8c34 | 2010-10-27 14:27:03 -0400 | [diff] [blame] | 47 | hb_var_int_t var1; |
| 48 | hb_var_int_t var2; |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 49 | } hb_glyph_info_t; |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 50 | |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 51 | typedef struct _hb_glyph_position_t { |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 52 | hb_position_t x_advance; |
| 53 | hb_position_t y_advance; |
Behdad Esfahbod | 9bef361 | 2009-11-05 12:20:11 -0500 | [diff] [blame] | 54 | hb_position_t x_offset; |
| 55 | hb_position_t y_offset; |
Behdad Esfahbod | b54cd07 | 2011-04-15 19:12:01 -0400 | [diff] [blame] | 56 | |
| 57 | /*< private >*/ |
Behdad Esfahbod | 88474c6 | 2010-10-27 14:42:15 -0400 | [diff] [blame] | 58 | hb_var_int_t var; |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 59 | } hb_glyph_position_t; |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 60 | |
| 61 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 62 | hb_buffer_t * |
| 63 | hb_buffer_create (unsigned int pre_alloc_size); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 64 | |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 65 | hb_buffer_t * |
Behdad Esfahbod | 80a6833 | 2011-05-11 18:14:44 -0400 | [diff] [blame] | 66 | hb_buffer_get_empty (void); |
| 67 | |
| 68 | hb_buffer_t * |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 69 | hb_buffer_reference (hb_buffer_t *buffer); |
| 70 | |
Behdad Esfahbod | a8abb8b | 2007-10-11 00:07:58 +0000 | [diff] [blame] | 71 | void |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 72 | hb_buffer_destroy (hb_buffer_t *buffer); |
| 73 | |
Behdad Esfahbod | 5fa849b | 2011-04-27 21:46:01 -0400 | [diff] [blame] | 74 | hb_bool_t |
| 75 | hb_buffer_set_user_data (hb_buffer_t *buffer, |
| 76 | hb_user_data_key_t *key, |
| 77 | void * data, |
Behdad Esfahbod | 33ccc77 | 2011-08-09 00:43:24 +0200 | [diff] [blame^] | 78 | hb_destroy_func_t destroy, |
| 79 | hb_bool_t replace); |
Behdad Esfahbod | 5fa849b | 2011-04-27 21:46:01 -0400 | [diff] [blame] | 80 | |
| 81 | void * |
| 82 | hb_buffer_get_user_data (hb_buffer_t *buffer, |
| 83 | hb_user_data_key_t *key); |
| 84 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 85 | |
| 86 | void |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 87 | hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, |
| 88 | hb_unicode_funcs_t *unicode_funcs); |
| 89 | |
| 90 | hb_unicode_funcs_t * |
| 91 | hb_buffer_get_unicode_funcs (hb_buffer_t *buffer); |
| 92 | |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 93 | void |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 94 | hb_buffer_set_direction (hb_buffer_t *buffer, |
| 95 | hb_direction_t direction); |
| 96 | |
| 97 | hb_direction_t |
| 98 | hb_buffer_get_direction (hb_buffer_t *buffer); |
| 99 | |
Behdad Esfahbod | ae070b7 | 2009-11-04 20:29:54 -0500 | [diff] [blame] | 100 | void |
| 101 | hb_buffer_set_script (hb_buffer_t *buffer, |
| 102 | hb_script_t script); |
| 103 | |
| 104 | hb_script_t |
| 105 | hb_buffer_get_script (hb_buffer_t *buffer); |
| 106 | |
| 107 | void |
| 108 | hb_buffer_set_language (hb_buffer_t *buffer, |
| 109 | hb_language_t language); |
| 110 | |
| 111 | hb_language_t |
| 112 | hb_buffer_get_language (hb_buffer_t *buffer); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 113 | |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 114 | |
Behdad Esfahbod | c910bec | 2011-04-13 15:49:06 -0400 | [diff] [blame] | 115 | /* Resets the buffer. Afterwards it's as if it was just created, |
| 116 | * except that it has a larger buffer allocated perhaps... */ |
| 117 | void |
| 118 | hb_buffer_reset (hb_buffer_t *buffer); |
| 119 | |
Behdad Esfahbod | aab0de5 | 2011-04-19 00:32:19 -0400 | [diff] [blame] | 120 | /* Returns FALSE if allocation failed */ |
Behdad Esfahbod | a6a79df | 2010-05-14 23:20:16 -0400 | [diff] [blame] | 121 | hb_bool_t |
Ryan Lortie | 02a534b | 2011-04-15 18:34:45 -0400 | [diff] [blame] | 122 | hb_buffer_pre_allocate (hb_buffer_t *buffer, |
| 123 | unsigned int size); |
Behdad Esfahbod | f9cd101 | 2009-07-28 15:43:34 -0400 | [diff] [blame] | 124 | |
Behdad Esfahbod | aab0de5 | 2011-04-19 00:32:19 -0400 | [diff] [blame] | 125 | |
| 126 | /* Returns FALSE if allocation has failed before */ |
| 127 | hb_bool_t |
| 128 | hb_buffer_allocation_successful (hb_buffer_t *buffer); |
| 129 | |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 130 | void |
| 131 | hb_buffer_reverse (hb_buffer_t *buffer); |
| 132 | |
Behdad Esfahbod | ff44f88 | 2009-11-06 19:48:16 -0500 | [diff] [blame] | 133 | void |
| 134 | hb_buffer_reverse_clusters (hb_buffer_t *buffer); |
| 135 | |
Behdad Esfahbod | 02aeca9 | 2011-08-04 22:31:05 -0400 | [diff] [blame] | 136 | void |
| 137 | hb_buffer_guess_properties (hb_buffer_t *buffer); |
| 138 | |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 139 | |
| 140 | /* Filling the buffer in */ |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 141 | |
Behdad Esfahbod | f9cd101 | 2009-07-28 15:43:34 -0400 | [diff] [blame] | 142 | void |
Behdad Esfahbod | f85faee | 2011-04-19 00:38:01 -0400 | [diff] [blame] | 143 | hb_buffer_add (hb_buffer_t *buffer, |
| 144 | hb_codepoint_t codepoint, |
| 145 | hb_mask_t mask, |
| 146 | unsigned int cluster); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 147 | |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 148 | void |
| 149 | hb_buffer_add_utf8 (hb_buffer_t *buffer, |
| 150 | const char *text, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 151 | int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 152 | unsigned int item_offset, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 153 | int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 154 | |
| 155 | void |
| 156 | hb_buffer_add_utf16 (hb_buffer_t *buffer, |
| 157 | const uint16_t *text, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 158 | int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 159 | unsigned int item_offset, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 160 | int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 161 | |
| 162 | void |
| 163 | hb_buffer_add_utf32 (hb_buffer_t *buffer, |
| 164 | const uint32_t *text, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 165 | int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 166 | unsigned int item_offset, |
Behdad Esfahbod | 944b2ba | 2011-08-09 00:23:58 +0200 | [diff] [blame] | 167 | int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 168 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 169 | |
Behdad Esfahbod | c910bec | 2011-04-13 15:49:06 -0400 | [diff] [blame] | 170 | /* Clears any new items added at the end */ |
| 171 | hb_bool_t |
| 172 | hb_buffer_set_length (hb_buffer_t *buffer, |
| 173 | unsigned int length); |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 174 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 175 | /* Return value valid as long as buffer not modified */ |
| 176 | unsigned int |
Behdad Esfahbod | 3d14528 | 2009-11-06 15:13:17 -0500 | [diff] [blame] | 177 | hb_buffer_get_length (hb_buffer_t *buffer); |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 178 | |
Behdad Esfahbod | c910bec | 2011-04-13 15:49:06 -0400 | [diff] [blame] | 179 | /* Getting glyphs out of the buffer */ |
| 180 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 181 | /* Return value valid as long as buffer not modified */ |
| 182 | hb_glyph_info_t * |
Ryan Lortie | 70566be | 2011-04-15 18:32:36 -0400 | [diff] [blame] | 183 | hb_buffer_get_glyph_infos (hb_buffer_t *buffer, |
| 184 | unsigned int *length); |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 185 | |
| 186 | /* Return value valid as long as buffer not modified */ |
| 187 | hb_glyph_position_t * |
Ryan Lortie | 70566be | 2011-04-15 18:32:36 -0400 | [diff] [blame] | 188 | hb_buffer_get_glyph_positions (hb_buffer_t *buffer, |
| 189 | unsigned int *length); |
Behdad Esfahbod | 02a3706 | 2009-07-29 18:41:25 -0400 | [diff] [blame] | 190 | |
| 191 | |
Behdad Esfahbod | f96ffd4 | 2009-05-24 15:01:16 -0400 | [diff] [blame] | 192 | HB_END_DECLS |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 193 | |
Behdad Esfahbod | 5c0adce | 2009-05-20 05:42:12 -0400 | [diff] [blame] | 194 | #endif /* HB_BUFFER_H */ |