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 32 33
#ifndef HB_H_IN
#error "Include <hb.h> instead."
#endif

34 35
#ifndef HB_BUFFER_H
#define HB_BUFFER_H
36

37
#include "hb-common.h"
B
Behdad Esfahbod 已提交
38
#include "hb-unicode.h"
39

B
Behdad Esfahbod 已提交
40
HB_BEGIN_DECLS
41

B
Behdad Esfahbod 已提交
42

43 44
typedef struct _hb_buffer_t hb_buffer_t;

B
Behdad Esfahbod 已提交
45
typedef struct _hb_glyph_info_t {
46
  hb_codepoint_t codepoint;
47
  hb_mask_t      mask;
48
  uint32_t       cluster;
49 50

  /*< private >*/
B
Behdad Esfahbod 已提交
51 52
  hb_var_int_t   var1;
  hb_var_int_t   var2;
B
Behdad Esfahbod 已提交
53
} hb_glyph_info_t;
54

B
Behdad Esfahbod 已提交
55
typedef struct _hb_glyph_position_t {
56 57
  hb_position_t  x_advance;
  hb_position_t  y_advance;
58 59
  hb_position_t  x_offset;
  hb_position_t  y_offset;
60 61

  /*< private >*/
62
  hb_var_int_t   var;
B
Behdad Esfahbod 已提交
63
} hb_glyph_position_t;
64 65


66
hb_buffer_t *
67
hb_buffer_create (void);
68

69 70 71
hb_buffer_t *
hb_buffer_get_empty (void);

72 73
hb_buffer_t *
hb_buffer_reference (hb_buffer_t *buffer);
74

75 76
void
hb_buffer_destroy (hb_buffer_t *buffer);
77

78 79 80 81
hb_bool_t
hb_buffer_set_user_data (hb_buffer_t        *buffer,
			 hb_user_data_key_t *key,
			 void *              data,
82 83
			 hb_destroy_func_t   destroy,
			 hb_bool_t           replace);
84 85 86 87 88

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

89

B
Behdad Esfahbod 已提交
90 91 92 93 94 95 96
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);

97
void
98 99 100 101 102 103
hb_buffer_set_direction (hb_buffer_t    *buffer,
			 hb_direction_t  direction);

hb_direction_t
hb_buffer_get_direction (hb_buffer_t *buffer);

104 105 106 107 108 109 110 111 112 113 114 115 116
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);
117

B
Behdad Esfahbod 已提交
118

119 120 121 122 123
/* 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);

124
/* Returns false if allocation failed */
125
hb_bool_t
126 127
hb_buffer_pre_allocate (hb_buffer_t  *buffer,
		        unsigned int  size);
B
Behdad Esfahbod 已提交
128

129

130
/* Returns false if allocation has failed before */
131 132 133
hb_bool_t
hb_buffer_allocation_successful (hb_buffer_t  *buffer);

B
Behdad Esfahbod 已提交
134 135 136
void
hb_buffer_reverse (hb_buffer_t *buffer);

137 138 139
void
hb_buffer_reverse_clusters (hb_buffer_t *buffer);

140 141 142
void
hb_buffer_guess_properties (hb_buffer_t *buffer);

B
Behdad Esfahbod 已提交
143 144

/* Filling the buffer in */
145

146
void
147 148 149 150
hb_buffer_add (hb_buffer_t    *buffer,
	       hb_codepoint_t  codepoint,
	       hb_mask_t       mask,
	       unsigned int    cluster);
151

B
Behdad Esfahbod 已提交
152 153 154
void
hb_buffer_add_utf8 (hb_buffer_t  *buffer,
		    const char   *text,
155
		    int           text_length,
B
Behdad Esfahbod 已提交
156
		    unsigned int  item_offset,
157
		    int           item_length);
B
Behdad Esfahbod 已提交
158 159 160 161

void
hb_buffer_add_utf16 (hb_buffer_t    *buffer,
		     const uint16_t *text,
162
		     int             text_length,
B
Behdad Esfahbod 已提交
163
		     unsigned int    item_offset,
164
		     int             item_length);
B
Behdad Esfahbod 已提交
165 166 167 168

void
hb_buffer_add_utf32 (hb_buffer_t    *buffer,
		     const uint32_t *text,
169
		     int             text_length,
B
Behdad Esfahbod 已提交
170
		     unsigned int    item_offset,
171
		     int             item_length);
B
Behdad Esfahbod 已提交
172

173

174 175 176 177
/* 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 已提交
178

179 180
/* Return value valid as long as buffer not modified */
unsigned int
181
hb_buffer_get_length (hb_buffer_t *buffer);
182

183 184
/* Getting glyphs out of the buffer */

185 186
/* Return value valid as long as buffer not modified */
hb_glyph_info_t *
187 188
hb_buffer_get_glyph_infos (hb_buffer_t  *buffer,
                           unsigned int *length);
189 190 191

/* Return value valid as long as buffer not modified */
hb_glyph_position_t *
192 193
hb_buffer_get_glyph_positions (hb_buffer_t  *buffer,
                               unsigned int *length);
B
Behdad Esfahbod 已提交
194 195


B
Behdad Esfahbod 已提交
196
HB_END_DECLS
197

198
#endif /* HB_BUFFER_H */