One fewer cmp() implementation...
[framework/uifw/harfbuzz.git] / src / hb-buffer.h
1 /*
2  * Copyright (C) 1998-2004  David Turner and Werner Lemberg
3  * Copyright (C) 2004,2007,2009  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_H
29 #define HB_BUFFER_H
30
31 #include "hb-common.h"
32 #include "hb-unicode.h"
33 #include "hb-language.h"
34
35 HB_BEGIN_DECLS
36
37
38 typedef struct _hb_buffer_t hb_buffer_t;
39
40 typedef struct _hb_glyph_info_t {
41   hb_codepoint_t codepoint;
42   hb_mask_t      mask;
43   uint32_t       cluster;
44   uint32_t       internal1;
45   uint32_t       internal2;
46 } hb_glyph_info_t;
47
48 typedef struct _hb_glyph_position_t {
49   hb_position_t  x_advance;
50   hb_position_t  y_advance;
51   hb_position_t  x_offset;
52   hb_position_t  y_offset;
53   uint32_t       internal;
54 } hb_glyph_position_t;
55
56
57 hb_buffer_t *
58 hb_buffer_create (unsigned int pre_alloc_size);
59
60 hb_buffer_t *
61 hb_buffer_reference (hb_buffer_t *buffer);
62
63 unsigned int
64 hb_buffer_get_reference_count (hb_buffer_t *buffer);
65
66 void
67 hb_buffer_destroy (hb_buffer_t *buffer);
68
69
70 void
71 hb_buffer_set_unicode_funcs (hb_buffer_t        *buffer,
72                              hb_unicode_funcs_t *unicode_funcs);
73
74 hb_unicode_funcs_t *
75 hb_buffer_get_unicode_funcs (hb_buffer_t        *buffer);
76
77 void
78 hb_buffer_set_direction (hb_buffer_t    *buffer,
79                          hb_direction_t  direction);
80
81 hb_direction_t
82 hb_buffer_get_direction (hb_buffer_t *buffer);
83
84 void
85 hb_buffer_set_script (hb_buffer_t *buffer,
86                       hb_script_t  script);
87
88 hb_script_t
89 hb_buffer_get_script (hb_buffer_t *buffer);
90
91 void
92 hb_buffer_set_language (hb_buffer_t   *buffer,
93                         hb_language_t  language);
94
95 hb_language_t
96 hb_buffer_get_language (hb_buffer_t *buffer);
97
98
99 void
100 hb_buffer_clear (hb_buffer_t *buffer);
101
102 void
103 hb_buffer_clear_positions (hb_buffer_t *buffer);
104
105 hb_bool_t
106 hb_buffer_ensure (hb_buffer_t  *buffer,
107                   unsigned int  size);
108
109 void
110 hb_buffer_reverse (hb_buffer_t *buffer);
111
112 void
113 hb_buffer_reverse_clusters (hb_buffer_t *buffer);
114
115
116 /* Filling the buffer in */
117
118 void
119 hb_buffer_add_glyph (hb_buffer_t    *buffer,
120                      hb_codepoint_t  codepoint,
121                      hb_mask_t       mask,
122                      unsigned int    cluster);
123
124 void
125 hb_buffer_add_utf8 (hb_buffer_t  *buffer,
126                     const char   *text,
127                     unsigned int  text_length,
128                     unsigned int  item_offset,
129                     unsigned int  item_length);
130
131 void
132 hb_buffer_add_utf16 (hb_buffer_t    *buffer,
133                      const uint16_t *text,
134                      unsigned int    text_length,
135                      unsigned int    item_offset,
136                      unsigned int    item_length);
137
138 void
139 hb_buffer_add_utf32 (hb_buffer_t    *buffer,
140                      const uint32_t *text,
141                      unsigned int    text_length,
142                      unsigned int    item_offset,
143                      unsigned int    item_length);
144
145
146 /* Getting glyphs out of the buffer */
147
148 /* Return value valid as long as buffer not modified */
149 unsigned int
150 hb_buffer_get_length (hb_buffer_t *buffer);
151
152 /* Return value valid as long as buffer not modified */
153 hb_glyph_info_t *
154 hb_buffer_get_glyph_infos (hb_buffer_t *buffer);
155
156 /* Return value valid as long as buffer not modified */
157 hb_glyph_position_t *
158 hb_buffer_get_glyph_positions (hb_buffer_t *buffer);
159
160
161 HB_END_DECLS
162
163 #endif /* HB_BUFFER_H */