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