hb-buffer.h revision 3d14528b8b2e7da425a9df7057fc9fb326d8298c
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" 325ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod#include "hb-unicode.h" 33ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod#include "hb-language.h" 349f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 35f96ffd43bce0ac6d9c897933c9be0e51d543e570Behdad EsfahbodHB_BEGIN_DECLS 369f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 3711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodtypedef struct _hb_buffer_t hb_buffer_t; 3811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 3902a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbodtypedef enum _hb_direction_t { 4002a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod HB_DIRECTION_LTR, 4102a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod HB_DIRECTION_RTL, 4202a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod HB_DIRECTION_TTB, 4302a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod HB_DIRECTION_BTT 4402a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod} hb_direction_t; 4502a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod 46c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbodtypedef struct _hb_glyph_info_t { 47f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod hb_codepoint_t codepoint; 48468769b8f5332940278244e744ec2bd5a5dc5ee9Behdad Esfahbod hb_mask_t mask; 49f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod uint32_t cluster; 502f5931e404cb56e31d24b2eb7ff0a849fb077b55Behdad Esfahbod uint32_t internal1; 512f5931e404cb56e31d24b2eb7ff0a849fb077b55Behdad Esfahbod uint32_t internal2; 52c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbod} hb_glyph_info_t; 539f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 54c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbodtypedef struct _hb_glyph_position_t { 55b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod hb_position_t x_advance; 56b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod hb_position_t y_advance; 579bef3611f07b45ba8199a4a339c72f49d266216aBehdad Esfahbod hb_position_t x_offset; 589bef3611f07b45ba8199a4a339c72f49d266216aBehdad Esfahbod hb_position_t y_offset; 59f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod /* XXX these should all be replaced by "uint32_t internal" */ 60864e2560b627f1e73be3b0635e02f00844cb67c3Behdad Esfahbod uint32_t new_advance :1; /* if set, the advance width values are 61f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod absolute, i.e., they won't be 62f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod added to the original glyph's value 63f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod but rather replace them */ 64864e2560b627f1e73be3b0635e02f00844cb67c3Behdad Esfahbod uint32_t back : 15; /* number of glyphs to go back 65f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod for drawing current glyph */ 66864e2560b627f1e73be3b0635e02f00844cb67c3Behdad Esfahbod int32_t cursive_chain : 16; /* character to which this connects, 67f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod may be positive or negative; used 68f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod only internally */ 69c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbod} hb_glyph_position_t; 709f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 719f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 7211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_t * 7311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_create (unsigned int pre_alloc_size); 749f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 7511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_t * 7611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_reference (hb_buffer_t *buffer); 775c0adce1ccc739415c4b26ff13ffd2d77ea4bc6cBehdad Esfahbod 7811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodunsigned int 7911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_get_reference_count (hb_buffer_t *buffer); 8002a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod 8111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodvoid 8211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_destroy (hb_buffer_t *buffer); 839f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 849f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 85a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbodvoid 865ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_set_unicode_funcs (hb_buffer_t *buffer, 875ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod hb_unicode_funcs_t *unicode_funcs); 885ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 895ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_unicode_funcs_t * 905ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_get_unicode_funcs (hb_buffer_t *buffer); 915ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 925ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodvoid 9311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_set_direction (hb_buffer_t *buffer, 9411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod hb_direction_t direction); 9511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 9611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_direction_t 9711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_get_direction (hb_buffer_t *buffer); 9811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 99ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodvoid 100ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_set_script (hb_buffer_t *buffer, 101ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod hb_script_t script); 102ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 103ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_script_t 104ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_get_script (hb_buffer_t *buffer); 105ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 106ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodvoid 107ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_set_language (hb_buffer_t *buffer, 108ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod hb_language_t language); 109ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 110ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_language_t 111ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_get_language (hb_buffer_t *buffer); 1129f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 1135ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 114a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbodvoid 115b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbodhb_buffer_clear (hb_buffer_t *buffer); 1169f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 117b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbodvoid 11811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_clear_positions (hb_buffer_t *buffer); 11911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 12011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodvoid 121f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbodhb_buffer_ensure (hb_buffer_t *buffer, 122f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod unsigned int size); 123f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod 124fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbodvoid 125fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbodhb_buffer_reverse (hb_buffer_t *buffer); 126fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod 127fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod 128fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod/* Filling the buffer in */ 12911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 130f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbodvoid 131b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbodhb_buffer_add_glyph (hb_buffer_t *buffer, 132f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod hb_codepoint_t codepoint, 133468769b8f5332940278244e744ec2bd5a5dc5ee9Behdad Esfahbod hb_mask_t mask, 134b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod unsigned int cluster); 1359f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 1361b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodvoid 1371b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodhb_buffer_add_utf8 (hb_buffer_t *buffer, 1381b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod const char *text, 139299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int text_length, 1401b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod unsigned int item_offset, 141299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_length); 1421b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod 1431b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodvoid 1441b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodhb_buffer_add_utf16 (hb_buffer_t *buffer, 1451b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod const uint16_t *text, 146299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int text_length, 1471b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod unsigned int item_offset, 148299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_length); 1491b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod 1501b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodvoid 1511b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodhb_buffer_add_utf32 (hb_buffer_t *buffer, 1521b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod const uint32_t *text, 153299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int text_length, 1541b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod unsigned int item_offset, 155299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_length); 1561b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod 15711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 158fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod/* Getting glyphs out of the buffer */ 159fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod 16011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod/* Return value valid as long as buffer not modified */ 16111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodunsigned int 1623d14528b8b2e7da425a9df7057fc9fb326d8298cBehdad Esfahbodhb_buffer_get_length (hb_buffer_t *buffer); 16311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 16411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod/* Return value valid as long as buffer not modified */ 16511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_info_t * 16611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_get_glyph_infos (hb_buffer_t *buffer); 16711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 16811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod/* Return value valid as long as buffer not modified */ 16911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_position_t * 17011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_get_glyph_positions (hb_buffer_t *buffer); 17102a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod 17202a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod 173f96ffd43bce0ac6d9c897933c9be0e51d543e570Behdad EsfahbodHB_END_DECLS 1749f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 1755c0adce1ccc739415c4b26ff13ffd2d77ea4bc6cBehdad Esfahbod#endif /* HB_BUFFER_H */ 176