blob: 0185415c46e373856086002900b3e96147934fcc [file] [log] [blame]
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00001/*
2 * Copyright (C) 1998-2004 David Turner and Werner Lemberg
Behdad Esfahbod6c786832009-05-25 03:22:19 -04003 * Copyright (C) 2004,2007,2009 Red Hat, Inc.
Behdad Esfahbod9f8da382006-03-31 12:28:09 +00004 *
Behdad Esfahbodc755cb32010-04-22 00:11:43 -04005 * This is part of HarfBuzz, a text shaping library.
Behdad Esfahbod9f8da382006-03-31 12:28:09 +00006 *
Behdad Esfahboda2a9a022008-01-15 22:46:32 +00007 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in
11 * all copies of this software.
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000012 *
Behdad Esfahboda2a9a022008-01-15 22:46:32 +000013 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17 * DAMAGE.
18 *
19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 *
25 * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000026 */
Behdad Esfahboda2a9a022008-01-15 22:46:32 +000027
Behdad Esfahbod5c0adce2009-05-20 05:42:12 -040028#ifndef HB_BUFFER_H
29#define HB_BUFFER_H
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000030
Behdad Esfahbodb857b492009-05-20 05:35:14 -040031#include "hb-common.h"
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050032#include "hb-unicode.h"
Behdad Esfahbodae070b72009-11-04 20:29:54 -050033#include "hb-language.h"
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000034
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -040035HB_BEGIN_DECLS
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000036
Behdad Esfahbodacdba3f2010-07-23 15:11:18 -040037
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040038typedef struct _hb_buffer_t hb_buffer_t;
39
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040040typedef struct _hb_glyph_info_t {
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040041 hb_codepoint_t codepoint;
Behdad Esfahbod468769b2009-08-08 16:53:23 -040042 hb_mask_t mask;
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040043 uint32_t cluster;
Behdad Esfahbod6cb8c342010-10-27 14:27:03 -040044 hb_var_int_t var1;
45 hb_var_int_t var2;
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040046} hb_glyph_info_t;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000047
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040048typedef struct _hb_glyph_position_t {
Behdad Esfahbodb857b492009-05-20 05:35:14 -040049 hb_position_t x_advance;
50 hb_position_t y_advance;
Behdad Esfahbod9bef3612009-11-05 12:20:11 -050051 hb_position_t x_offset;
52 hb_position_t y_offset;
Behdad Esfahbod88474c62010-10-27 14:42:15 -040053 hb_var_int_t var;
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040054} hb_glyph_position_t;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000055
56
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040057hb_buffer_t *
58hb_buffer_create (unsigned int pre_alloc_size);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000059
Behdad Esfahbodb857b492009-05-20 05:35:14 -040060hb_buffer_t *
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040061hb_buffer_reference (hb_buffer_t *buffer);
62
63unsigned int
64hb_buffer_get_reference_count (hb_buffer_t *buffer);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000065
Behdad Esfahboda8abb8b2007-10-11 00:07:58 +000066void
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040067hb_buffer_destroy (hb_buffer_t *buffer);
68
69
70void
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050071hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
72 hb_unicode_funcs_t *unicode_funcs);
73
74hb_unicode_funcs_t *
75hb_buffer_get_unicode_funcs (hb_buffer_t *buffer);
76
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050077void
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040078hb_buffer_set_direction (hb_buffer_t *buffer,
79 hb_direction_t direction);
80
81hb_direction_t
82hb_buffer_get_direction (hb_buffer_t *buffer);
83
Behdad Esfahbodae070b72009-11-04 20:29:54 -050084void
85hb_buffer_set_script (hb_buffer_t *buffer,
86 hb_script_t script);
87
88hb_script_t
89hb_buffer_get_script (hb_buffer_t *buffer);
90
91void
92hb_buffer_set_language (hb_buffer_t *buffer,
93 hb_language_t language);
94
95hb_language_t
96hb_buffer_get_language (hb_buffer_t *buffer);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000097
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050098
Behdad Esfahboda8abb8b2007-10-11 00:07:58 +000099void
Behdad Esfahbodb857b492009-05-20 05:35:14 -0400100hb_buffer_clear (hb_buffer_t *buffer);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000101
Behdad Esfahbodb857b492009-05-20 05:35:14 -0400102void
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400103hb_buffer_clear_positions (hb_buffer_t *buffer);
104
Behdad Esfahboda6a79df2010-05-14 23:20:16 -0400105hb_bool_t
Behdad Esfahbodf9cd1012009-07-28 15:43:34 -0400106hb_buffer_ensure (hb_buffer_t *buffer,
107 unsigned int size);
108
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400109void
110hb_buffer_reverse (hb_buffer_t *buffer);
111
Behdad Esfahbodff44f882009-11-06 19:48:16 -0500112void
113hb_buffer_reverse_clusters (hb_buffer_t *buffer);
114
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400115
116/* Filling the buffer in */
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400117
Behdad Esfahbodf9cd1012009-07-28 15:43:34 -0400118void
Behdad Esfahbodb857b492009-05-20 05:35:14 -0400119hb_buffer_add_glyph (hb_buffer_t *buffer,
Behdad Esfahbodf1322e52009-08-01 22:53:04 -0400120 hb_codepoint_t codepoint,
Behdad Esfahbod468769b2009-08-08 16:53:23 -0400121 hb_mask_t mask,
Behdad Esfahbodb857b492009-05-20 05:35:14 -0400122 unsigned int cluster);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000123
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400124void
125hb_buffer_add_utf8 (hb_buffer_t *buffer,
126 const char *text,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400127 unsigned int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400128 unsigned int item_offset,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400129 unsigned int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400130
131void
132hb_buffer_add_utf16 (hb_buffer_t *buffer,
133 const uint16_t *text,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400134 unsigned int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400135 unsigned int item_offset,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400136 unsigned int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400137
138void
139hb_buffer_add_utf32 (hb_buffer_t *buffer,
140 const uint32_t *text,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400141 unsigned int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400142 unsigned int item_offset,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400143 unsigned int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400144
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400145
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400146/* Getting glyphs out of the buffer */
147
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400148/* Return value valid as long as buffer not modified */
149unsigned int
Behdad Esfahbod3d145282009-11-06 15:13:17 -0500150hb_buffer_get_length (hb_buffer_t *buffer);
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400151
152/* Return value valid as long as buffer not modified */
153hb_glyph_info_t *
154hb_buffer_get_glyph_infos (hb_buffer_t *buffer);
155
156/* Return value valid as long as buffer not modified */
157hb_glyph_position_t *
158hb_buffer_get_glyph_positions (hb_buffer_t *buffer);
Behdad Esfahbod02a37062009-07-29 18:41:25 -0400159
160
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -0400161HB_END_DECLS
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000162
Behdad Esfahbod5c0adce2009-05-20 05:42:12 -0400163#endif /* HB_BUFFER_H */