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);
68 _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
71 const uint16_t *glyph_data_be);
74 _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
75 hb_codepoint_t glyph_index);
78 _hb_buffer_next_glyph (hb_buffer_t *buffer);
82 _hb_buffer_reset_masks (hb_buffer_t *buffer,
86 _hb_buffer_add_masks (hb_buffer_t *buffer,
90 _hb_buffer_set_masks (hb_buffer_t *buffer,
93 unsigned int cluster_start,
94 unsigned int cluster_end);
98 hb_reference_count_t ref_count;
100 /* Information about how the text in the buffer should be treated */
102 hb_unicode_funcs_t *unicode; /* Unicode functions */
103 hb_segment_properties_t props; /* Script, language, direction */
105 /* Buffer contents */
107 unsigned int allocated; /* Length of allocated arrays */
109 hb_bool_t have_output; /* Whether we have an output buffer going on */
110 hb_bool_t have_positions; /* Whether we have positions */
111 hb_bool_t in_error; /* Allocation failed */
113 unsigned int i; /* Cursor into ->info and ->pos arrays */
114 unsigned int len; /* Length of ->info and ->pos arrays */
115 unsigned int out_len; /* Length of ->out array */
117 hb_glyph_info_t *info;
118 hb_glyph_info_t *out_info;
119 hb_glyph_position_t *pos;
123 unsigned int max_lig_id;
127 inline unsigned int allocate_lig_id (void) { return max_lig_id++; }
128 inline void swap (void) { _hb_buffer_swap (this); }
129 inline void clear_output (void) { _hb_buffer_clear_output (this); }
130 inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
131 inline void add_output_glyphs (unsigned int num_in,
132 unsigned int num_out,
133 const hb_codepoint_t *glyph_data)
134 { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data); }
135 inline void add_output_glyphs_be16 (unsigned int num_in,
136 unsigned int num_out,
137 const uint16_t *glyph_data_be)
138 { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be); }
139 inline void add_output_glyph (hb_codepoint_t glyph_index)
140 { _hb_buffer_add_output_glyph (this, glyph_index); }
141 inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); }
143 inline void reset_masks (hb_mask_t mask)
145 for (unsigned int i = 0; i < len; i++)
148 inline void add_masks (hb_mask_t mask)
150 for (unsigned int i = 0; i < len; i++)
151 info[i].mask |= mask;
153 inline void set_masks (hb_mask_t value,
155 unsigned int cluster_start,
156 unsigned int cluster_end)
157 { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); }
164 #endif /* HB_BUFFER_PRIVATE_HH */