hb-buffer.h 4.8 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 67
hb_buffer_t *
hb_buffer_get_empty (void);

68 69
hb_buffer_t *
hb_buffer_reference (hb_buffer_t *buffer);
70

71 72
void
hb_buffer_destroy (hb_buffer_t *buffer);
73

74 75 76 77 78 79 80 81 82 83
hb_bool_t
hb_buffer_set_user_data (hb_buffer_t        *buffer,
			 hb_user_data_key_t *key,
			 void *              data,
			 hb_destroy_func_t   destroy);

void *
hb_buffer_get_user_data (hb_buffer_t        *buffer,
			 hb_user_data_key_t *key);

84

B
Behdad Esfahbod 已提交
85 86 87 88 89 90 91
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);

92
void
93 94 95 96 97 98
hb_buffer_set_direction (hb_buffer_t    *buffer,
			 hb_direction_t  direction);

hb_direction_t
hb_buffer_get_direction (hb_buffer_t *buffer);

99 100 101 102 103 104 105 106 107 108 109 110 111
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);
112

B
Behdad Esfahbod 已提交
113

114 115 116 117 118
/* 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);

119
/* Returns FALSE if allocation failed */
120
hb_bool_t
121 122
hb_buffer_pre_allocate (hb_buffer_t  *buffer,
		        unsigned int  size);
B
Behdad Esfahbod 已提交
123

124 125 126 127 128

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

B
Behdad Esfahbod 已提交
129 130 131
void
hb_buffer_reverse (hb_buffer_t *buffer);

132 133 134
void
hb_buffer_reverse_clusters (hb_buffer_t *buffer);

135 136 137
void
hb_buffer_guess_properties (hb_buffer_t *buffer);

B
Behdad Esfahbod 已提交
138 139

/* Filling the buffer in */
140

141
void
142 143 144 145
hb_buffer_add (hb_buffer_t    *buffer,
	       hb_codepoint_t  codepoint,
	       hb_mask_t       mask,
	       unsigned int    cluster);
146

B
Behdad Esfahbod 已提交
147 148 149
void
hb_buffer_add_utf8 (hb_buffer_t  *buffer,
		    const char   *text,
150
		    unsigned int  text_length,
B
Behdad Esfahbod 已提交
151
		    unsigned int  item_offset,
152
		    unsigned int  item_length);
B
Behdad Esfahbod 已提交
153 154 155 156

void
hb_buffer_add_utf16 (hb_buffer_t    *buffer,
		     const uint16_t *text,
157
		     unsigned int    text_length,
B
Behdad Esfahbod 已提交
158
		     unsigned int    item_offset,
159
		     unsigned int    item_length);
B
Behdad Esfahbod 已提交
160 161 162 163

void
hb_buffer_add_utf32 (hb_buffer_t    *buffer,
		     const uint32_t *text,
164
		     unsigned int    text_length,
B
Behdad Esfahbod 已提交
165
		     unsigned int    item_offset,
166
		     unsigned int    item_length);
B
Behdad Esfahbod 已提交
167

168

169 170 171 172
/* 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 已提交
173

174 175
/* Return value valid as long as buffer not modified */
unsigned int
176
hb_buffer_get_length (hb_buffer_t *buffer);
177

178 179
/* Getting glyphs out of the buffer */

180 181
/* Return value valid as long as buffer not modified */
hb_glyph_info_t *
182 183
hb_buffer_get_glyph_infos (hb_buffer_t  *buffer,
                           unsigned int *length);
184 185 186

/* Return value valid as long as buffer not modified */
hb_glyph_position_t *
187 188
hb_buffer_get_glyph_positions (hb_buffer_t  *buffer,
                               unsigned int *length);
B
Behdad Esfahbod 已提交
189 190


B
Behdad Esfahbod 已提交
191
HB_END_DECLS
192

193
#endif /* HB_BUFFER_H */