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 | 22da7fd | 2010-05-12 18:23:21 -0400 | [diff] [blame] | 3 | * Copyright (C) 2004,2007,2009,2010 Red Hat, Inc. |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +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 | 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 | 3015c41 | 2009-05-20 06:01:16 -0400 | [diff] [blame] | 31 | #include "hb-private.h" |
Behdad Esfahbod | 5c0adce | 2009-05-20 05:42:12 -0400 | [diff] [blame] | 32 | #include "hb-buffer.h" |
Behdad Esfahbod | 5ebabec | 2009-11-03 15:15:07 -0500 | [diff] [blame] | 33 | #include "hb-unicode-private.h" |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 34 | |
Behdad Esfahbod | f96ffd4 | 2009-05-24 15:01:16 -0400 | [diff] [blame] | 35 | HB_BEGIN_DECLS |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 36 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 37 | |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 38 | #define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 39 | |
Behdad Esfahbod | 11fbb54 | 2009-08-01 22:19:06 -0400 | [diff] [blame] | 40 | |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 41 | typedef struct _hb_internal_glyph_info_t { |
| 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; |
| 45 | uint16_t component; |
| 46 | uint16_t lig_id; |
| 47 | uint32_t gproperty; |
| 48 | } hb_internal_glyph_info_t; |
| 49 | |
| 50 | typedef struct _hb_internal_glyph_position_t { |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 51 | hb_position_t x_advance; |
| 52 | hb_position_t y_advance; |
Behdad Esfahbod | 9bef361 | 2009-11-05 12:20:11 -0500 | [diff] [blame] | 53 | hb_position_t x_offset; |
| 54 | hb_position_t y_offset; |
Behdad Esfahbod | 9db8ad7 | 2009-11-06 16:47:31 -0500 | [diff] [blame] | 55 | uint32_t back : 16; /* number of glyphs to go back |
Behdad Esfahbod | 864e256 | 2009-08-18 16:38:48 -0400 | [diff] [blame] | 56 | for drawing current glyph */ |
| 57 | int32_t cursive_chain : 16; /* character to which this connects, |
Behdad Esfahbod | c3df649 | 2010-05-11 13:54:12 -0400 | [diff] [blame] | 58 | may be positive or negative */ |
Behdad Esfahbod | f1322e5 | 2009-08-01 22:53:04 -0400 | [diff] [blame] | 59 | } hb_internal_glyph_position_t; |
| 60 | |
| 61 | ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t)); |
| 62 | ASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t)); |
| 63 | ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)); |
| 64 | |
| 65 | |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 66 | HB_INTERNAL void |
Behdad Esfahbod | 3015c41 | 2009-05-20 06:01:16 -0400 | [diff] [blame] | 67 | _hb_buffer_swap (hb_buffer_t *buffer); |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 68 | |
| 69 | HB_INTERNAL void |
Behdad Esfahbod | 3015c41 | 2009-05-20 06:01:16 -0400 | [diff] [blame] | 70 | _hb_buffer_clear_output (hb_buffer_t *buffer); |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 71 | |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 72 | HB_INTERNAL void |
Behdad Esfahbod | 3015c41 | 2009-05-20 06:01:16 -0400 | [diff] [blame] | 73 | _hb_buffer_add_output_glyphs (hb_buffer_t *buffer, |
| 74 | unsigned int num_in, |
| 75 | unsigned int num_out, |
Behdad Esfahbod | 25e7ef7 | 2009-11-06 17:21:01 -0500 | [diff] [blame] | 76 | const hb_codepoint_t *glyph_data, |
Behdad Esfahbod | 3015c41 | 2009-05-20 06:01:16 -0400 | [diff] [blame] | 77 | unsigned short component, |
| 78 | unsigned short ligID); |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 79 | |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 80 | HB_INTERNAL void |
Behdad Esfahbod | 25e7ef7 | 2009-11-06 17:21:01 -0500 | [diff] [blame] | 81 | _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer, |
| 82 | unsigned int num_in, |
| 83 | unsigned int num_out, |
| 84 | const uint16_t *glyph_data_be, |
| 85 | unsigned short component, |
| 86 | unsigned short ligID); |
| 87 | |
| 88 | HB_INTERNAL void |
Behdad Esfahbod | 3015c41 | 2009-05-20 06:01:16 -0400 | [diff] [blame] | 89 | _hb_buffer_add_output_glyph (hb_buffer_t *buffer, |
| 90 | hb_codepoint_t glyph_index, |
| 91 | unsigned short component, |
| 92 | unsigned short ligID); |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 93 | |
Behdad Esfahbod | c968fc2 | 2009-05-25 04:04:24 -0400 | [diff] [blame] | 94 | HB_INTERNAL void |
Behdad Esfahbod | 3015c41 | 2009-05-20 06:01:16 -0400 | [diff] [blame] | 95 | _hb_buffer_next_glyph (hb_buffer_t *buffer); |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 96 | |
Behdad Esfahbod | 78ef65b | 2007-11-07 08:06:01 +0000 | [diff] [blame] | 97 | |
Behdad Esfahbod | 1ce7b87 | 2010-05-21 17:31:45 +0100 | [diff] [blame] | 98 | HB_INTERNAL void |
| 99 | _hb_buffer_clear_masks (hb_buffer_t *buffer); |
| 100 | |
| 101 | HB_INTERNAL void |
Behdad Esfahbod | 81c5e87 | 2010-05-28 18:31:16 -0400 | [diff] [blame] | 102 | _hb_buffer_set_masks (hb_buffer_t *buffer, |
| 103 | hb_mask_t value, |
| 104 | hb_mask_t mask, |
| 105 | unsigned int cluster_start, |
| 106 | unsigned int cluster_end); |
Behdad Esfahbod | 1ce7b87 | 2010-05-21 17:31:45 +0100 | [diff] [blame] | 107 | |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 108 | |
| 109 | struct _hb_buffer_t { |
| 110 | hb_reference_count_t ref_count; |
| 111 | |
| 112 | /* Information about how the text in the buffer should be treated */ |
| 113 | hb_unicode_funcs_t *unicode; |
| 114 | hb_direction_t direction; |
| 115 | hb_script_t script; |
| 116 | hb_language_t language; |
| 117 | |
| 118 | /* Buffer contents */ |
| 119 | |
Behdad Esfahbod | 910a33f | 2010-05-14 22:13:38 -0400 | [diff] [blame] | 120 | unsigned int allocated; /* Length of allocated arrays */ |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 121 | |
Behdad Esfahbod | a6a79df | 2010-05-14 23:20:16 -0400 | [diff] [blame] | 122 | hb_bool_t have_output; /* Whether we have an output buffer going on */ |
| 123 | hb_bool_t have_positions; /* Whether we have positions */ |
| 124 | hb_bool_t in_error; /* Allocation failed */ |
Behdad Esfahbod | 910a33f | 2010-05-14 22:13:38 -0400 | [diff] [blame] | 125 | |
| 126 | unsigned int i; /* Cursor into ->info and ->pos arrays */ |
| 127 | unsigned int len; /* Length of ->info and ->pos arrays */ |
| 128 | unsigned int out_len; /* Length of ->out array */ |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 129 | |
Behdad Esfahbod | 7e7007a | 2010-05-14 22:02:37 -0400 | [diff] [blame] | 130 | hb_internal_glyph_info_t *info; |
Behdad Esfahbod | 9d5e26d | 2010-05-14 22:03:11 -0400 | [diff] [blame] | 131 | hb_internal_glyph_info_t *out_info; |
Behdad Esfahbod | 1b62182 | 2010-05-14 22:05:53 -0400 | [diff] [blame] | 132 | hb_internal_glyph_position_t *pos; |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 133 | |
| 134 | /* Other stuff */ |
| 135 | |
Behdad Esfahbod | 1b62182 | 2010-05-14 22:05:53 -0400 | [diff] [blame] | 136 | unsigned int max_lig_id; |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 137 | |
| 138 | |
| 139 | /* Methods */ |
| 140 | inline unsigned int allocate_lig_id (void) { return max_lig_id++; } |
| 141 | inline void swap (void) { _hb_buffer_swap (this); } |
Behdad Esfahbod | 1d5e780 | 2010-05-12 23:43:00 -0400 | [diff] [blame] | 142 | inline void clear_output (void) { _hb_buffer_clear_output (this); } |
| 143 | inline void next_glyph (void) { _hb_buffer_next_glyph (this); } |
Behdad Esfahbod | 72071a8 | 2010-05-13 13:22:24 -0400 | [diff] [blame] | 144 | inline void add_output_glyphs (unsigned int num_in, |
| 145 | unsigned int num_out, |
| 146 | const hb_codepoint_t *glyph_data, |
| 147 | unsigned short component, |
| 148 | unsigned short ligID) |
| 149 | { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data, component, ligID); } |
| 150 | inline void add_output_glyphs_be16 (unsigned int num_in, |
| 151 | unsigned int num_out, |
| 152 | const uint16_t *glyph_data_be, |
| 153 | unsigned short component, |
| 154 | unsigned short ligID) |
| 155 | { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be, component, ligID); } |
Behdad Esfahbod | 1d5e780 | 2010-05-12 23:43:00 -0400 | [diff] [blame] | 156 | inline void add_output_glyph (hb_codepoint_t glyph_index, |
| 157 | unsigned short component = 0xFFFF, |
| 158 | unsigned short ligID = 0xFFFF) |
| 159 | { _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); } |
| 160 | inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); } |
Behdad Esfahbod | 1ce7b87 | 2010-05-21 17:31:45 +0100 | [diff] [blame] | 161 | |
| 162 | inline void clear_masks (void) { _hb_buffer_clear_masks (this); } |
Behdad Esfahbod | 81c5e87 | 2010-05-28 18:31:16 -0400 | [diff] [blame] | 163 | inline void set_masks (hb_mask_t value, |
| 164 | hb_mask_t mask, |
| 165 | unsigned int cluster_start, |
| 166 | unsigned int cluster_end) |
| 167 | { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); } |
Behdad Esfahbod | 1ce7b87 | 2010-05-21 17:31:45 +0100 | [diff] [blame] | 168 | |
Behdad Esfahbod | d0316a8 | 2010-05-12 23:34:52 -0400 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | |
Behdad Esfahbod | f96ffd4 | 2009-05-24 15:01:16 -0400 | [diff] [blame] | 172 | HB_END_DECLS |
Behdad Esfahbod | 6b34713 | 2007-10-11 08:30:50 +0000 | [diff] [blame] | 173 | |
Behdad Esfahbod | da8edbb | 2010-06-09 07:15:39 -0400 | [diff] [blame] | 174 | #endif /* HB_BUFFER_PRIVATE_HH */ |