Update Copyright headers
[apps/home/video-player.git] / src / hb-buffer.h
1 /*
2  * Copyright © 1998-2004  David Turner and Werner Lemberg
3  * Copyright © 2004,2007,2009  Red Hat, Inc.
4  * Copyright © 2011  Google, Inc.
5  *
6  *  This is part of HarfBuzz, a text shaping library.
7  *
8  * Permission is hereby granted, without written agreement and without
9  * license or royalty fees, to use, copy, modify, and distribute this
10  * software and its documentation for any purpose, provided that the
11  * above copyright notice and the following two paragraphs appear in
12  * all copies of this software.
13  *
14  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
15  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
17  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18  * DAMAGE.
19  *
20  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
21  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
23  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
24  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25  *
26  * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
27  * Google Author(s): Behdad Esfahbod
28  */
29
30 #ifndef HB_BUFFER_H
31 #define HB_BUFFER_H
32
33 #include "hb-common.h"
34 #include "hb-unicode.h"
35
36 HB_BEGIN_DECLS
37
38
39 typedef struct _hb_buffer_t hb_buffer_t;
40
41 typedef struct _hb_glyph_info_t {
42   hb_codepoint_t codepoint;
43   hb_mask_t      mask;
44   uint32_t       cluster;
45
46   /*< private >*/
47   hb_var_int_t   var1;
48   hb_var_int_t   var2;
49 } hb_glyph_info_t;
50
51 typedef struct _hb_glyph_position_t {
52   hb_position_t  x_advance;
53   hb_position_t  y_advance;
54   hb_position_t  x_offset;
55   hb_position_t  y_offset;
56
57   /*< private >*/
58   hb_var_int_t   var;
59 } hb_glyph_position_t;
60
61
62 hb_buffer_t *
63 hb_buffer_create (unsigned int pre_alloc_size);
64
65 hb_buffer_t *
66 hb_buffer_reference (hb_buffer_t *buffer);
67
68 void
69 hb_buffer_destroy (hb_buffer_t *buffer);
70
71
72 void
73 hb_buffer_set_unicode_funcs (hb_buffer_t        *buffer,
74                              hb_unicode_funcs_t *unicode_funcs);
75
76 hb_unicode_funcs_t *
77 hb_buffer_get_unicode_funcs (hb_buffer_t        *buffer);
78
79 void
80 hb_buffer_set_direction (hb_buffer_t    *buffer,
81                          hb_direction_t  direction);
82
83 hb_direction_t
84 hb_buffer_get_direction (hb_buffer_t *buffer);
85
86 void
87 hb_buffer_set_script (hb_buffer_t *buffer,
88                       hb_script_t  script);
89
90 hb_script_t
91 hb_buffer_get_script (hb_buffer_t *buffer);
92
93 void
94 hb_buffer_set_language (hb_buffer_t   *buffer,
95                         hb_language_t  language);
96
97 hb_language_t
98 hb_buffer_get_language (hb_buffer_t *buffer);
99
100
101 /* Resets the buffer.  Afterwards it's as if it was just created,
102  * except that it has a larger buffer allocated perhaps... */
103 void
104 hb_buffer_reset (hb_buffer_t *buffer);
105
106 /* Returns FALSE if allocation failed */
107 hb_bool_t
108 hb_buffer_pre_allocate (hb_buffer_t  *buffer,
109                         unsigned int  size);
110
111
112 /* Returns FALSE if allocation has failed before */
113 hb_bool_t
114 hb_buffer_allocation_successful (hb_buffer_t  *buffer);
115
116 void
117 hb_buffer_reverse (hb_buffer_t *buffer);
118
119 void
120 hb_buffer_reverse_clusters (hb_buffer_t *buffer);
121
122
123 /* Filling the buffer in */
124
125 void
126 hb_buffer_add (hb_buffer_t    *buffer,
127                hb_codepoint_t  codepoint,
128                hb_mask_t       mask,
129                unsigned int    cluster);
130
131 void
132 hb_buffer_add_utf8 (hb_buffer_t  *buffer,
133                     const char   *text,
134                     unsigned int  text_length,
135                     unsigned int  item_offset,
136                     unsigned int  item_length);
137
138 void
139 hb_buffer_add_utf16 (hb_buffer_t    *buffer,
140                      const uint16_t *text,
141                      unsigned int    text_length,
142                      unsigned int    item_offset,
143                      unsigned int    item_length);
144
145 void
146 hb_buffer_add_utf32 (hb_buffer_t    *buffer,
147                      const uint32_t *text,
148                      unsigned int    text_length,
149                      unsigned int    item_offset,
150                      unsigned int    item_length);
151
152
153 /* Clears any new items added at the end */
154 hb_bool_t
155 hb_buffer_set_length (hb_buffer_t  *buffer,
156                       unsigned int  length);
157
158 /* Return value valid as long as buffer not modified */
159 unsigned int
160 hb_buffer_get_length (hb_buffer_t *buffer);
161
162 /* Getting glyphs out of the buffer */
163
164 /* Return value valid as long as buffer not modified */
165 hb_glyph_info_t *
166 hb_buffer_get_glyph_infos (hb_buffer_t  *buffer,
167                            unsigned int *length);
168
169 /* Return value valid as long as buffer not modified */
170 hb_glyph_position_t *
171 hb_buffer_get_glyph_positions (hb_buffer_t  *buffer,
172                                unsigned int *length);
173
174
175 HB_END_DECLS
176
177 #endif /* HB_BUFFER_H */