hb-buffer.h 4.4 KB
Newer Older
1
/*
B
Behdad Esfahbod 已提交
2 3 4
 * Copyright © 1998-2004  David Turner and Werner Lemberg
 * Copyright © 2004,2007,2009  Red Hat, Inc.
 * Copyright © 2011  Google, Inc.
5
 *
6
 *  This is part of HarfBuzz, a text shaping library.
7
 *
8 9 10 11 12
 * Permission is hereby granted, without written agreement and without
 * license or royalty fees, to use, copy, modify, and distribute this
 * software and its documentation for any purpose, provided that the
 * above copyright notice and the following two paragraphs appear in
 * all copies of this software.
13
 *
14 15 16 17 18 19 20 21 22 23 24 25 26
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 *
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
27
 * Google Author(s): Behdad Esfahbod
28
 */
29

30 31
#ifndef HB_BUFFER_H
#define HB_BUFFER_H
32

33
#include "hb-common.h"
B
Behdad Esfahbod 已提交
34
#include "hb-unicode.h"
35

B
Behdad Esfahbod 已提交
36
HB_BEGIN_DECLS
37

B
Behdad Esfahbod 已提交
38

39 40
typedef struct _hb_buffer_t hb_buffer_t;

B
Behdad Esfahbod 已提交
41
typedef struct _hb_glyph_info_t {
42
  hb_codepoint_t codepoint;
43
  hb_mask_t      mask;
44
  uint32_t       cluster;
45 46

  /*< private >*/
B
Behdad Esfahbod 已提交
47 48
  hb_var_int_t   var1;
  hb_var_int_t   var2;
B
Behdad Esfahbod 已提交
49
} hb_glyph_info_t;
50

B
Behdad Esfahbod 已提交
51
typedef struct _hb_glyph_position_t {
52 53
  hb_position_t  x_advance;
  hb_position_t  y_advance;
54 55
  hb_position_t  x_offset;
  hb_position_t  y_offset;
56 57

  /*< private >*/
58
  hb_var_int_t   var;
B
Behdad Esfahbod 已提交
59
} hb_glyph_position_t;
60 61


62 63
hb_buffer_t *
hb_buffer_create (unsigned int pre_alloc_size);
64

65 66
hb_buffer_t *
hb_buffer_reference (hb_buffer_t *buffer);
67

68 69
void
hb_buffer_destroy (hb_buffer_t *buffer);
70 71


B
Behdad Esfahbod 已提交
72 73 74 75 76 77 78
void
hb_buffer_set_unicode_funcs (hb_buffer_t        *buffer,
			     hb_unicode_funcs_t *unicode_funcs);

hb_unicode_funcs_t *
hb_buffer_get_unicode_funcs (hb_buffer_t        *buffer);

79
void
80 81 82 83 84 85
hb_buffer_set_direction (hb_buffer_t    *buffer,
			 hb_direction_t  direction);

hb_direction_t
hb_buffer_get_direction (hb_buffer_t *buffer);

86 87 88 89 90 91 92 93 94 95 96 97 98
void
hb_buffer_set_script (hb_buffer_t *buffer,
		      hb_script_t  script);

hb_script_t
hb_buffer_get_script (hb_buffer_t *buffer);

void
hb_buffer_set_language (hb_buffer_t   *buffer,
			hb_language_t  language);

hb_language_t
hb_buffer_get_language (hb_buffer_t *buffer);
99

B
Behdad Esfahbod 已提交
100

101 102 103 104 105
/* Resets the buffer.  Afterwards it's as if it was just created,
 * except that it has a larger buffer allocated perhaps... */
void
hb_buffer_reset (hb_buffer_t *buffer);

106
/* Returns FALSE if allocation failed */
107
hb_bool_t
108 109
hb_buffer_pre_allocate (hb_buffer_t  *buffer,
		        unsigned int  size);
B
Behdad Esfahbod 已提交
110

111 112 113 114 115

/* Returns FALSE if allocation has failed before */
hb_bool_t
hb_buffer_allocation_successful (hb_buffer_t  *buffer);

B
Behdad Esfahbod 已提交
116 117 118
void
hb_buffer_reverse (hb_buffer_t *buffer);

119 120 121
void
hb_buffer_reverse_clusters (hb_buffer_t *buffer);

B
Behdad Esfahbod 已提交
122 123

/* Filling the buffer in */
124

125
void
126 127 128 129
hb_buffer_add (hb_buffer_t    *buffer,
	       hb_codepoint_t  codepoint,
	       hb_mask_t       mask,
	       unsigned int    cluster);
130

B
Behdad Esfahbod 已提交
131 132 133
void
hb_buffer_add_utf8 (hb_buffer_t  *buffer,
		    const char   *text,
134
		    unsigned int  text_length,
B
Behdad Esfahbod 已提交
135
		    unsigned int  item_offset,
136
		    unsigned int  item_length);
B
Behdad Esfahbod 已提交
137 138 139 140

void
hb_buffer_add_utf16 (hb_buffer_t    *buffer,
		     const uint16_t *text,
141
		     unsigned int    text_length,
B
Behdad Esfahbod 已提交
142
		     unsigned int    item_offset,
143
		     unsigned int    item_length);
B
Behdad Esfahbod 已提交
144 145 146 147

void
hb_buffer_add_utf32 (hb_buffer_t    *buffer,
		     const uint32_t *text,
148
		     unsigned int    text_length,
B
Behdad Esfahbod 已提交
149
		     unsigned int    item_offset,
150
		     unsigned int    item_length);
B
Behdad Esfahbod 已提交
151

152

153 154 155 156
/* Clears any new items added at the end */
hb_bool_t
hb_buffer_set_length (hb_buffer_t  *buffer,
		      unsigned int  length);
B
Behdad Esfahbod 已提交
157

158 159
/* Return value valid as long as buffer not modified */
unsigned int
160
hb_buffer_get_length (hb_buffer_t *buffer);
161

162 163
/* Getting glyphs out of the buffer */

164 165
/* Return value valid as long as buffer not modified */
hb_glyph_info_t *
166 167
hb_buffer_get_glyph_infos (hb_buffer_t  *buffer,
                           unsigned int *length);
168 169 170

/* Return value valid as long as buffer not modified */
hb_glyph_position_t *
171 172
hb_buffer_get_glyph_positions (hb_buffer_t  *buffer,
                               unsigned int *length);
B
Behdad Esfahbod 已提交
173 174


B
Behdad Esfahbod 已提交
175
HB_END_DECLS
176

177
#endif /* HB_BUFFER_H */