1a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod/* 22409d5f8d7dd8b535ce5ea29e933f7db27d33793Behdad Esfahbod * Copyright © 1998-2004 David Turner and Werner Lemberg 32409d5f8d7dd8b535ce5ea29e933f7db27d33793Behdad Esfahbod * Copyright © 2004,2007,2009 Red Hat, Inc. 405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod * Copyright © 2011,2012 Google, Inc. 59f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod * 68f0d7e0c3fd4b05c43ac449be4f374dc2dc56127Behdad Esfahbod * This is part of HarfBuzz, a text shaping library. 79f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod * 8a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * Permission is hereby granted, without written agreement and without 9a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this 10a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * software and its documentation for any purpose, provided that the 11a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * above copyright notice and the following two paragraphs appear in 12a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * all copies of this software. 139f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod * 14a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 15a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 16a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 17a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 18a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * DAMAGE. 19a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * 20a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 21a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 22a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 23a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 24a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 25a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * 26a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * Red Hat Author(s): Owen Taylor, Behdad Esfahbod 27c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod * Google Author(s): Behdad Esfahbod 289f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod */ 29a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod 30d1c9eb458c843215da8df84b596bfae51fee135bBehdad Esfahbod#ifndef HB_H_IN 31d1c9eb458c843215da8df84b596bfae51fee135bBehdad Esfahbod#error "Include <hb.h> instead." 32d1c9eb458c843215da8df84b596bfae51fee135bBehdad Esfahbod#endif 33d1c9eb458c843215da8df84b596bfae51fee135bBehdad Esfahbod 345c0adce1ccc739415c4b26ff13ffd2d77ea4bc6cBehdad Esfahbod#ifndef HB_BUFFER_H 355c0adce1ccc739415c4b26ff13ffd2d77ea4bc6cBehdad Esfahbod#define HB_BUFFER_H 369f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 37b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod#include "hb-common.h" 385ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod#include "hb-unicode.h" 39f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod#include "hb-font.h" 409f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 41f96ffd43bce0ac6d9c897933c9be0e51d543e570Behdad EsfahbodHB_BEGIN_DECLS 429f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 43acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 441bc1cb3603167f5da309336f7018c8b0608ac104Behdad Esfahbodtypedef struct hb_glyph_info_t { 45f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod hb_codepoint_t codepoint; 46468769b8f5332940278244e744ec2bd5a5dc5ee9Behdad Esfahbod hb_mask_t mask; 47f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod uint32_t cluster; 48b54cd07b2623b68171e00179a9dc3ecbea7aa6a1Behdad Esfahbod 49b54cd07b2623b68171e00179a9dc3ecbea7aa6a1Behdad Esfahbod /*< private >*/ 506cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod hb_var_int_t var1; 516cb8c3493019e1497921666fc268cb81943f9f1fBehdad Esfahbod hb_var_int_t var2; 52c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbod} hb_glyph_info_t; 539f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 541bc1cb3603167f5da309336f7018c8b0608ac104Behdad 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; 59b54cd07b2623b68171e00179a9dc3ecbea7aa6a1Behdad Esfahbod 60b54cd07b2623b68171e00179a9dc3ecbea7aa6a1Behdad Esfahbod /*< private >*/ 6188474c6fdaf35c56368694a5b164f4988a004d49Behdad Esfahbod hb_var_int_t var; 62c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbod} hb_glyph_position_t; 639f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 649f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 65f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodtypedef struct hb_segment_properties_t { 66f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod hb_direction_t direction; 67f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod hb_script_t script; 68f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod hb_language_t language; 69f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod /*< private >*/ 70f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod void *reserved1; 71f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod void *reserved2; 72f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod} hb_segment_properties_t; 73f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 74f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod#define HB_SEGMENT_PROPERTIES_DEFAULT {HB_DIRECTION_INVALID, \ 75f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod HB_SCRIPT_INVALID, \ 76f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod HB_LANGUAGE_INVALID, \ 77f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod NULL, \ 78f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod NULL} 79f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 80f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_bool_t 81f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_segment_properties_equal (const hb_segment_properties_t *a, 82f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod const hb_segment_properties_t *b); 83f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 84f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodunsigned int 85f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_segment_properties_hash (const hb_segment_properties_t *p); 86f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 87f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 88f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 89f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod/* 90f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod * hb_buffer_t 91f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod */ 92f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 93f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodtypedef struct hb_buffer_t hb_buffer_t; 94f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 9511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_t * 96e6c09cdf43201ff1b7f38e411ae1f9977e4f9271Behdad Esfahbodhb_buffer_create (void); 979f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 9811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_t * 9980a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbodhb_buffer_get_empty (void); 10080a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbod 10180a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbodhb_buffer_t * 10211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_reference (hb_buffer_t *buffer); 1035c0adce1ccc739415c4b26ff13ffd2d77ea4bc6cBehdad Esfahbod 10411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodvoid 10511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_destroy (hb_buffer_t *buffer); 1069f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 1075fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_bool_t 1085fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_buffer_set_user_data (hb_buffer_t *buffer, 1095fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod hb_user_data_key_t *key, 1105fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod void * data, 11133ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod hb_destroy_func_t destroy, 11233ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod hb_bool_t replace); 1135fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 1145fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodvoid * 1155fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_buffer_get_user_data (hb_buffer_t *buffer, 1165fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod hb_user_data_key_t *key); 1175fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 1189f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 11992f9bfed42f720c1fd78e795845542661aaf4f8aBehdad Esfahbodtypedef enum { 12092f9bfed42f720c1fd78e795845542661aaf4f8aBehdad Esfahbod HB_BUFFER_CONTENT_TYPE_INVALID = 0, 12192f9bfed42f720c1fd78e795845542661aaf4f8aBehdad Esfahbod HB_BUFFER_CONTENT_TYPE_UNICODE, 12292f9bfed42f720c1fd78e795845542661aaf4f8aBehdad Esfahbod HB_BUFFER_CONTENT_TYPE_GLYPHS 12392f9bfed42f720c1fd78e795845542661aaf4f8aBehdad Esfahbod} hb_buffer_content_type_t; 12492f9bfed42f720c1fd78e795845542661aaf4f8aBehdad Esfahbod 125a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbodvoid 12696fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_set_content_type (hb_buffer_t *buffer, 12796fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod hb_buffer_content_type_t content_type); 12896fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 12996fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_content_type_t 13096fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_get_content_type (hb_buffer_t *buffer); 13196fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 13296fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 13396fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodvoid 1345ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_set_unicode_funcs (hb_buffer_t *buffer, 1355ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod hb_unicode_funcs_t *unicode_funcs); 1365ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 1375ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_unicode_funcs_t * 1385ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_get_unicode_funcs (hb_buffer_t *buffer); 1395ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 1405ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodvoid 14111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_set_direction (hb_buffer_t *buffer, 14211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod hb_direction_t direction); 14311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 14411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_direction_t 14511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_get_direction (hb_buffer_t *buffer); 14611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 147ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodvoid 148ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_set_script (hb_buffer_t *buffer, 149ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod hb_script_t script); 150ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 151ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_script_t 152ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_get_script (hb_buffer_t *buffer); 153ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 154ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodvoid 155ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_set_language (hb_buffer_t *buffer, 156ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod hb_language_t language); 157ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 158f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 159ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_language_t 160ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_get_language (hb_buffer_t *buffer); 1619f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 162f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodvoid 163f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_buffer_set_segment_properties (hb_buffer_t *buffer, 164f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod const hb_segment_properties_t *props); 165f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 166f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodvoid 167f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_buffer_get_segment_properties (hb_buffer_t *buffer, 168f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod hb_segment_properties_t *props); 169f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 170f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodvoid 1713f82f8ff07a9d16a7c047129658c1bbedfdb5436Behdad Esfahbodhb_buffer_guess_segment_properties (hb_buffer_t *buffer); 172f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 17392f9bfed42f720c1fd78e795845542661aaf4f8aBehdad Esfahbod 1744dc798de19c767b91fd3025c85593fa6809d1340Behdad Esfahbodtypedef enum { /*< flags >*/ 17511fb16cb849285a178d9e80991b1d60a960326eeBehdad Esfahbod HB_BUFFER_FLAG_DEFAULT = 0x00000000u, 17611fb16cb849285a178d9e80991b1d60a960326eeBehdad Esfahbod HB_BUFFER_FLAG_BOT = 0x00000001u, /* Beginning-of-text */ 17711fb16cb849285a178d9e80991b1d60a960326eeBehdad Esfahbod HB_BUFFER_FLAG_EOT = 0x00000002u, /* End-of-text */ 17811fb16cb849285a178d9e80991b1d60a960326eeBehdad Esfahbod HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004u 17992f9bfed42f720c1fd78e795845542661aaf4f8aBehdad Esfahbod} hb_buffer_flags_t; 18092f9bfed42f720c1fd78e795845542661aaf4f8aBehdad Esfahbod 1810c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodvoid 1820c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_set_flags (hb_buffer_t *buffer, 1830c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod hb_buffer_flags_t flags); 1840c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod 1850c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_flags_t 1860c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_get_flags (hb_buffer_t *buffer); 1870c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod 1885ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 189976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod 190976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod#define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu 191976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod 192976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod/* Sets codepoint used to replace invalid UTF-8/16/32 entries. 193976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * Default is 0xFFFDu. */ 194976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbodvoid 195976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbodhb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, 196976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod hb_codepoint_t replacement); 197976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod 198976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbodhb_codepoint_t 199976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbodhb_buffer_get_replacement_codepoint (hb_buffer_t *buffer); 200976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod 201976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod 202c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod/* Resets the buffer. Afterwards it's as if it was just created, 203c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod * except that it has a larger buffer allocated perhaps... */ 204c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodvoid 205c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_buffer_reset (hb_buffer_t *buffer); 206c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod 207976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod/* Like reset, but does NOT clear unicode_funcs and replacement_codepoint. */ 20882ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbodvoid 2091172dc736280566426eb6dade1a886b2a0ca9aa4Behdad Esfahbodhb_buffer_clear_contents (hb_buffer_t *buffer); 21082ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod 2110594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod/* Returns false if allocation failed */ 212a6a79df5fe2ed2cd307e7a991346faee164e70d9Behdad Esfahbodhb_bool_t 21302a534b23f2d1e7475109563b9f61221ed020e8bRyan Lortiehb_buffer_pre_allocate (hb_buffer_t *buffer, 21402a534b23f2d1e7475109563b9f61221ed020e8bRyan Lortie unsigned int size); 215f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod 216aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod 2170594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod/* Returns false if allocation has failed before */ 218aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbodhb_bool_t 219aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbodhb_buffer_allocation_successful (hb_buffer_t *buffer); 220aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod 221fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbodvoid 222fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbodhb_buffer_reverse (hb_buffer_t *buffer); 223fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod 224ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodvoid 225ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodhb_buffer_reverse_clusters (hb_buffer_t *buffer); 226ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod 227fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod 228fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod/* Filling the buffer in */ 22911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 230f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbodvoid 231f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbodhb_buffer_add (hb_buffer_t *buffer, 232f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbod hb_codepoint_t codepoint, 233f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbod unsigned int cluster); 2349f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 2351b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodvoid 2361b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodhb_buffer_add_utf8 (hb_buffer_t *buffer, 2371b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod const char *text, 238944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 2391b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod unsigned int item_offset, 240944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int item_length); 2411b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod 2421b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodvoid 2431b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodhb_buffer_add_utf16 (hb_buffer_t *buffer, 2441b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod const uint16_t *text, 245944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 2461b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod unsigned int item_offset, 247944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int item_length); 2481b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod 2491b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodvoid 2501b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbodhb_buffer_add_utf32 (hb_buffer_t *buffer, 2511b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod const uint32_t *text, 252944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 2531b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod unsigned int item_offset, 254944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int item_length); 2551b7b97f28ac192006ca5b6d1cc9fbc80fa2bdb55Behdad Esfahbod 256bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod/* Like add_utf32 but does NOT check for invalid Unicode codepoints. */ 257bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbodvoid 258bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbodhb_buffer_add_codepoints (hb_buffer_t *buffer, 259bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod const hb_codepoint_t *text, 260bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod int text_length, 261bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod unsigned int item_offset, 262bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod int item_length); 263bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod 26411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 265c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod/* Clears any new items added at the end */ 266c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_bool_t 267c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_buffer_set_length (hb_buffer_t *buffer, 268c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod unsigned int length); 269fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod 27011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod/* Return value valid as long as buffer not modified */ 27111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodunsigned int 2723d14528b8b2e7da425a9df7057fc9fb326d8298cBehdad Esfahbodhb_buffer_get_length (hb_buffer_t *buffer); 27311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 274c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod/* Getting glyphs out of the buffer */ 275c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod 27611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod/* Return value valid as long as buffer not modified */ 27711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_info_t * 27870566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortiehb_buffer_get_glyph_infos (hb_buffer_t *buffer, 27970566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie unsigned int *length); 28011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 28111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod/* Return value valid as long as buffer not modified */ 28211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_position_t * 28370566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortiehb_buffer_get_glyph_positions (hb_buffer_t *buffer, 28470566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie unsigned int *length); 28502a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod 28602a370697d25b986dbf1d5c38f46a89a4833b495Behdad Esfahbod 28739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod/* Reorders a glyph buffer to have canonical in-cluster glyph order / position. 28839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod * The resulting clusters should behave identical to pre-reordering clusters. 28939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod * NOTE: This has nothing to do with Unicode normalization. */ 29039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodvoid 29139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodhb_buffer_normalize_glyphs (hb_buffer_t *buffer); 29239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 29339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 294c54599ad269380c7aa28d885fcfd660fc2c10a7bBehdad Esfahbod/* 295c54599ad269380c7aa28d885fcfd660fc2c10a7bBehdad Esfahbod * Serialize 296c54599ad269380c7aa28d885fcfd660fc2c10a7bBehdad Esfahbod */ 29739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 2984dc798de19c767b91fd3025c85593fa6809d1340Behdad Esfahbodtypedef enum { /*< flags >*/ 29911fb16cb849285a178d9e80991b1d60a960326eeBehdad Esfahbod HB_BUFFER_SERIALIZE_FLAG_DEFAULT = 0x00000000u, 30011fb16cb849285a178d9e80991b1d60a960326eeBehdad Esfahbod HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS = 0x00000001u, 30111fb16cb849285a178d9e80991b1d60a960326eeBehdad Esfahbod HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS = 0x00000002u, 30211fb16cb849285a178d9e80991b1d60a960326eeBehdad Esfahbod HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES = 0x00000004u 303f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod} hb_buffer_serialize_flags_t; 304f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod 305f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbodtypedef enum { 306f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod HB_BUFFER_SERIALIZE_FORMAT_TEXT = HB_TAG('T','E','X','T'), 307f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod HB_BUFFER_SERIALIZE_FORMAT_JSON = HB_TAG('J','S','O','N'), 308f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod HB_BUFFER_SERIALIZE_FORMAT_INVALID = HB_TAG_NONE 309f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod} hb_buffer_serialize_format_t; 310f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod 311f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod/* len=-1 means str is NUL-terminated. */ 312f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbodhb_buffer_serialize_format_t 313f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbodhb_buffer_serialize_format_from_string (const char *str, int len); 314f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod 315f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbodconst char * 316f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbodhb_buffer_serialize_format_to_string (hb_buffer_serialize_format_t format); 317f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod 318072ae7a982bf640804eee0b41525e7c328806bf5Behdad Esfahbodconst char ** 319072ae7a982bf640804eee0b41525e7c328806bf5Behdad Esfahbodhb_buffer_serialize_list_formats (void); 320072ae7a982bf640804eee0b41525e7c328806bf5Behdad Esfahbod 321f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod/* Returns number of items, starting at start, that were serialized. */ 322f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbodunsigned int 323f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbodhb_buffer_serialize_glyphs (hb_buffer_t *buffer, 324f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod unsigned int start, 325f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod unsigned int end, 326f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod char *buf, 327f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod unsigned int buf_size, 328bcc8f32b4c46cd73f591924c64a6f63df6eaf9e7Behdad Esfahbod unsigned int *buf_consumed, /* May be NULL */ 329f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod hb_font_t *font, /* May be NULL */ 330f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod hb_buffer_serialize_format_t format, 331f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod hb_buffer_serialize_flags_t flags); 332f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod 333f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbodhb_bool_t 334f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbodhb_buffer_deserialize_glyphs (hb_buffer_t *buffer, 335f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod const char *buf, 336e54dd26300f50eb19907a9d39269a363279b3e07Behdad Esfahbod int buf_len, /* -1 means nul-terminated */ 337847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod const char **end_ptr, /* May be NULL */ 338f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod hb_font_t *font, /* May be NULL */ 339f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod hb_buffer_serialize_format_t format); 340f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod 341f9edf1672511c3bcc3796cc79578ffea43b2bda1Behdad Esfahbod 342f96ffd43bce0ac6d9c897933c9be0e51d543e570Behdad EsfahbodHB_END_DECLS 3439f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 3445c0adce1ccc739415c4b26ff13ffd2d77ea4bc6cBehdad Esfahbod#endif /* HB_BUFFER_H */ 345