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,2010 Red Hat, Inc. |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 4 | * |
Behdad Esfahbod | 8f0d7e0 | 2011-04-15 18:59:56 -0400 | [diff] [blame] | 5 | * This is part of HarfBuzz, a text shaping library. |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +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 | 6b34713 | 2007-10-11 08:30:50 +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 | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 26 | */ |
Behdad Esfahbod | a2a9a02 | 2008-01-15 22:46:32 +0000 | [diff] [blame] | 27 | |
Behdad Esfahbod | da8edbb | 2010-06-09 07:15:39 -0400 | [diff] [blame] | 28 | #ifndef HB_BUFFER_PRIVATE_HH |
| 29 | #define HB_BUFFER_PRIVATE_HH |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 30 | |
Behdad Esfahbod | c57d454 | 2011-04-20 18:50:27 -0400 | [diff] [blame] | 31 | #include "hb-private.hh" |
Behdad Esfahbod | 5c0adce | 2009-05-20 05:42:12 -0400 | [diff] [blame] | 32 | #include "hb-buffer.h" |
Behdad Esfahbod | fca368c | 2011-04-21 18:24:02 -0400 | [diff] [blame^] | 33 | #include "hb-object-private.hh" |
Behdad Esfahbod | fb194b8 | 2011-04-20 02:00:47 -0400 | [diff] [blame] | 34 | #include "hb-unicode-private.hh" |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 35 | |
Behdad Esfahbod | f96ffd4 | 2009-05-24 15:01:16 -0400 | [diff] [blame] | 36 | HB_BEGIN_DECLS |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 37 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 38 | |
Behdad Esfahbod | 88474c6 | 2010-10-27 14:42:15 -0400 | [diff] [blame] | 39 | ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20); |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 40 | ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)); |
| 41 | |
Behdad Esfahbod | a7c5046 | 2010-10-08 18:47:47 -0400 | [diff] [blame] | 42 | typedef struct _hb_segment_properties_t { |
| 43 | hb_direction_t direction; |
| 44 | hb_script_t script; |
| 45 | hb_language_t language; |
| 46 | } hb_segment_properties_t; |
| 47 | |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 48 | |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 49 | HB_INTERNAL void |
Behdad Esfahbod | 3015c41 | 2009-05-20 06:01:16 -0400 | [diff] [blame] | 50 | _hb_buffer_swap (hb_buffer_t *buffer); |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 51 | |
| 52 | HB_INTERNAL void |
Behdad Esfahbod | 3015c41 | 2009-05-20 06:01:16 -0400 | [diff] [blame] | 53 | _hb_buffer_clear_output (hb_buffer_t *buffer); |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 54 | |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 55 | HB_INTERNAL void |
Behdad Esfahbod | 8f0d7e0 | 2011-04-15 18:59:56 -0400 | [diff] [blame] | 56 | _hb_buffer_clear_positions (hb_buffer_t *buffer); |
| 57 | |
| 58 | HB_INTERNAL void |
Behdad Esfahbod | dd2ffd2 | 2010-10-27 16:57:01 -0400 | [diff] [blame] | 59 | _hb_buffer_replace_glyphs_be16 (hb_buffer_t *buffer, |
| 60 | unsigned int num_in, |
| 61 | unsigned int num_out, |
| 62 | const uint16_t *glyph_data_be); |
Behdad Esfahbod | 25e7ef7 | 2009-11-06 17:21:01 -0500 | [diff] [blame] | 63 | |
| 64 | HB_INTERNAL void |
Behdad Esfahbod | dd2ffd2 | 2010-10-27 16:57:01 -0400 | [diff] [blame] | 65 | _hb_buffer_replace_glyph (hb_buffer_t *buffer, |
| 66 | hb_codepoint_t glyph_index); |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 67 | |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 68 | HB_INTERNAL void |
Behdad Esfahbod | 3015c41 | 2009-05-20 06:01:16 -0400 | [diff] [blame] | 69 | _hb_buffer_next_glyph (hb_buffer_t *buffer); |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 70 | |
Behdad Esfahbod | 78ef65b | 2007-11-07 08:06:01 +0000 | [diff] [blame] | 71 | |
Behdad Esfahbod | 1ce7b87 | 2010-05-21 17:31:45 +0100 | [diff] [blame] | 72 | HB_INTERNAL void |
Behdad Esfahbod | 57ac0ec | 2010-10-12 17:07:02 -0400 | [diff] [blame] | 73 | _hb_buffer_reset_masks (hb_buffer_t *buffer, |
| 74 | hb_mask_t mask); |
Behdad Esfahbod | 1ce7b87 | 2010-05-21 17:31:45 +0100 | [diff] [blame] | 75 | |
| 76 | HB_INTERNAL void |
Behdad Esfahbod | 57ac0ec | 2010-10-12 17:07:02 -0400 | [diff] [blame] | 77 | _hb_buffer_add_masks (hb_buffer_t *buffer, |
Behdad Esfahbod | bd7378b | 2010-10-13 18:33:16 -0400 | [diff] [blame] | 78 | hb_mask_t mask); |
| 79 | |
| 80 | HB_INTERNAL void |
| 81 | _hb_buffer_set_masks (hb_buffer_t *buffer, |
Behdad Esfahbod | 81c5e87 | 2010-05-28 18:31:16 -0400 | [diff] [blame] | 82 | hb_mask_t value, |
| 83 | hb_mask_t mask, |
| 84 | unsigned int cluster_start, |
| 85 | unsigned int cluster_end); |
Behdad Esfahbod | 1ce7b87 | 2010-05-21 17:31:45 +0100 | [diff] [blame] | 86 | |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 87 | |
| 88 | struct _hb_buffer_t { |
Behdad Esfahbod | fca368c | 2011-04-21 18:24:02 -0400 | [diff] [blame^] | 89 | hb_object_header_t header; |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 90 | |
| 91 | /* Information about how the text in the buffer should be treated */ |
Behdad Esfahbod | 4e4ef24 | 2010-07-23 17:22:11 -0400 | [diff] [blame] | 92 | |
Behdad Esfahbod | a7c5046 | 2010-10-08 18:47:47 -0400 | [diff] [blame] | 93 | hb_unicode_funcs_t *unicode; /* Unicode functions */ |
| 94 | hb_segment_properties_t props; /* Script, language, direction */ |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 95 | |
| 96 | /* Buffer contents */ |
| 97 | |
Behdad Esfahbod | fca368c | 2011-04-21 18:24:02 -0400 | [diff] [blame^] | 98 | bool have_output; /* Whether we have an output buffer going on */ |
| 99 | bool have_positions; /* Whether we have positions */ |
| 100 | bool in_error; /* Allocation failed */ |
Behdad Esfahbod | 910a33f | 2010-05-14 22:13:38 -0400 | [diff] [blame] | 101 | |
| 102 | unsigned int i; /* Cursor into ->info and ->pos arrays */ |
| 103 | unsigned int len; /* Length of ->info and ->pos arrays */ |
Behdad Esfahbod | cc1a8a9 | 2011-01-06 14:58:52 -0500 | [diff] [blame] | 104 | unsigned int out_len; /* Length of ->out array if have_output */ |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 105 | |
Behdad Esfahbod | c0af193 | 2011-04-15 19:26:24 -0400 | [diff] [blame] | 106 | unsigned int serial; |
| 107 | |
| 108 | unsigned int allocated; /* Length of allocated arrays */ |
Behdad Esfahbod | 88474c6 | 2010-10-27 14:42:15 -0400 | [diff] [blame] | 109 | hb_glyph_info_t *info; |
| 110 | hb_glyph_info_t *out_info; |
| 111 | hb_glyph_position_t *pos; |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 112 | |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 113 | |
| 114 | /* Methods */ |
Behdad Esfahbod | cc1a8a9 | 2011-01-06 14:58:52 -0500 | [diff] [blame] | 115 | inline unsigned int backtrack_len (void) const |
| 116 | { return this->have_output? this->out_len : this->i; } |
Behdad Esfahbod | dbf56b1 | 2010-10-27 17:06:12 -0400 | [diff] [blame] | 117 | inline unsigned int next_serial (void) { return serial++; } |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 118 | inline void swap (void) { _hb_buffer_swap (this); } |
Behdad Esfahbod | 1d5e780 | 2010-05-12 23:43:00 -0400 | [diff] [blame] | 119 | inline void clear_output (void) { _hb_buffer_clear_output (this); } |
Behdad Esfahbod | 8f0d7e0 | 2011-04-15 18:59:56 -0400 | [diff] [blame] | 120 | inline void clear_positions (void) { _hb_buffer_clear_positions (this); } |
Behdad Esfahbod | 1d5e780 | 2010-05-12 23:43:00 -0400 | [diff] [blame] | 121 | inline void next_glyph (void) { _hb_buffer_next_glyph (this); } |
Behdad Esfahbod | dd2ffd2 | 2010-10-27 16:57:01 -0400 | [diff] [blame] | 122 | inline void replace_glyphs_be16 (unsigned int num_in, |
| 123 | unsigned int num_out, |
| 124 | const uint16_t *glyph_data_be) |
| 125 | { _hb_buffer_replace_glyphs_be16 (this, num_in, num_out, glyph_data_be); } |
| 126 | inline void replace_glyph (hb_codepoint_t glyph_index) |
| 127 | { _hb_buffer_replace_glyph (this, glyph_index); } |
Behdad Esfahbod | 1ce7b87 | 2010-05-21 17:31:45 +0100 | [diff] [blame] | 128 | |
Behdad Esfahbod | bd7378b | 2010-10-13 18:33:16 -0400 | [diff] [blame] | 129 | inline void reset_masks (hb_mask_t mask) |
| 130 | { |
| 131 | for (unsigned int i = 0; i < len; i++) |
| 132 | info[i].mask = mask; |
| 133 | } |
| 134 | inline void add_masks (hb_mask_t mask) |
| 135 | { |
| 136 | for (unsigned int i = 0; i < len; i++) |
| 137 | info[i].mask |= mask; |
| 138 | } |
| 139 | inline void set_masks (hb_mask_t value, |
Behdad Esfahbod | 81c5e87 | 2010-05-28 18:31:16 -0400 | [diff] [blame] | 140 | hb_mask_t mask, |
| 141 | unsigned int cluster_start, |
| 142 | unsigned int cluster_end) |
Behdad Esfahbod | bd7378b | 2010-10-13 18:33:16 -0400 | [diff] [blame] | 143 | { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); } |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | |
Behdad Esfahbod | f96ffd4 | 2009-05-24 15:01:16 -0400 | [diff] [blame] | 147 | HB_END_DECLS |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 148 | |
Behdad Esfahbod | da8edbb | 2010-06-09 07:15:39 -0400 | [diff] [blame] | 149 | #endif /* HB_BUFFER_PRIVATE_HH */ |