Start ft glue
[framework/uifw/harfbuzz.git] / src / hb-buffer-private.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_PRIVATE_H
29 #define HB_BUFFER_PRIVATE_H
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_pos;
51   hb_position_t  y_pos;
52   hb_position_t  x_advance;
53   hb_position_t  y_advance;
54   uint32_t       new_advance :1;        /* if set, the advance width values are
55                                            absolute, i.e., they won't be
56                                            added to the original glyph's value
57                                            but rather replace them */
58   uint32_t       back : 15;             /* number of glyphs to go back
59                                            for drawing current glyph */
60   int32_t        cursive_chain : 16;    /* character to which this connects,
61                                            may be positive or negative; used
62                                            only internally */
63 } hb_internal_glyph_position_t;
64
65 ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t));
66 ASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t));
67 ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
68
69
70 struct _hb_buffer_t {
71   hb_reference_count_t ref_count;
72
73   /* Information about how the text in the buffer should be treated */
74
75   hb_unicode_funcs_t *unicode;
76   hb_direction_t       direction;
77
78
79   /* Buffer contents */
80
81   unsigned int allocated;
82
83   hb_bool_t    have_output; /* weather we have an output buffer going on */
84   unsigned int in_length;
85   unsigned int out_length;
86   unsigned int in_pos;
87   unsigned int out_pos; /* out_length and out_pos are actually always the same */
88
89   hb_internal_glyph_info_t     *in_string;
90   hb_internal_glyph_info_t     *out_string;
91   hb_internal_glyph_position_t *positions;
92
93   /* Other stuff */
94
95   unsigned int         max_lig_id;
96 };
97
98
99 HB_INTERNAL void
100 _hb_buffer_swap (hb_buffer_t *buffer);
101
102 HB_INTERNAL void
103 _hb_buffer_clear_output (hb_buffer_t *buffer);
104
105 HB_INTERNAL void
106 _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
107                               unsigned int num_in,
108                               unsigned int num_out,
109                               const uint16_t *glyph_data_be,
110                               unsigned short component,
111                               unsigned short ligID);
112
113 HB_INTERNAL void
114 _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
115                              hb_codepoint_t glyph_index,
116                              unsigned short component,
117                              unsigned short ligID);
118
119 HB_INTERNAL void
120 _hb_buffer_next_glyph (hb_buffer_t *buffer);
121
122 HB_INTERNAL void
123 _hb_buffer_replace_glyph (hb_buffer_t *buffer,
124                           hb_codepoint_t glyph_index);
125
126 HB_INTERNAL unsigned short
127 _hb_buffer_allocate_lig_id (hb_buffer_t *buffer);
128
129
130 /* convenience macros */
131 #define IN_GLYPH(pos)           (buffer->in_string[(pos)].codepoint)
132 #define IN_INFO(pos)            (&buffer->in_string[(pos)])
133 #define IN_CURGLYPH()           (buffer->in_string[buffer->in_pos].codepoint)
134 #define IN_CURINFO()            (&buffer->in_string[buffer->in_pos])
135 #define IN_MASK(pos)            (buffer->in_string[(pos)].mask)
136 #define IN_LIGID(pos)           (buffer->in_string[(pos)].lig_id)
137 #define IN_COMPONENT(pos)       (buffer->in_string[(pos)].component)
138 #define POSITION(pos)           (&buffer->positions[(pos)])
139 #define CURPOSITION()           (&buffer->positions[buffer->in_pos])
140 #define OUT_GLYPH(pos)          (buffer->out_string[(pos)].codepoint)
141 #define OUT_INFO(pos)           (&buffer->out_string[(pos)])
142
143 HB_END_DECLS
144
145 #endif /* HB_BUFFER_PRIVATE_H */