blob: a5efce3543aafdccab75a927aaef7e471a7724f0 [file] [log] [blame]
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00001/*
Behdad Esfahbod2409d5f2011-04-21 17:14:28 -04002 * Copyright © 1998-2004 David Turner and Werner Lemberg
3 * Copyright © 2004,2007,2009 Red Hat, Inc.
4 * Copyright © 2011 Google, Inc.
Behdad Esfahbod9f8da382006-03-31 12:28:09 +00005 *
Behdad Esfahbod8f0d7e02011-04-15 18:59:56 -04006 * This is part of HarfBuzz, a text shaping library.
Behdad Esfahbod9f8da382006-03-31 12:28:09 +00007 *
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00008 * Permission is hereby granted, without written agreement and without
9 * license or royalty fees, to use, copy, modify, and distribute this
10 * software and its documentation for any purpose, provided that the
11 * above copyright notice and the following two paragraphs appear in
12 * all copies of this software.
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000013 *
Behdad Esfahboda2a9a022008-01-15 22:46:32 +000014 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
15 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
17 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * DAMAGE.
19 *
20 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
21 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
23 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
24 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25 *
26 * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
Behdad Esfahbodc910bec2011-04-13 15:49:06 -040027 * Google Author(s): Behdad Esfahbod
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000028 */
Behdad Esfahboda2a9a022008-01-15 22:46:32 +000029
Behdad Esfahbod5c0adce2009-05-20 05:42:12 -040030#ifndef HB_BUFFER_H
31#define HB_BUFFER_H
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000032
Behdad Esfahbodb857b492009-05-20 05:35:14 -040033#include "hb-common.h"
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050034#include "hb-unicode.h"
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000035
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -040036HB_BEGIN_DECLS
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000037
Behdad Esfahbodacdba3f2010-07-23 15:11:18 -040038
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040039typedef struct _hb_buffer_t hb_buffer_t;
40
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040041typedef struct _hb_glyph_info_t {
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040042 hb_codepoint_t codepoint;
Behdad Esfahbod468769b2009-08-08 16:53:23 -040043 hb_mask_t mask;
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040044 uint32_t cluster;
Behdad Esfahbodb54cd072011-04-15 19:12:01 -040045
46 /*< private >*/
Behdad Esfahbod6cb8c342010-10-27 14:27:03 -040047 hb_var_int_t var1;
48 hb_var_int_t var2;
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040049} hb_glyph_info_t;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000050
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040051typedef struct _hb_glyph_position_t {
Behdad Esfahbodb857b492009-05-20 05:35:14 -040052 hb_position_t x_advance;
53 hb_position_t y_advance;
Behdad Esfahbod9bef3612009-11-05 12:20:11 -050054 hb_position_t x_offset;
55 hb_position_t y_offset;
Behdad Esfahbodb54cd072011-04-15 19:12:01 -040056
57 /*< private >*/
Behdad Esfahbod88474c62010-10-27 14:42:15 -040058 hb_var_int_t var;
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040059} hb_glyph_position_t;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000060
61
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040062hb_buffer_t *
63hb_buffer_create (unsigned int pre_alloc_size);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000064
Behdad Esfahbodb857b492009-05-20 05:35:14 -040065hb_buffer_t *
Behdad Esfahbod80a68332011-05-11 18:14:44 -040066hb_buffer_get_empty (void);
67
68hb_buffer_t *
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040069hb_buffer_reference (hb_buffer_t *buffer);
70
Behdad Esfahboda8abb8b2007-10-11 00:07:58 +000071void
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040072hb_buffer_destroy (hb_buffer_t *buffer);
73
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -040074hb_bool_t
75hb_buffer_set_user_data (hb_buffer_t *buffer,
76 hb_user_data_key_t *key,
77 void * data,
Behdad Esfahbod33ccc772011-08-09 00:43:24 +020078 hb_destroy_func_t destroy,
79 hb_bool_t replace);
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -040080
81void *
82hb_buffer_get_user_data (hb_buffer_t *buffer,
83 hb_user_data_key_t *key);
84
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040085
86void
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050087hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
88 hb_unicode_funcs_t *unicode_funcs);
89
90hb_unicode_funcs_t *
91hb_buffer_get_unicode_funcs (hb_buffer_t *buffer);
92
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050093void
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040094hb_buffer_set_direction (hb_buffer_t *buffer,
95 hb_direction_t direction);
96
97hb_direction_t
98hb_buffer_get_direction (hb_buffer_t *buffer);
99
Behdad Esfahbodae070b72009-11-04 20:29:54 -0500100void
101hb_buffer_set_script (hb_buffer_t *buffer,
102 hb_script_t script);
103
104hb_script_t
105hb_buffer_get_script (hb_buffer_t *buffer);
106
107void
108hb_buffer_set_language (hb_buffer_t *buffer,
109 hb_language_t language);
110
111hb_language_t
112hb_buffer_get_language (hb_buffer_t *buffer);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000113
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -0500114
Behdad Esfahbodc910bec2011-04-13 15:49:06 -0400115/* Resets the buffer. Afterwards it's as if it was just created,
116 * except that it has a larger buffer allocated perhaps... */
117void
118hb_buffer_reset (hb_buffer_t *buffer);
119
Behdad Esfahbodaab0de52011-04-19 00:32:19 -0400120/* Returns FALSE if allocation failed */
Behdad Esfahboda6a79df2010-05-14 23:20:16 -0400121hb_bool_t
Ryan Lortie02a534b2011-04-15 18:34:45 -0400122hb_buffer_pre_allocate (hb_buffer_t *buffer,
123 unsigned int size);
Behdad Esfahbodf9cd1012009-07-28 15:43:34 -0400124
Behdad Esfahbodaab0de52011-04-19 00:32:19 -0400125
126/* Returns FALSE if allocation has failed before */
127hb_bool_t
128hb_buffer_allocation_successful (hb_buffer_t *buffer);
129
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400130void
131hb_buffer_reverse (hb_buffer_t *buffer);
132
Behdad Esfahbodff44f882009-11-06 19:48:16 -0500133void
134hb_buffer_reverse_clusters (hb_buffer_t *buffer);
135
Behdad Esfahbod02aeca92011-08-04 22:31:05 -0400136void
137hb_buffer_guess_properties (hb_buffer_t *buffer);
138
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400139
140/* Filling the buffer in */
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400141
Behdad Esfahbodf9cd1012009-07-28 15:43:34 -0400142void
Behdad Esfahbodf85faee2011-04-19 00:38:01 -0400143hb_buffer_add (hb_buffer_t *buffer,
144 hb_codepoint_t codepoint,
145 hb_mask_t mask,
146 unsigned int cluster);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000147
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400148void
149hb_buffer_add_utf8 (hb_buffer_t *buffer,
150 const char *text,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200151 int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400152 unsigned int item_offset,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200153 int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400154
155void
156hb_buffer_add_utf16 (hb_buffer_t *buffer,
157 const uint16_t *text,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200158 int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400159 unsigned int item_offset,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200160 int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400161
162void
163hb_buffer_add_utf32 (hb_buffer_t *buffer,
164 const uint32_t *text,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200165 int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400166 unsigned int item_offset,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200167 int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400168
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400169
Behdad Esfahbodc910bec2011-04-13 15:49:06 -0400170/* Clears any new items added at the end */
171hb_bool_t
172hb_buffer_set_length (hb_buffer_t *buffer,
173 unsigned int length);
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400174
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400175/* Return value valid as long as buffer not modified */
176unsigned int
Behdad Esfahbod3d145282009-11-06 15:13:17 -0500177hb_buffer_get_length (hb_buffer_t *buffer);
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400178
Behdad Esfahbodc910bec2011-04-13 15:49:06 -0400179/* Getting glyphs out of the buffer */
180
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400181/* Return value valid as long as buffer not modified */
182hb_glyph_info_t *
Ryan Lortie70566be2011-04-15 18:32:36 -0400183hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
184 unsigned int *length);
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400185
186/* Return value valid as long as buffer not modified */
187hb_glyph_position_t *
Ryan Lortie70566be2011-04-15 18:32:36 -0400188hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
189 unsigned int *length);
Behdad Esfahbod02a37062009-07-29 18:41:25 -0400190
191
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -0400192HB_END_DECLS
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000193
Behdad Esfahbod5c0adce2009-05-20 05:42:12 -0400194#endif /* HB_BUFFER_H */