Fix header
[profile/ivi/org.tizen.video-player.git] / src / hb-buffer-private.hh
1 /*
2  * Copyright (C) 1998-2004  David Turner and Werner Lemberg
3  * Copyright (C) 2004,2007,2009,2010  Red Hat, Inc.
4  *
5  * This is part of HarfBuzz, a text shaping library.
6  *
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.
12  *
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
26  */
27
28 #ifndef HB_BUFFER_PRIVATE_HH
29 #define HB_BUFFER_PRIVATE_HH
30
31 #include "hb-private.h"
32 #include "hb-buffer.h"
33 #include "hb-unicode-private.h"
34
35 HB_BEGIN_DECLS
36
37 #define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
38
39
40 typedef struct _hb_internal_glyph_info_t {
41   hb_codepoint_t codepoint;
42   hb_mask_t      mask;
43   uint32_t       cluster;
44   uint16_t       component;
45   uint16_t       lig_id;
46   uint32_t       gproperty;
47 } hb_internal_glyph_info_t;
48
49 typedef struct _hb_internal_glyph_position_t {
50   hb_position_t  x_advance;
51   hb_position_t  y_advance;
52   hb_position_t  x_offset;
53   hb_position_t  y_offset;
54   uint32_t       back : 16;             /* number of glyphs to go back
55                                            for drawing current glyph */
56   int32_t        cursive_chain : 16;    /* character to which this connects,
57                                            may be positive or negative */
58 } hb_internal_glyph_position_t;
59
60 ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t));
61 ASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t));
62 ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
63
64
65 HB_INTERNAL void
66 _hb_buffer_swap (hb_buffer_t *buffer);
67
68 HB_INTERNAL void
69 _hb_buffer_clear_output (hb_buffer_t *buffer);
70
71 HB_INTERNAL void
72 _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
73                               unsigned int num_in,
74                               unsigned int num_out,
75                               const hb_codepoint_t *glyph_data,
76                               unsigned short component,
77                               unsigned short ligID);
78
79 HB_INTERNAL void
80 _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
81                                    unsigned int num_in,
82                                    unsigned int num_out,
83                                    const uint16_t *glyph_data_be,
84                                    unsigned short component,
85                                    unsigned short ligID);
86
87 HB_INTERNAL void
88 _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
89                              hb_codepoint_t glyph_index,
90                              unsigned short component,
91                              unsigned short ligID);
92
93 HB_INTERNAL void
94 _hb_buffer_next_glyph (hb_buffer_t *buffer);
95
96
97 HB_INTERNAL void
98 _hb_buffer_clear_masks (hb_buffer_t *buffer);
99
100 HB_INTERNAL void
101 _hb_buffer_set_masks (hb_buffer_t *buffer,
102                       hb_mask_t    value,
103                       hb_mask_t    mask,
104                       unsigned int cluster_start,
105                       unsigned int cluster_end);
106
107
108 struct _hb_buffer_t {
109   hb_reference_count_t ref_count;
110
111   /* Information about how the text in the buffer should be treated */
112   hb_unicode_funcs_t *unicode;
113   hb_direction_t      direction;
114   hb_script_t         script;
115   hb_language_t       language;
116
117   /* Buffer contents */
118
119   unsigned int allocated; /* Length of allocated arrays */
120
121   hb_bool_t have_output; /* Whether we have an output buffer going on */
122   hb_bool_t have_positions; /* Whether we have positions */
123   hb_bool_t in_error; /* Allocation failed */
124
125   unsigned int i; /* Cursor into ->info and ->pos arrays */
126   unsigned int len; /* Length of ->info and ->pos arrays */
127   unsigned int out_len; /* Length of ->out array */
128
129   hb_internal_glyph_info_t     *info;
130   hb_internal_glyph_info_t     *out_info;
131   hb_internal_glyph_position_t *pos;
132
133   /* Other stuff */
134
135   unsigned int max_lig_id;
136
137
138   /* Methods */
139   inline unsigned int allocate_lig_id (void) { return max_lig_id++; }
140   inline void swap (void) { _hb_buffer_swap (this); }
141   inline void clear_output (void) { _hb_buffer_clear_output (this); }
142   inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
143   inline void add_output_glyphs (unsigned int num_in,
144                                  unsigned int num_out,
145                                  const hb_codepoint_t *glyph_data,
146                                  unsigned short component,
147                                  unsigned short ligID)
148   { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data, component, ligID); }
149   inline void add_output_glyphs_be16 (unsigned int num_in,
150                                       unsigned int num_out,
151                                       const uint16_t *glyph_data_be,
152                                       unsigned short component,
153                                       unsigned short ligID)
154   { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be, component, ligID); }
155   inline void add_output_glyph (hb_codepoint_t glyph_index,
156                                 unsigned short component = 0xFFFF,
157                                 unsigned short ligID = 0xFFFF)
158   { _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); }
159   inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); }
160
161   inline void clear_masks (void) { _hb_buffer_clear_masks (this); }
162   inline void set_masks (hb_mask_t    value,
163                          hb_mask_t mask,
164                          unsigned int cluster_start,
165                          unsigned int cluster_end)
166   { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); }
167
168 };
169
170
171 HB_END_DECLS
172
173 #endif /* HB_BUFFER_PRIVATE_HH */