Start ft glue
[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, an OpenType Layout engine 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
34 HB_BEGIN_DECLS
35
36 typedef struct _hb_buffer_t hb_buffer_t;
37
38 typedef enum _hb_direction_t {
39   HB_DIRECTION_LTR,
40   HB_DIRECTION_RTL,
41   HB_DIRECTION_TTB,
42   HB_DIRECTION_BTT
43 } hb_direction_t;
44
45 typedef struct _hb_glyph_info_t {
46   hb_codepoint_t codepoint;
47   hb_mask_t      mask;
48   uint32_t       cluster;
49   uint32_t       internal1;
50   uint32_t       internal2;
51 } hb_glyph_info_t;
52
53 typedef struct _hb_glyph_position_t {
54   hb_position_t  x_pos;
55   hb_position_t  y_pos;
56   hb_position_t  x_advance;
57   hb_position_t  y_advance;
58   /* XXX these should all be replaced by "uint32_t internal" */
59   uint32_t       new_advance :1;        /* if set, the advance width values are
60                                            absolute, i.e., they won't be
61                                            added to the original glyph's value
62                                            but rather replace them */
63   uint32_t       back : 15;             /* number of glyphs to go back
64                                            for drawing current glyph */
65   int32_t        cursive_chain : 16;    /* character to which this connects,
66                                            may be positive or negative; used
67                                            only internally */
68 } hb_glyph_position_t;
69
70
71 hb_buffer_t *
72 hb_buffer_create (unsigned int pre_alloc_size);
73
74 hb_buffer_t *
75 hb_buffer_reference (hb_buffer_t *buffer);
76
77 unsigned int
78 hb_buffer_get_reference_count (hb_buffer_t *buffer);
79
80 void
81 hb_buffer_destroy (hb_buffer_t *buffer);
82
83
84 void
85 hb_buffer_set_unicode_funcs (hb_buffer_t        *buffer,
86                              hb_unicode_funcs_t *unicode_funcs);
87
88 hb_unicode_funcs_t *
89 hb_buffer_get_unicode_funcs (hb_buffer_t        *buffer);
90
91
92 void
93 hb_buffer_set_direction (hb_buffer_t    *buffer,
94                          hb_direction_t  direction);
95
96 hb_direction_t
97 hb_buffer_get_direction (hb_buffer_t *buffer);
98
99
100
101 void
102 hb_buffer_clear (hb_buffer_t *buffer);
103
104 void
105 hb_buffer_clear_positions (hb_buffer_t *buffer);
106
107 void
108 hb_buffer_ensure (hb_buffer_t  *buffer,
109                   unsigned int  size);
110
111 void
112 hb_buffer_reverse (hb_buffer_t *buffer);
113
114
115 /* Filling the buffer in */
116
117 void
118 hb_buffer_add_glyph (hb_buffer_t    *buffer,
119                      hb_codepoint_t  codepoint,
120                      hb_mask_t       mask,
121                      unsigned int    cluster);
122
123 void
124 hb_buffer_add_utf8 (hb_buffer_t  *buffer,
125                     const char   *text,
126                     unsigned int  text_length,
127                     unsigned int  item_offset,
128                     unsigned int  item_length);
129
130 void
131 hb_buffer_add_utf16 (hb_buffer_t    *buffer,
132                      const uint16_t *text,
133                      unsigned int    text_length,
134                      unsigned int    item_offset,
135                      unsigned int    item_length);
136
137 void
138 hb_buffer_add_utf32 (hb_buffer_t    *buffer,
139                      const uint32_t *text,
140                      unsigned int    text_length,
141                      unsigned int    item_offset,
142                      unsigned int    item_length);
143
144
145 /* Getting glyphs out of the buffer */
146
147 /* Return value valid as long as buffer not modified */
148 unsigned int
149 hb_buffer_get_len (hb_buffer_t *buffer);
150
151 /* Return value valid as long as buffer not modified */
152 hb_glyph_info_t *
153 hb_buffer_get_glyph_infos (hb_buffer_t *buffer);
154
155 /* Return value valid as long as buffer not modified */
156 hb_glyph_position_t *
157 hb_buffer_get_glyph_positions (hb_buffer_t *buffer);
158
159
160 HB_END_DECLS
161
162 #endif /* HB_BUFFER_H */