2 * Copyright (C) 1998-2004 David Turner and Werner Lemberg
3 * Copyright (C) 2004,2007,2009,2010 Red Hat, Inc.
5 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
25 * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
28 #ifndef HB_BUFFER_PRIVATE_HH
29 #define HB_BUFFER_PRIVATE_HH
31 #include "hb-private.h"
32 #include "hb-buffer.h"
33 #include "hb-unicode-private.h"
38 #define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
39 #define component() var1.u16[0]
40 #define lig_id() var1.u16[1]
41 #define gproperty() var2.u32
42 #define back() var.u16[0] /* number of glyphs to go back for drawing current glyph */
43 #define cursive_chain() var.i16[1] /* character to which this connects, may be positive or negative */
45 ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20);
46 ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
48 typedef struct _hb_segment_properties_t {
49 hb_direction_t direction;
51 hb_language_t language;
52 } hb_segment_properties_t;
56 _hb_buffer_swap (hb_buffer_t *buffer);
59 _hb_buffer_clear_output (hb_buffer_t *buffer);
62 _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
65 const hb_codepoint_t *glyph_data,
66 unsigned short component,
67 unsigned short ligID);
70 _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
73 const uint16_t *glyph_data_be,
74 unsigned short component,
75 unsigned short ligID);
78 _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
79 hb_codepoint_t glyph_index,
80 unsigned short component,
81 unsigned short ligID);
84 _hb_buffer_next_glyph (hb_buffer_t *buffer);
88 _hb_buffer_reset_masks (hb_buffer_t *buffer,
92 _hb_buffer_add_masks (hb_buffer_t *buffer,
96 _hb_buffer_set_masks (hb_buffer_t *buffer,
99 unsigned int cluster_start,
100 unsigned int cluster_end);
103 struct _hb_buffer_t {
104 hb_reference_count_t ref_count;
106 /* Information about how the text in the buffer should be treated */
108 hb_unicode_funcs_t *unicode; /* Unicode functions */
109 hb_segment_properties_t props; /* Script, language, direction */
111 /* Buffer contents */
113 unsigned int allocated; /* Length of allocated arrays */
115 hb_bool_t have_output; /* Whether we have an output buffer going on */
116 hb_bool_t have_positions; /* Whether we have positions */
117 hb_bool_t in_error; /* Allocation failed */
119 unsigned int i; /* Cursor into ->info and ->pos arrays */
120 unsigned int len; /* Length of ->info and ->pos arrays */
121 unsigned int out_len; /* Length of ->out array */
123 hb_glyph_info_t *info;
124 hb_glyph_info_t *out_info;
125 hb_glyph_position_t *pos;
129 unsigned int max_lig_id;
133 inline unsigned int allocate_lig_id (void) { return max_lig_id++; }
134 inline void swap (void) { _hb_buffer_swap (this); }
135 inline void clear_output (void) { _hb_buffer_clear_output (this); }
136 inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
137 inline void add_output_glyphs (unsigned int num_in,
138 unsigned int num_out,
139 const hb_codepoint_t *glyph_data,
140 unsigned short component,
141 unsigned short ligID)
142 { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data, component, ligID); }
143 inline void add_output_glyphs_be16 (unsigned int num_in,
144 unsigned int num_out,
145 const uint16_t *glyph_data_be,
146 unsigned short component,
147 unsigned short ligID)
148 { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be, component, ligID); }
149 inline void add_output_glyph (hb_codepoint_t glyph_index,
150 unsigned short component = 0xFFFF,
151 unsigned short ligID = 0xFFFF)
152 { _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); }
153 inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); }
155 inline void reset_masks (hb_mask_t mask)
157 for (unsigned int i = 0; i < len; i++)
160 inline void add_masks (hb_mask_t mask)
162 for (unsigned int i = 0; i < len; i++)
163 info[i].mask |= mask;
165 inline void set_masks (hb_mask_t value,
167 unsigned int cluster_start,
168 unsigned int cluster_end)
169 { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); }
176 #endif /* HB_BUFFER_PRIVATE_HH */