blob: d5cb74686184a051b040e4e87e07bd64a0856fd8 [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.
Behdad Esfahbod05207a72012-09-25 17:44:53 -04004 * Copyright © 2011,2012 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 Esfahbodd1c9eb42012-04-12 13:17:44 -040030#ifndef HB_H_IN
31#error "Include <hb.h> instead."
32#endif
33
Behdad Esfahbod5c0adce2009-05-20 05:42:12 -040034#ifndef HB_BUFFER_H
35#define HB_BUFFER_H
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000036
Behdad Esfahbodb857b492009-05-20 05:35:14 -040037#include "hb-common.h"
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050038#include "hb-unicode.h"
Behdad Esfahbodf9edf162012-11-15 12:14:09 -080039#include "hb-font.h"
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000040
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -040041HB_BEGIN_DECLS
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000042
Khaled Hosnyfb192c22015-12-30 15:05:50 +040043/**
44 * hb_glyph_info_t:
45 * @codepoint: either a Unicode code point (before shaping) or a glyph index
46 * (after shaping).
Khaled Hosnyfb192c22015-12-30 15:05:50 +040047 * @cluster: the index of the character in the original text that corresponds
48 * to this #hb_glyph_info_t, or whatever the client passes to
49 * hb_buffer_add(). More than one #hb_glyph_info_t can have the same
50 * @cluster value, if they resulted from the same character (e.g. one
51 * to many glyph substitution), and when more than one character gets
52 * merged in the same glyph (e.g. many to one glyph substitution) the
Behdad Esfahbod97624d92016-01-11 12:58:45 +000053 * #hb_glyph_info_t will have the smallest cluster value of them.
54 * By default some characters are merged into the same cluster
55 * (e.g. combining marks have the same cluster as their bases)
56 * even if they are separate glyphs, hb_buffer_set_cluster_level()
57 * allow selecting more fine-grained cluster handling.
Khaled Hosnyfb192c22015-12-30 15:05:50 +040058 *
Khaled Hosny9ab9f972016-01-01 20:38:21 +040059 * The #hb_glyph_info_t is the structure that holds information about the
Khaled Hosnyfb192c22015-12-30 15:05:50 +040060 * glyphs and their relation to input text.
Khaled Hosnyfb192c22015-12-30 15:05:50 +040061 */
Behdad Esfahbod55bae682018-09-24 10:43:06 -040062typedef struct hb_glyph_info_t
63{
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040064 hb_codepoint_t codepoint;
Behdad Esfahbod1dd1e562018-09-30 18:25:58 +020065 /*< private >*/
Behdad Esfahbod55bae682018-09-24 10:43:06 -040066 hb_mask_t mask;
Behdad Esfahbod1dd1e562018-09-30 18:25:58 +020067 /*< public >*/
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040068 uint32_t cluster;
Behdad Esfahbodb54cd072011-04-15 19:12:01 -040069
70 /*< private >*/
Behdad Esfahbod6cb8c342010-10-27 14:27:03 -040071 hb_var_int_t var1;
72 hb_var_int_t var2;
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040073} hb_glyph_info_t;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000074
bungeman671f0a72018-02-01 13:31:25 -050075/**
76 * hb_glyph_flags_t:
Behdad Esfahbod3b7aa652018-02-09 15:43:20 -060077 * @HB_GLYPH_FLAG_UNSAFE_TO_BREAK: Indicates that if input text is broken at the
78 * beginning of the cluster this glyph is part of,
79 * then both sides need to be re-shaped, as the
80 * result might be different. On the flip side,
81 * it means that when this flag is not present,
82 * then it's safe to break the glyph-run at the
83 * beginning of this cluster, and the two sides
84 * represent the exact same result one would get
85 * if breaking input text at the beginning of
Behdad Esfahbodd45f2402018-02-09 15:51:45 -060086 * this cluster and shaping the two sides
Behdad Esfahbod3b7aa652018-02-09 15:43:20 -060087 * separately. This can be used to optimize
88 * paragraph layout, by avoiding re-shaping
89 * of each line after line-breaking, or limiting
90 * the reshaping to a small piece around the
91 * breaking point only.
Behdad Esfahbod1e398332018-10-20 16:56:06 -070092 * @HB_GLYPH_FLAG_DEFINED: All the currently defined flags.
Behdad Esfahbod1a2eb102018-11-19 12:36:56 -050093 *
94 * Since: 1.5.0
bungeman671f0a72018-02-01 13:31:25 -050095 */
Behdad Esfahbod40bd7e92016-05-02 14:47:45 +020096typedef enum { /*< flags >*/
Behdad Esfahbod5287ccc2017-08-10 14:25:53 -070097 HB_GLYPH_FLAG_UNSAFE_TO_BREAK = 0x00000001,
98
Behdad Esfahbod1e398332018-10-20 16:56:06 -070099 HB_GLYPH_FLAG_DEFINED = 0x00000001 /* OR of all defined flags */
Behdad Esfahbod40bd7e92016-05-02 14:47:45 +0200100} hb_glyph_flags_t;
101
Behdad Esfahbodb2dd0c12017-08-23 13:12:54 -0700102HB_EXTERN hb_glyph_flags_t
103hb_glyph_info_get_glyph_flags (const hb_glyph_info_t *info);
104
105#define hb_glyph_info_get_glyph_flags(info) \
106 ((hb_glyph_flags_t) ((unsigned int) (info)->mask & HB_GLYPH_FLAG_DEFINED))
107
108
Khaled Hosnyfb192c22015-12-30 15:05:50 +0400109/**
110 * hb_glyph_position_t:
111 * @x_advance: how much the line advances after drawing this glyph when setting
112 * text in horizontal direction.
113 * @y_advance: how much the line advances after drawing this glyph when setting
114 * text in vertical direction.
115 * @x_offset: how much the glyph moves on the X-axis before drawing it, this
116 * should not affect how much the line advances.
117 * @y_offset: how much the glyph moves on the Y-axis before drawing it, this
118 * should not affect how much the line advances.
119 *
120 * The #hb_glyph_position_t is the structure that holds the positions of the
121 * glyph in both horizontal and vertical directions. All positions in
122 * #hb_glyph_position_t are relative to the current point.
123 *
124 */
Behdad Esfahbod1bc1cb32012-06-16 15:21:55 -0400125typedef struct hb_glyph_position_t {
Behdad Esfahbodb857b492009-05-20 05:35:14 -0400126 hb_position_t x_advance;
127 hb_position_t y_advance;
Behdad Esfahbod9bef3612009-11-05 12:20:11 -0500128 hb_position_t x_offset;
129 hb_position_t y_offset;
Behdad Esfahbodb54cd072011-04-15 19:12:01 -0400130
131 /*< private >*/
Behdad Esfahbod88474c62010-10-27 14:42:15 -0400132 hb_var_int_t var;
Behdad Esfahbodc968fc22009-05-25 04:04:24 -0400133} hb_glyph_position_t;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000134
Khaled Hosny9ab9f972016-01-01 20:38:21 +0400135/**
136 * hb_segment_properties_t:
137 * @direction: the #hb_direction_t of the buffer, see hb_buffer_set_direction().
138 * @script: the #hb_script_t of the buffer, see hb_buffer_set_script().
139 * @language: the #hb_language_t of the buffer, see hb_buffer_set_language().
140 *
141 * The structure that holds various text properties of an #hb_buffer_t. Can be
142 * set and retrieved using hb_buffer_set_segment_properties() and
143 * hb_buffer_get_segment_properties(), respectively.
144 */
Behdad Esfahbodf3064102012-11-15 18:39:46 -0800145typedef struct hb_segment_properties_t {
146 hb_direction_t direction;
147 hb_script_t script;
148 hb_language_t language;
149 /*< private >*/
150 void *reserved1;
151 void *reserved2;
152} hb_segment_properties_t;
153
154#define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \
155 HB_SCRIPT_INVALID, \
156 HB_LANGUAGE_INVALID, \
Behdad Esfahbodfbb937b2017-10-15 12:04:16 +0200157 (void *) 0, \
158 (void *) 0}
Behdad Esfahbodf3064102012-11-15 18:39:46 -0800159
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800160HB_EXTERN hb_bool_t
Behdad Esfahbodf3064102012-11-15 18:39:46 -0800161hb_segment_properties_equal (const hb_segment_properties_t *a,
162 const hb_segment_properties_t *b);
163
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800164HB_EXTERN unsigned int
Behdad Esfahbodf3064102012-11-15 18:39:46 -0800165hb_segment_properties_hash (const hb_segment_properties_t *p);
166
167
168
Khaled Hosny9ab9f972016-01-01 20:38:21 +0400169/**
170 * hb_buffer_t:
171 *
172 * The main structure holding the input text and its properties before shaping,
173 * and output glyphs and their information after shaping.
Behdad Esfahbodf3064102012-11-15 18:39:46 -0800174 */
175
176typedef struct hb_buffer_t hb_buffer_t;
177
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800178HB_EXTERN hb_buffer_t *
Behdad Esfahbode6c09cd2011-08-17 19:07:59 +0200179hb_buffer_create (void);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000180
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800181HB_EXTERN hb_buffer_t *
Behdad Esfahbod80a68332011-05-11 18:14:44 -0400182hb_buffer_get_empty (void);
183
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800184HB_EXTERN hb_buffer_t *
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400185hb_buffer_reference (hb_buffer_t *buffer);
186
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800187HB_EXTERN void
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400188hb_buffer_destroy (hb_buffer_t *buffer);
189
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800190HB_EXTERN hb_bool_t
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -0400191hb_buffer_set_user_data (hb_buffer_t *buffer,
192 hb_user_data_key_t *key,
193 void * data,
Behdad Esfahbod33ccc772011-08-09 00:43:24 +0200194 hb_destroy_func_t destroy,
195 hb_bool_t replace);
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -0400196
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800197HB_EXTERN void *
Behdad Esfahbod5fa849b2011-04-27 21:46:01 -0400198hb_buffer_get_user_data (hb_buffer_t *buffer,
199 hb_user_data_key_t *key);
200
Behdad Esfahbod39a97492017-08-11 15:52:06 -0700201
Khaled Hosny8ab797c2015-12-29 17:42:16 +0400202/**
203 * hb_buffer_content_type_t:
204 * @HB_BUFFER_CONTENT_TYPE_INVALID: Initial value for new buffer.
205 * @HB_BUFFER_CONTENT_TYPE_UNICODE: The buffer contains input characters (before shaping).
206 * @HB_BUFFER_CONTENT_TYPE_GLYPHS: The buffer contains output glyphs (after shaping).
207 */
Behdad Esfahbod92f9bfe2012-11-13 16:50:45 -0800208typedef enum {
209 HB_BUFFER_CONTENT_TYPE_INVALID = 0,
210 HB_BUFFER_CONTENT_TYPE_UNICODE,
211 HB_BUFFER_CONTENT_TYPE_GLYPHS
212} hb_buffer_content_type_t;
213
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800214HB_EXTERN void
Behdad Esfahbod96fdc042012-09-06 22:26:16 -0400215hb_buffer_set_content_type (hb_buffer_t *buffer,
216 hb_buffer_content_type_t content_type);
217
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800218HB_EXTERN hb_buffer_content_type_t
Behdad Esfahbod96fdc042012-09-06 22:26:16 -0400219hb_buffer_get_content_type (hb_buffer_t *buffer);
220
221
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800222HB_EXTERN void
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -0500223hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
224 hb_unicode_funcs_t *unicode_funcs);
225
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800226HB_EXTERN hb_unicode_funcs_t *
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -0500227hb_buffer_get_unicode_funcs (hb_buffer_t *buffer);
228
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800229HB_EXTERN void
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400230hb_buffer_set_direction (hb_buffer_t *buffer,
231 hb_direction_t direction);
232
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800233HB_EXTERN hb_direction_t
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400234hb_buffer_get_direction (hb_buffer_t *buffer);
235
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800236HB_EXTERN void
Behdad Esfahbodae070b72009-11-04 20:29:54 -0500237hb_buffer_set_script (hb_buffer_t *buffer,
238 hb_script_t script);
239
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800240HB_EXTERN hb_script_t
Behdad Esfahbodae070b72009-11-04 20:29:54 -0500241hb_buffer_get_script (hb_buffer_t *buffer);
242
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800243HB_EXTERN void
Behdad Esfahbodae070b72009-11-04 20:29:54 -0500244hb_buffer_set_language (hb_buffer_t *buffer,
245 hb_language_t language);
246
Behdad Esfahbodf3064102012-11-15 18:39:46 -0800247
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800248HB_EXTERN hb_language_t
Behdad Esfahbodae070b72009-11-04 20:29:54 -0500249hb_buffer_get_language (hb_buffer_t *buffer);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000250
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800251HB_EXTERN void
Behdad Esfahbodf3064102012-11-15 18:39:46 -0800252hb_buffer_set_segment_properties (hb_buffer_t *buffer,
253 const hb_segment_properties_t *props);
254
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800255HB_EXTERN void
Behdad Esfahbodf3064102012-11-15 18:39:46 -0800256hb_buffer_get_segment_properties (hb_buffer_t *buffer,
257 hb_segment_properties_t *props);
258
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800259HB_EXTERN void
Behdad Esfahbod3f82f8f2012-11-15 18:45:31 -0800260hb_buffer_guess_segment_properties (hb_buffer_t *buffer);
Behdad Esfahbodf3064102012-11-15 18:39:46 -0800261
Behdad Esfahbod92f9bfe2012-11-13 16:50:45 -0800262
Khaled Hosnyfb192c22015-12-30 15:05:50 +0400263/**
264 * hb_buffer_flags_t:
265 * @HB_BUFFER_FLAG_DEFAULT: the default buffer flag.
266 * @HB_BUFFER_FLAG_BOT: flag indicating that special handling of the beginning
Behdad Esfahbod97624d92016-01-11 12:58:45 +0000267 * of text paragraph can be applied to this buffer. Should usually
268 * be set, unless you are passing to the buffer only part
Khaled Hosnyfb192c22015-12-30 15:05:50 +0400269 * of the text without the full context.
270 * @HB_BUFFER_FLAG_EOT: flag indicating that special handling of the end of text
Behdad Esfahbod97624d92016-01-11 12:58:45 +0000271 * paragraph can be applied to this buffer, similar to
Bruce Mitchener19a93fc2018-01-21 20:40:34 +0700272 * @HB_BUFFER_FLAG_BOT.
Khaled Hosnyfb192c22015-12-30 15:05:50 +0400273 * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES:
Behdad Esfahbod97624d92016-01-11 12:58:45 +0000274 * flag indication that character with Default_Ignorable
Khaled Hosnyfb192c22015-12-30 15:05:50 +0400275 * Unicode property should use the corresponding glyph
Behdad Esfahbod3b1e97f2018-01-10 03:35:20 +0100276 * from the font, instead of hiding them (done by
277 * replacing them with the space glyph and zeroing the
Bruce Mitchener19a93fc2018-01-21 20:40:34 +0700278 * advance width.) This flag takes precedence over
Behdad Esfahbod3b1e97f2018-01-10 03:35:20 +0100279 * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES.
280 * @HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES:
281 * flag indication that character with Default_Ignorable
282 * Unicode property should be removed from glyph string
283 * instead of hiding them (done by replacing them with the
284 * space glyph and zeroing the advance width.)
285 * @HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES takes
286 * precedence over this flag. Since: 1.8.0
Eric Muller30d7c402019-02-09 02:55:27 -0800287 * @HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE:
288 * flag indicating that a dotted circle should
289 * not be inserted in the rendering of incorrect
Behdad Esfahbodd6fc1d42019-03-28 21:21:26 -0700290 * character sequences (such at <0905 093E>). Since: 2.4
Khaled Hosnyfb192c22015-12-30 15:05:50 +0400291 *
Behdad Esfahbodb8811422015-09-03 15:53:22 +0430292 * Since: 0.9.20
293 */
Behdad Esfahbod4dc798d2013-08-26 20:39:00 -0400294typedef enum { /*< flags >*/
Behdad Esfahbod11fb16c2013-10-17 20:57:57 +0200295 HB_BUFFER_FLAG_DEFAULT = 0x00000000u,
296 HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */
297 HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */
Behdad Esfahbod3b1e97f2018-01-10 03:35:20 +0100298 HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u,
Eric Muller30d7c402019-02-09 02:55:27 -0800299 HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES = 0x00000008u,
300 HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE = 0x00000010u
Behdad Esfahbod92f9bfe2012-11-13 16:50:45 -0800301} hb_buffer_flags_t;
302
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800303HB_EXTERN void
Behdad Esfahbod0c7df222012-11-13 14:42:35 -0800304hb_buffer_set_flags (hb_buffer_t *buffer,
305 hb_buffer_flags_t flags);
306
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800307HB_EXTERN hb_buffer_flags_t
Behdad Esfahbod0c7df222012-11-13 14:42:35 -0800308hb_buffer_get_flags (hb_buffer_t *buffer);
309
Behdad Esfahbod55bae682018-09-24 10:43:06 -0400310/**
311 * hb_buffer_cluster_level_t:
312 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES: Return cluster values grouped by graphemes into
313 * monotone order.
314 * @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS: Return cluster values grouped into monotone order.
315 * @HB_BUFFER_CLUSTER_LEVEL_CHARACTERS: Don't group cluster values.
316 * @HB_BUFFER_CLUSTER_LEVEL_DEFAULT: Default cluster level,
317 * equal to @HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES.
318 *
Behdad Esfahbodb8811422015-09-03 15:53:22 +0430319 * Since: 0.9.42
320 */
Behdad Esfahbod376d5872015-07-22 16:51:12 +0100321typedef enum {
322 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES = 0,
323 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS = 1,
324 HB_BUFFER_CLUSTER_LEVEL_CHARACTERS = 2,
325 HB_BUFFER_CLUSTER_LEVEL_DEFAULT = HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES
326} hb_buffer_cluster_level_t;
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -0500327
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800328HB_EXTERN void
Behdad Esfahbod376d5872015-07-22 16:51:12 +0100329hb_buffer_set_cluster_level (hb_buffer_t *buffer,
330 hb_buffer_cluster_level_t cluster_level);
331
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800332HB_EXTERN hb_buffer_cluster_level_t
Behdad Esfahbod376d5872015-07-22 16:51:12 +0100333hb_buffer_get_cluster_level (hb_buffer_t *buffer);
Behdad Esfahbod976c8f42014-07-16 15:34:20 -0400334
Khaled Hosny9ab9f972016-01-01 20:38:21 +0400335/**
336 * HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT:
337 *
338 * The default code point for replacing invalid characters in a given encoding.
339 * Set to U+FFFD REPLACEMENT CHARACTER.
340 *
341 * Since: 0.9.31
342 */
Behdad Esfahbod976c8f42014-07-16 15:34:20 -0400343#define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu
344
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800345HB_EXTERN void
Behdad Esfahbod976c8f42014-07-16 15:34:20 -0400346hb_buffer_set_replacement_codepoint (hb_buffer_t *buffer,
347 hb_codepoint_t replacement);
348
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800349HB_EXTERN hb_codepoint_t
Behdad Esfahbod976c8f42014-07-16 15:34:20 -0400350hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer);
351
Behdad Esfahbod71b65eb2018-10-07 18:41:52 +0200352HB_EXTERN void
Behdad Esfahbode42cd582018-10-07 20:46:11 -0400353hb_buffer_set_invisible_glyph (hb_buffer_t *buffer,
354 hb_codepoint_t invisible);
Behdad Esfahbod71b65eb2018-10-07 18:41:52 +0200355
356HB_EXTERN hb_codepoint_t
Behdad Esfahbode42cd582018-10-07 20:46:11 -0400357hb_buffer_get_invisible_glyph (hb_buffer_t *buffer);
Behdad Esfahbod71b65eb2018-10-07 18:41:52 +0200358
Behdad Esfahbod976c8f42014-07-16 15:34:20 -0400359
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800360HB_EXTERN void
Behdad Esfahbodc910bec2011-04-13 15:49:06 -0400361hb_buffer_reset (hb_buffer_t *buffer);
362
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800363HB_EXTERN void
Behdad Esfahbod1172dc72013-01-07 16:46:37 -0600364hb_buffer_clear_contents (hb_buffer_t *buffer);
Behdad Esfahbod82ecaff2012-11-13 13:57:52 -0800365
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800366HB_EXTERN hb_bool_t
Ryan Lortie02a534b2011-04-15 18:34:45 -0400367hb_buffer_pre_allocate (hb_buffer_t *buffer,
368 unsigned int size);
Behdad Esfahbodf9cd1012009-07-28 15:43:34 -0400369
Behdad Esfahbodaab0de52011-04-19 00:32:19 -0400370
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800371HB_EXTERN hb_bool_t
Behdad Esfahbodaab0de52011-04-19 00:32:19 -0400372hb_buffer_allocation_successful (hb_buffer_t *buffer);
373
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800374HB_EXTERN void
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400375hb_buffer_reverse (hb_buffer_t *buffer);
376
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800377HB_EXTERN void
Behdad Esfahbod81bedda2015-04-30 13:04:16 -0400378hb_buffer_reverse_range (hb_buffer_t *buffer,
379 unsigned int start, unsigned int end);
380
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800381HB_EXTERN void
Behdad Esfahbodff44f882009-11-06 19:48:16 -0500382hb_buffer_reverse_clusters (hb_buffer_t *buffer);
383
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400384
385/* Filling the buffer in */
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400386
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800387HB_EXTERN void
Behdad Esfahbodf85faee2011-04-19 00:38:01 -0400388hb_buffer_add (hb_buffer_t *buffer,
389 hb_codepoint_t codepoint,
Behdad Esfahbodf85faee2011-04-19 00:38:01 -0400390 unsigned int cluster);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000391
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800392HB_EXTERN void
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400393hb_buffer_add_utf8 (hb_buffer_t *buffer,
394 const char *text,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200395 int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400396 unsigned int item_offset,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200397 int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400398
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800399HB_EXTERN void
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400400hb_buffer_add_utf16 (hb_buffer_t *buffer,
401 const uint16_t *text,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200402 int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400403 unsigned int item_offset,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200404 int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400405
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800406HB_EXTERN void
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400407hb_buffer_add_utf32 (hb_buffer_t *buffer,
408 const uint32_t *text,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200409 int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400410 unsigned int item_offset,
Behdad Esfahbod944b2ba2011-08-09 00:23:58 +0200411 int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400412
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800413HB_EXTERN void
Behdad Esfahbod61820bc2015-01-26 14:25:52 -0800414hb_buffer_add_latin1 (hb_buffer_t *buffer,
415 const uint8_t *text,
416 int text_length,
417 unsigned int item_offset,
418 int item_length);
419
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800420HB_EXTERN void
Behdad Esfahbodbcba8b42014-07-16 14:59:04 -0400421hb_buffer_add_codepoints (hb_buffer_t *buffer,
422 const hb_codepoint_t *text,
423 int text_length,
424 unsigned int item_offset,
425 int item_length);
426
Behdad Esfahbod39a97492017-08-11 15:52:06 -0700427HB_EXTERN void
428hb_buffer_append (hb_buffer_t *buffer,
429 hb_buffer_t *source,
430 unsigned int start,
431 unsigned int end);
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400432
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800433HB_EXTERN hb_bool_t
Behdad Esfahbodc910bec2011-04-13 15:49:06 -0400434hb_buffer_set_length (hb_buffer_t *buffer,
435 unsigned int length);
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400436
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800437HB_EXTERN unsigned int
Behdad Esfahbod3d145282009-11-06 15:13:17 -0500438hb_buffer_get_length (hb_buffer_t *buffer);
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400439
Behdad Esfahbodc910bec2011-04-13 15:49:06 -0400440/* Getting glyphs out of the buffer */
441
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800442HB_EXTERN hb_glyph_info_t *
Ryan Lortie70566be2011-04-15 18:32:36 -0400443hb_buffer_get_glyph_infos (hb_buffer_t *buffer,
Ebrahim Byagowia0b4ac42019-08-24 17:57:14 +0430444 unsigned int *length);
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400445
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800446HB_EXTERN hb_glyph_position_t *
Ryan Lortie70566be2011-04-15 18:32:36 -0400447hb_buffer_get_glyph_positions (hb_buffer_t *buffer,
Ebrahim Byagowia0b4ac42019-08-24 17:57:14 +0430448 unsigned int *length);
Behdad Esfahbod02a37062009-07-29 18:41:25 -0400449
450
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800451HB_EXTERN void
Behdad Esfahbod39b17832012-07-17 17:09:29 -0400452hb_buffer_normalize_glyphs (hb_buffer_t *buffer);
453
Behdad Esfahbod39b17832012-07-17 17:09:29 -0400454
Behdad Esfahbodc54599a2012-11-15 16:14:23 -0800455/*
456 * Serialize
457 */
Behdad Esfahbod39b17832012-07-17 17:09:29 -0400458
Khaled Hosny9ab9f972016-01-01 20:38:21 +0400459/**
460 * hb_buffer_serialize_flags_t:
461 * @HB_BUFFER_SERIALIZE_FLAG_DEFAULT: serialize glyph names, clusters and positions.
462 * @HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS: do not serialize glyph cluster.
463 * @HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS: do not serialize glyph position information.
464 * @HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES: do no serialize glyph name.
465 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS: serialize glyph extents.
Behdad Esfahbod71fd6322018-01-10 02:20:14 +0100466 * @HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS: serialize glyph flags. Since: 1.5.0
Khaled Hosny0b22da92018-01-10 07:12:07 +0200467 * @HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES: do not serialize glyph advances,
468 * glyph offsets will reflect absolute glyph positions. Since: 1.8.0
Khaled Hosny9ab9f972016-01-01 20:38:21 +0400469 *
470 * Flags that control what glyph information are serialized in hb_buffer_serialize_glyphs().
471 *
Behdad Esfahbodb8811422015-09-03 15:53:22 +0430472 * Since: 0.9.20
473 */
Behdad Esfahbod4dc798d2013-08-26 20:39:00 -0400474typedef enum { /*< flags >*/
Behdad Esfahbod11fb16c2013-10-17 20:57:57 +0200475 HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u,
476 HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u,
477 HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u,
Behdad Esfahbodfdd17702015-08-24 13:49:55 +0100478 HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u,
Behdad Esfahbod40bd7e92016-05-02 14:47:45 +0200479 HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS = 0x00000008u,
Behdad Esfahbod71fd6322018-01-10 02:20:14 +0100480 HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS = 0x00000010u,
481 HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES = 0x00000020u
Behdad Esfahbodf9edf162012-11-15 12:14:09 -0800482} hb_buffer_serialize_flags_t;
483
Khaled Hosny9ab9f972016-01-01 20:38:21 +0400484/**
485 * hb_buffer_serialize_format_t:
486 * @HB_BUFFER_SERIALIZE_FORMAT_TEXT: a human-readable, plain text format.
487 * @HB_BUFFER_SERIALIZE_FORMAT_JSON: a machine-readable JSON format.
Behdad Esfahbod97624d92016-01-11 12:58:45 +0000488 * @HB_BUFFER_SERIALIZE_FORMAT_INVALID: invalid format.
Khaled Hosny9ab9f972016-01-01 20:38:21 +0400489 *
490 * The buffer serialization and de-serialization format used in
491 * hb_buffer_serialize_glyphs() and hb_buffer_deserialize_glyphs().
492 *
493 * Since: 0.9.2
494 */
Behdad Esfahbodf9edf162012-11-15 12:14:09 -0800495typedef enum {
496 HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'),
497 HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'),
498 HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE
499} hb_buffer_serialize_format_t;
500
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800501HB_EXTERN hb_buffer_serialize_format_t
Behdad Esfahbodf9edf162012-11-15 12:14:09 -0800502hb_buffer_serialize_format_from_string (const char *str, int len);
503
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800504HB_EXTERN const char *
Behdad Esfahbodf9edf162012-11-15 12:14:09 -0800505hb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format);
506
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800507HB_EXTERN const char **
Behdad Esfahbod072ae7a2012-11-15 13:14:12 -0800508hb_buffer_serialize_list_formats (void);
509
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800510HB_EXTERN unsigned int
Behdad Esfahbodf9edf162012-11-15 12:14:09 -0800511hb_buffer_serialize_glyphs (hb_buffer_t *buffer,
512 unsigned int start,
513 unsigned int end,
514 char *buf,
515 unsigned int buf_size,
Khaled Hosny9ab9f972016-01-01 20:38:21 +0400516 unsigned int *buf_consumed,
517 hb_font_t *font,
Behdad Esfahbodf9edf162012-11-15 12:14:09 -0800518 hb_buffer_serialize_format_t format,
519 hb_buffer_serialize_flags_t flags);
520
Chun-wei Fan835bbdc2015-11-19 18:34:12 +0800521HB_EXTERN hb_bool_t
Behdad Esfahbodf9edf162012-11-15 12:14:09 -0800522hb_buffer_deserialize_glyphs (hb_buffer_t *buffer,
523 const char *buf,
Khaled Hosny9ab9f972016-01-01 20:38:21 +0400524 int buf_len,
525 const char **end_ptr,
526 hb_font_t *font,
Behdad Esfahbodf9edf162012-11-15 12:14:09 -0800527 hb_buffer_serialize_format_t format);
528
529
Behdad Esfahbod0475ef22015-12-18 18:17:07 +0000530/*
Jonathan Kew331d66c2014-07-19 23:09:09 +0100531 * Compare buffers
532 */
533
534typedef enum { /*< flags >*/
535 HB_BUFFER_DIFF_FLAG_EQUAL = 0x0000,
536
537 /* Buffers with different content_type cannot be meaningfully compared
538 * in any further detail. */
Behdad Esfahbodd03f11f2017-09-04 20:14:13 -0700539 HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH = 0x0001,
Jonathan Kew331d66c2014-07-19 23:09:09 +0100540
541 /* For buffers with differing length, the per-glyph comparison is not
542 * attempted, though we do still scan reference for dottedcircle / .notdef
543 * glyphs. */
Behdad Esfahbodd03f11f2017-09-04 20:14:13 -0700544 HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH = 0x0002,
Jonathan Kew331d66c2014-07-19 23:09:09 +0100545
546 /* We want to know if dottedcircle / .notdef glyphs are present in the
547 * reference, as we may not care so much about other differences in this
548 * case. */
549 HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT = 0x0004,
550 HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT = 0x0008,
551
552 /* If the buffers have the same length, we compare them glyph-by-glyph
553 * and report which aspect(s) of the glyph info/position are different. */
554 HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH = 0x0010,
Behdad Esfahbod338e61a2017-08-14 12:36:38 -0700555 HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH = 0x0020,
Behdad Esfahbod3e8f4f12017-08-22 17:56:25 -0700556 HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH = 0x0040,
Jonathan Kew331d66c2014-07-19 23:09:09 +0100557 HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH = 0x0080
558
559} hb_buffer_diff_flags_t;
560
561/* Compare the contents of two buffers, report types of differences. */
fanc99948a94062017-10-07 18:57:14 +0800562HB_EXTERN hb_buffer_diff_flags_t
Jonathan Kew331d66c2014-07-19 23:09:09 +0100563hb_buffer_diff (hb_buffer_t *buffer,
564 hb_buffer_t *reference,
565 hb_codepoint_t dottedcircle_glyph,
566 unsigned int position_fuzz);
567
568
569/*
Behdad Esfahbod0475ef22015-12-18 18:17:07 +0000570 * Debugging.
571 */
572
573typedef hb_bool_t (*hb_buffer_message_func_t) (hb_buffer_t *buffer,
574 hb_font_t *font,
575 const char *message,
576 void *user_data);
577
578HB_EXTERN void
579hb_buffer_set_message_func (hb_buffer_t *buffer,
580 hb_buffer_message_func_t func,
581 void *user_data, hb_destroy_func_t destroy);
582
583
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -0400584HB_END_DECLS
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000585
Behdad Esfahbod5c0adce2009-05-20 05:42:12 -0400586#endif /* HB_BUFFER_H */