hb-buffer.h revision 864e2560b627f1e73be3b0635e02f00844cb67c3
1a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod/*
2a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * Copyright (C) 1998-2004  David Turner and Werner Lemberg
36c78683c042250a7b5a6fc6ebae4717b03fadf9eBehdad Esfahbod * Copyright (C) 2004,2007,2009  Red Hat, Inc.
49f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod *
5a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * This is part of HarfBuzz, an OpenType Layout engine library.
69f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod *
7a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * Permission is hereby granted, without written agreement and without
8a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this
9a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * software and its documentation for any purpose, provided that the
10a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * above copyright notice and the following two paragraphs appear in
11a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * all copies of this software.
129f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod *
13a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * DAMAGE.
18a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod *
19a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod *
25a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * Red Hat Author(s): Owen Taylor, Behdad Esfahbod
269f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod */
27a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod
285c0adce1ccc739415c4b26ff13ffd2d77ea4bc6cBehdad Esfahbod#ifndef HB_BUFFER_H
295c0adce1ccc739415c4b26ff13ffd2d77ea4bc6cBehdad Esfahbod#define HB_BUFFER_H
309f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
31b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod#include "hb-common.h"
329f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
33f96ffd43bce0ac6d9c897933c9be0e51d543e570Behdad EsfahbodHB_BEGIN_DECLS
349f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
3511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodtypedef struct _hb_buffer_t hb_buffer_t;
3611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod
3702a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbodtypedef enum _hb_direction_t {
3802a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod  HB_DIRECTION_LTR,
3902a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod  HB_DIRECTION_RTL,
4002a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod  HB_DIRECTION_TTB,
4102a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod  HB_DIRECTION_BTT
4202a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod} hb_direction_t;
4302a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod
44c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbodtypedef struct _hb_glyph_info_t {
45f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod  hb_codepoint_t codepoint;
46468769b8f5332940278244e744ec2bd5a5dc5ee9Behdad Esfahbod  hb_mask_t      mask;
47f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod  uint32_t       cluster;
48f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod  uint16_t       component;
49f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod  uint16_t       lig_id;
50f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod  uint32_t       internal;
51c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbod} hb_glyph_info_t;
529f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
53c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbodtypedef struct _hb_glyph_position_t {
54b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod  hb_position_t  x_pos;
55b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod  hb_position_t  y_pos;
56b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod  hb_position_t  x_advance;
57b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod  hb_position_t  y_advance;
58f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod  /* XXX these should all be replaced by "uint32_t internal" */
59864e2560b627f1e73be3b0635e02f00844cb67c3Behdad Esfahbod  uint32_t       new_advance :1;	/* if set, the advance width values are
60f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod					   absolute, i.e., they won't be
61f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod					   added to the original glyph's value
62f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod					   but rather replace them */
63864e2560b627f1e73be3b0635e02f00844cb67c3Behdad Esfahbod  uint32_t       back : 15;		/* number of glyphs to go back
64f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod					   for drawing current glyph */
65864e2560b627f1e73be3b0635e02f00844cb67c3Behdad Esfahbod  int32_t        cursive_chain : 16;	/* character to which this connects,
66f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod					   may be positive or negative; used
67f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod					   only internally */
68c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbod} hb_glyph_position_t;
699f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
709f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
7111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_t *
7211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_create (unsigned int pre_alloc_size);
739f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
7411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_t *
7511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_reference (hb_buffer_t *buffer);
765c0adce1ccc739415c4b26ff13ffd2d77ea4bc6cBehdad Esfahbod
7711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodunsigned int
7811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_get_reference_count (hb_buffer_t *buffer);
7902a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod
8011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodvoid
8111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_destroy (hb_buffer_t *buffer);
829f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
839f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
84a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbodvoid
8511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_set_direction (hb_buffer_t    *buffer,
8611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod			 hb_direction_t  direction);
8711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod
8811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_direction_t
8911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_get_direction (hb_buffer_t *buffer);
9011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod
919f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
92a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbodvoid
93b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbodhb_buffer_clear (hb_buffer_t *buffer);
949f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
95b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbodvoid
9611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_clear_positions (hb_buffer_t *buffer);
9711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod
9811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodvoid
99f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbodhb_buffer_ensure (hb_buffer_t  *buffer,
100f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod		  unsigned int  size);
101f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod
102fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbodvoid
103fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbodhb_buffer_reverse (hb_buffer_t *buffer);
104fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod
105fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod
106fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod/* Filling the buffer in */
10711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod
108f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbodvoid
109b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbodhb_buffer_add_glyph (hb_buffer_t    *buffer,
110f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod		     hb_codepoint_t  codepoint,
111468769b8f5332940278244e744ec2bd5a5dc5ee9Behdad Esfahbod		     hb_mask_t       mask,
112b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod		     unsigned int    cluster);
1139f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
1141b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodvoid
1151b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodhb_buffer_add_utf8 (hb_buffer_t  *buffer,
1161b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod		    const char   *text,
117299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod		    unsigned int  text_length,
1181b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod		    unsigned int  item_offset,
119299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod		    unsigned int  item_length);
1201b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod
1211b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodvoid
1221b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodhb_buffer_add_utf16 (hb_buffer_t    *buffer,
1231b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod		     const uint16_t *text,
124299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod		     unsigned int    text_length,
1251b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod		     unsigned int    item_offset,
126299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod		     unsigned int    item_length);
1271b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod
1281b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodvoid
1291b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodhb_buffer_add_utf32 (hb_buffer_t    *buffer,
1301b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod		     const uint32_t *text,
131299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod		     unsigned int    text_length,
1321b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod		     unsigned int    item_offset,
133299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod		     unsigned int    item_length);
1341b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod
13511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod
136fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod/* Getting glyphs out of the buffer */
137fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod
13811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod/* Return value valid as long as buffer not modified */
13911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodunsigned int
14011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_get_len (hb_buffer_t *buffer);
14111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod
14211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod/* Return value valid as long as buffer not modified */
14311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_info_t *
14411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_get_glyph_infos (hb_buffer_t *buffer);
14511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod
14611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod/* Return value valid as long as buffer not modified */
14711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_position_t *
14811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_get_glyph_positions (hb_buffer_t *buffer);
14902a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod
15002a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod
151f96ffd43bce0ac6d9c897933c9be0e51d543e570Behdad EsfahbodHB_END_DECLS
1529f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod
1535c0adce1ccc739415c4b26ff13ffd2d77ea4bc6cBehdad Esfahbod#endif /* HB_BUFFER_H */
154