Behdad Esfahbod | a2a9a02 | 2008-01-15 22:46:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 1998-2004 David Turner and Werner Lemberg |
Behdad Esfahbod | 6c78683 | 2009-05-25 03:22:19 -0400 | [diff] [blame] | 3 | * Copyright (C) 2004,2007,2009 Red Hat, Inc. |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 4 | * |
Behdad Esfahbod | c755cb3 | 2010-04-22 00:11:43 -0400 | [diff] [blame] | 5 | * This is part of HarfBuzz, a text shaping library. |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 6 | * |
Behdad Esfahbod | a2a9a02 | 2008-01-15 22:46:32 +0000 | [diff] [blame] | 7 | * Permission is hereby granted, without written agreement and without |
| 8 | * license or royalty fees, to use, copy, modify, and distribute this |
| 9 | * software and its documentation for any purpose, provided that the |
| 10 | * above copyright notice and the following two paragraphs appear in |
| 11 | * all copies of this software. |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 12 | * |
Behdad Esfahbod | a2a9a02 | 2008-01-15 22:46:32 +0000 | [diff] [blame] | 13 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| 14 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| 15 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
| 16 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 17 | * DAMAGE. |
| 18 | * |
| 19 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 20 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| 22 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| 23 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 24 | * |
| 25 | * Red Hat Author(s): Owen Taylor, Behdad Esfahbod |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 26 | */ |
Behdad Esfahbod | a2a9a02 | 2008-01-15 22:46:32 +0000 | [diff] [blame] | 27 | |
Behdad Esfahbod | 5c0adce | 2009-05-20 05:42:12 -0400 | [diff] [blame] | 28 | #ifndef HB_BUFFER_H |
| 29 | #define HB_BUFFER_H |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 30 | |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 31 | #include "hb-common.h" |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 32 | #include "hb-unicode.h" |
Behdad Esfahbod | ae070b7 | 2009-11-04 20:29:54 -0500 | [diff] [blame] | 33 | #include "hb-language.h" |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 34 | |
Behdad Esfahbod | f96ffd4 | 2009-05-24 15:01:16 -0400 | [diff] [blame] | 35 | HB_BEGIN_DECLS |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 36 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 37 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 38 | typedef struct _hb_buffer_t hb_buffer_t; |
| 39 | |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 40 | typedef struct _hb_glyph_info_t { |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 41 | hb_codepoint_t codepoint; |
Behdad Esfahbod | 468769b | 2009-08-08 16:53:23 -0400 | [diff] [blame] | 42 | hb_mask_t mask; |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 43 | uint32_t cluster; |
Behdad Esfahbod | 6cb8c34 | 2010-10-27 14:27:03 -0400 | [diff] [blame] | 44 | hb_var_int_t var1; |
| 45 | hb_var_int_t var2; |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 46 | } hb_glyph_info_t; |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 47 | |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 48 | typedef struct _hb_glyph_position_t { |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 49 | hb_position_t x_advance; |
| 50 | hb_position_t y_advance; |
Behdad Esfahbod | 9bef361 | 2009-11-05 12:20:11 -0500 | [diff] [blame] | 51 | hb_position_t x_offset; |
| 52 | hb_position_t y_offset; |
Behdad Esfahbod | 88474c6 | 2010-10-27 14:42:15 -0400 | [diff] [blame] | 53 | hb_var_int_t var; |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 54 | } hb_glyph_position_t; |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 55 | |
| 56 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 57 | hb_buffer_t * |
| 58 | hb_buffer_create (unsigned int pre_alloc_size); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 59 | |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 60 | hb_buffer_t * |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 61 | hb_buffer_reference (hb_buffer_t *buffer); |
| 62 | |
| 63 | unsigned int |
| 64 | hb_buffer_get_reference_count (hb_buffer_t *buffer); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 65 | |
Behdad Esfahbod | a8abb8b | 2007-10-11 00:07:58 +0000 | [diff] [blame] | 66 | void |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 67 | hb_buffer_destroy (hb_buffer_t *buffer); |
| 68 | |
| 69 | |
| 70 | void |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 71 | hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, |
| 72 | hb_unicode_funcs_t *unicode_funcs); |
| 73 | |
| 74 | hb_unicode_funcs_t * |
| 75 | hb_buffer_get_unicode_funcs (hb_buffer_t *buffer); |
| 76 | |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 77 | void |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 78 | hb_buffer_set_direction (hb_buffer_t *buffer, |
| 79 | hb_direction_t direction); |
| 80 | |
| 81 | hb_direction_t |
| 82 | hb_buffer_get_direction (hb_buffer_t *buffer); |
| 83 | |
Behdad Esfahbod | ae070b7 | 2009-11-04 20:29:54 -0500 | [diff] [blame] | 84 | void |
| 85 | hb_buffer_set_script (hb_buffer_t *buffer, |
| 86 | hb_script_t script); |
| 87 | |
| 88 | hb_script_t |
| 89 | hb_buffer_get_script (hb_buffer_t *buffer); |
| 90 | |
| 91 | void |
| 92 | hb_buffer_set_language (hb_buffer_t *buffer, |
| 93 | hb_language_t language); |
| 94 | |
| 95 | hb_language_t |
| 96 | hb_buffer_get_language (hb_buffer_t *buffer); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 97 | |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 98 | |
Behdad Esfahbod | a8abb8b | 2007-10-11 00:07:58 +0000 | [diff] [blame] | 99 | void |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 100 | hb_buffer_clear (hb_buffer_t *buffer); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 101 | |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 102 | void |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 103 | hb_buffer_clear_positions (hb_buffer_t *buffer); |
| 104 | |
Behdad Esfahbod | a6a79df | 2010-05-14 23:20:16 -0400 | [diff] [blame] | 105 | hb_bool_t |
Behdad Esfahbod | f9cd101 | 2009-07-28 15:43:34 -0400 | [diff] [blame] | 106 | hb_buffer_ensure (hb_buffer_t *buffer, |
| 107 | unsigned int size); |
| 108 | |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 109 | void |
| 110 | hb_buffer_reverse (hb_buffer_t *buffer); |
| 111 | |
Behdad Esfahbod | ff44f88 | 2009-11-06 19:48:16 -0500 | [diff] [blame] | 112 | void |
| 113 | hb_buffer_reverse_clusters (hb_buffer_t *buffer); |
| 114 | |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 115 | |
| 116 | /* Filling the buffer in */ |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 117 | |
Behdad Esfahbod | f9cd101 | 2009-07-28 15:43:34 -0400 | [diff] [blame] | 118 | void |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 119 | hb_buffer_add_glyph (hb_buffer_t *buffer, |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 120 | hb_codepoint_t codepoint, |
Behdad Esfahbod | 468769b | 2009-08-08 16:53:23 -0400 | [diff] [blame] | 121 | hb_mask_t mask, |
Behdad Esfahbod | b857b49 | 2009-05-20 05:35:14 -0400 | [diff] [blame] | 122 | unsigned int cluster); |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 123 | |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 124 | void |
| 125 | hb_buffer_add_utf8 (hb_buffer_t *buffer, |
| 126 | const char *text, |
Behdad Esfahbod | 299f089 | 2009-08-10 22:47:57 -0400 | [diff] [blame] | 127 | unsigned int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 128 | unsigned int item_offset, |
Behdad Esfahbod | 299f089 | 2009-08-10 22:47:57 -0400 | [diff] [blame] | 129 | unsigned int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 130 | |
| 131 | void |
| 132 | hb_buffer_add_utf16 (hb_buffer_t *buffer, |
| 133 | const uint16_t *text, |
Behdad Esfahbod | 299f089 | 2009-08-10 22:47:57 -0400 | [diff] [blame] | 134 | unsigned int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 135 | unsigned int item_offset, |
Behdad Esfahbod | 299f089 | 2009-08-10 22:47:57 -0400 | [diff] [blame] | 136 | unsigned int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 137 | |
| 138 | void |
| 139 | hb_buffer_add_utf32 (hb_buffer_t *buffer, |
| 140 | const uint32_t *text, |
Behdad Esfahbod | 299f089 | 2009-08-10 22:47:57 -0400 | [diff] [blame] | 141 | unsigned int text_length, |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 142 | unsigned int item_offset, |
Behdad Esfahbod | 299f089 | 2009-08-10 22:47:57 -0400 | [diff] [blame] | 143 | unsigned int item_length); |
Behdad Esfahbod | 1b7b97f | 2009-08-10 21:10:37 -0400 | [diff] [blame] | 144 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 145 | |
Behdad Esfahbod | fbaf8ff | 2009-08-10 20:59:25 -0400 | [diff] [blame] | 146 | /* Getting glyphs out of the buffer */ |
| 147 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 148 | /* Return value valid as long as buffer not modified */ |
| 149 | unsigned int |
Behdad Esfahbod | 3d14528 | 2009-11-06 15:13:17 -0500 | [diff] [blame] | 150 | hb_buffer_get_length (hb_buffer_t *buffer); |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 151 | |
| 152 | /* Return value valid as long as buffer not modified */ |
| 153 | hb_glyph_info_t * |
| 154 | hb_buffer_get_glyph_infos (hb_buffer_t *buffer); |
| 155 | |
| 156 | /* Return value valid as long as buffer not modified */ |
| 157 | hb_glyph_position_t * |
| 158 | hb_buffer_get_glyph_positions (hb_buffer_t *buffer); |
Behdad Esfahbod | 02a3706 | 2009-07-29 18:41:25 -0400 | [diff] [blame] | 159 | |
| 160 | |
Behdad Esfahbod | f96ffd4 | 2009-05-24 15:01:16 -0400 | [diff] [blame] | 161 | HB_END_DECLS |
Behdad Esfahbod | 9f8da38 | 2006-03-31 12:28:09 +0000 | [diff] [blame] | 162 | |
Behdad Esfahbod | 5c0adce | 2009-05-20 05:42:12 -0400 | [diff] [blame] | 163 | #endif /* HB_BUFFER_H */ |