blob: d1772d4c7102d8df2b98f74550f524896436426b [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 Esfahbod11fbb542009-08-01 22:19:06 -040037typedef struct _hb_buffer_t hb_buffer_t;
38
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040039typedef struct _hb_glyph_info_t {
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040040 hb_codepoint_t codepoint;
Behdad Esfahbod468769b2009-08-08 16:53:23 -040041 hb_mask_t mask;
Behdad Esfahbodf1322e52009-08-01 22:53:04 -040042 uint32_t cluster;
Behdad Esfahbod2f5931e2009-08-19 16:07:40 -040043 uint32_t internal1;
44 uint32_t internal2;
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040045} hb_glyph_info_t;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000046
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040047typedef struct _hb_glyph_position_t {
Behdad Esfahbodb857b492009-05-20 05:35:14 -040048 hb_position_t x_advance;
49 hb_position_t y_advance;
Behdad Esfahbod9bef3612009-11-05 12:20:11 -050050 hb_position_t x_offset;
51 hb_position_t y_offset;
Behdad Esfahbod9db8ad72009-11-06 16:47:31 -050052 uint32_t internal;
Behdad Esfahbodc968fc22009-05-25 04:04:24 -040053} hb_glyph_position_t;
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000054
55
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040056hb_buffer_t *
57hb_buffer_create (unsigned int pre_alloc_size);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000058
Behdad Esfahbodb857b492009-05-20 05:35:14 -040059hb_buffer_t *
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040060hb_buffer_reference (hb_buffer_t *buffer);
61
62unsigned int
63hb_buffer_get_reference_count (hb_buffer_t *buffer);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000064
Behdad Esfahboda8abb8b2007-10-11 00:07:58 +000065void
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040066hb_buffer_destroy (hb_buffer_t *buffer);
67
68
69void
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050070hb_buffer_set_unicode_funcs (hb_buffer_t *buffer,
71 hb_unicode_funcs_t *unicode_funcs);
72
73hb_unicode_funcs_t *
74hb_buffer_get_unicode_funcs (hb_buffer_t *buffer);
75
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050076void
Behdad Esfahbod11fbb542009-08-01 22:19:06 -040077hb_buffer_set_direction (hb_buffer_t *buffer,
78 hb_direction_t direction);
79
80hb_direction_t
81hb_buffer_get_direction (hb_buffer_t *buffer);
82
Behdad Esfahbodae070b72009-11-04 20:29:54 -050083void
84hb_buffer_set_script (hb_buffer_t *buffer,
85 hb_script_t script);
86
87hb_script_t
88hb_buffer_get_script (hb_buffer_t *buffer);
89
90void
91hb_buffer_set_language (hb_buffer_t *buffer,
92 hb_language_t language);
93
94hb_language_t
95hb_buffer_get_language (hb_buffer_t *buffer);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +000096
Behdad Esfahbod5ebabec2009-11-03 15:15:07 -050097
Behdad Esfahboda8abb8b2007-10-11 00:07:58 +000098void
Behdad Esfahbodb857b492009-05-20 05:35:14 -040099hb_buffer_clear (hb_buffer_t *buffer);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000100
Behdad Esfahbodb857b492009-05-20 05:35:14 -0400101void
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400102hb_buffer_clear_positions (hb_buffer_t *buffer);
103
104void
Behdad Esfahbodf9cd1012009-07-28 15:43:34 -0400105hb_buffer_ensure (hb_buffer_t *buffer,
106 unsigned int size);
107
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400108void
109hb_buffer_reverse (hb_buffer_t *buffer);
110
Behdad Esfahbodff44f882009-11-06 19:48:16 -0500111void
112hb_buffer_reverse_clusters (hb_buffer_t *buffer);
113
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400114
115/* Filling the buffer in */
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400116
Behdad Esfahbodf9cd1012009-07-28 15:43:34 -0400117void
Behdad Esfahbodb857b492009-05-20 05:35:14 -0400118hb_buffer_add_glyph (hb_buffer_t *buffer,
Behdad Esfahbodf1322e52009-08-01 22:53:04 -0400119 hb_codepoint_t codepoint,
Behdad Esfahbod468769b2009-08-08 16:53:23 -0400120 hb_mask_t mask,
Behdad Esfahbodb857b492009-05-20 05:35:14 -0400121 unsigned int cluster);
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000122
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400123void
124hb_buffer_add_utf8 (hb_buffer_t *buffer,
125 const char *text,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400126 unsigned int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400127 unsigned int item_offset,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400128 unsigned int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400129
130void
131hb_buffer_add_utf16 (hb_buffer_t *buffer,
132 const uint16_t *text,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400133 unsigned int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400134 unsigned int item_offset,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400135 unsigned int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400136
137void
138hb_buffer_add_utf32 (hb_buffer_t *buffer,
139 const uint32_t *text,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400140 unsigned int text_length,
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400141 unsigned int item_offset,
Behdad Esfahbod299f0892009-08-10 22:47:57 -0400142 unsigned int item_length);
Behdad Esfahbod1b7b97f2009-08-10 21:10:37 -0400143
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400144
Behdad Esfahbodfbaf8ff2009-08-10 20:59:25 -0400145/* Getting glyphs out of the buffer */
146
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400147/* Return value valid as long as buffer not modified */
148unsigned int
Behdad Esfahbod3d145282009-11-06 15:13:17 -0500149hb_buffer_get_length (hb_buffer_t *buffer);
Behdad Esfahbod11fbb542009-08-01 22:19:06 -0400150
151/* Return value valid as long as buffer not modified */
152hb_glyph_info_t *
153hb_buffer_get_glyph_infos (hb_buffer_t *buffer);
154
155/* Return value valid as long as buffer not modified */
156hb_glyph_position_t *
157hb_buffer_get_glyph_positions (hb_buffer_t *buffer);
Behdad Esfahbod02a37062009-07-29 18:41:25 -0400158
159
Behdad Esfahbodf96ffd42009-05-24 15:01:16 -0400160HB_END_DECLS
Behdad Esfahbod9f8da382006-03-31 12:28:09 +0000161
Behdad Esfahbod5c0adce2009-05-20 05:42:12 -0400162#endif /* HB_BUFFER_H */