hb-buffer-private.hh revision bd7378b2ef9793de4e7f57b920f29f48ac9d0c25
1a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod/* 2a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod * Copyright (C) 1998-2004 David Turner and Werner Lemberg 322da7fd94d6318c52df69d70470a85464ffc533dBehdad Esfahbod * Copyright (C) 2004,2007,2009,2010 Red Hat, Inc. 46b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod * 5c755cb3e3ac55156d0d2ec05adea7a650b97cc41Behdad Esfahbod * This is part of HarfBuzz, a text shaping library. 66b347138b597c41af24453f630336ba2fc033dc5Behdad 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. 126b347138b597c41af24453f630336ba2fc033dc5Behdad 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 266b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod */ 27a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod 28da8edbb62204dc39f93d500ef85929e234e0bd19Behdad Esfahbod#ifndef HB_BUFFER_PRIVATE_HH 29da8edbb62204dc39f93d500ef85929e234e0bd19Behdad Esfahbod#define HB_BUFFER_PRIVATE_HH 306b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 313015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod#include "hb-private.h" 325c0adce1ccc739415c4b26ff13ffd2d77ea4bc6cBehdad Esfahbod#include "hb-buffer.h" 335ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod#include "hb-unicode-private.h" 346b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 35f96ffd43bce0ac6d9c897933c9be0e51d543e570Behdad EsfahbodHB_BEGIN_DECLS 366b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 37acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 38c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbod#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF 396b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 4011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 41f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbodtypedef struct _hb_internal_glyph_info_t { 42f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod hb_codepoint_t codepoint; 43468769b8f5332940278244e744ec2bd5a5dc5ee9Behdad Esfahbod hb_mask_t mask; 44f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod uint32_t cluster; 45f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod uint16_t component; 46f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod uint16_t lig_id; 47f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod uint32_t gproperty; 48f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod} hb_internal_glyph_info_t; 49f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod 50f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbodtypedef struct _hb_internal_glyph_position_t { 51f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod hb_position_t x_advance; 52f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod hb_position_t y_advance; 539bef3611f07b45ba8199a4a339c72f49d266216aBehdad Esfahbod hb_position_t x_offset; 549bef3611f07b45ba8199a4a339c72f49d266216aBehdad Esfahbod hb_position_t y_offset; 559db8ad75317d589807e7725455f49cafece58d5dBehdad Esfahbod uint32_t back : 16; /* number of glyphs to go back 56864e2560b627f1e73be3b0635e02f00844cb67c3Behdad Esfahbod for drawing current glyph */ 57864e2560b627f1e73be3b0635e02f00844cb67c3Behdad Esfahbod int32_t cursive_chain : 16; /* character to which this connects, 58c3df649f258b334e93c7626a43cd8ebfbd5a610eBehdad Esfahbod may be positive or negative */ 59f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod} hb_internal_glyph_position_t; 60f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod 61f1322e52d557726baa010be8d35a594748e8fa1aBehdad EsfahbodASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t)); 62f1322e52d557726baa010be8d35a594748e8fa1aBehdad EsfahbodASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t)); 63f1322e52d557726baa010be8d35a594748e8fa1aBehdad EsfahbodASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)); 64f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod 65a7c5046d6b676a32298b97403a49235f7f255161Behdad Esfahbodtypedef struct _hb_segment_properties_t { 66a7c5046d6b676a32298b97403a49235f7f255161Behdad Esfahbod hb_direction_t direction; 67a7c5046d6b676a32298b97403a49235f7f255161Behdad Esfahbod hb_script_t script; 68a7c5046d6b676a32298b97403a49235f7f255161Behdad Esfahbod hb_language_t language; 69a7c5046d6b676a32298b97403a49235f7f255161Behdad Esfahbod} hb_segment_properties_t; 70a7c5046d6b676a32298b97403a49235f7f255161Behdad Esfahbod 71f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod 726b347138b597c41af24453f630336ba2fc033dc5Behdad EsfahbodHB_INTERNAL void 733015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod_hb_buffer_swap (hb_buffer_t *buffer); 746b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 756b347138b597c41af24453f630336ba2fc033dc5Behdad EsfahbodHB_INTERNAL void 763015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod_hb_buffer_clear_output (hb_buffer_t *buffer); 776b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 78c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad EsfahbodHB_INTERNAL void 793015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod_hb_buffer_add_output_glyphs (hb_buffer_t *buffer, 803015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod unsigned int num_in, 813015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod unsigned int num_out, 8225e7ef704633447f109b148620336c42d6fb310eBehdad Esfahbod const hb_codepoint_t *glyph_data, 833015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod unsigned short component, 843015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod unsigned short ligID); 856b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 86c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad EsfahbodHB_INTERNAL void 8725e7ef704633447f109b148620336c42d6fb310eBehdad Esfahbod_hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer, 8825e7ef704633447f109b148620336c42d6fb310eBehdad Esfahbod unsigned int num_in, 8925e7ef704633447f109b148620336c42d6fb310eBehdad Esfahbod unsigned int num_out, 9025e7ef704633447f109b148620336c42d6fb310eBehdad Esfahbod const uint16_t *glyph_data_be, 9125e7ef704633447f109b148620336c42d6fb310eBehdad Esfahbod unsigned short component, 9225e7ef704633447f109b148620336c42d6fb310eBehdad Esfahbod unsigned short ligID); 9325e7ef704633447f109b148620336c42d6fb310eBehdad Esfahbod 9425e7ef704633447f109b148620336c42d6fb310eBehdad EsfahbodHB_INTERNAL void 953015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod_hb_buffer_add_output_glyph (hb_buffer_t *buffer, 963015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod hb_codepoint_t glyph_index, 973015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod unsigned short component, 983015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod unsigned short ligID); 996b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 100c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad EsfahbodHB_INTERNAL void 1013015c4175179a1816aad2a4950da9a3b8baf2578Behdad Esfahbod_hb_buffer_next_glyph (hb_buffer_t *buffer); 1026b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 10378ef65ba08967fe1b5f97bcb27074bd635f4b898Behdad Esfahbod 1041ce7b87c4d8d1ab3ec1d5198351d71b7199f7c64Behdad EsfahbodHB_INTERNAL void 10557ac0ecb7843533b2e6e6d6c8a12b2a44437cc1cBehdad Esfahbod_hb_buffer_reset_masks (hb_buffer_t *buffer, 10657ac0ecb7843533b2e6e6d6c8a12b2a44437cc1cBehdad Esfahbod hb_mask_t mask); 1071ce7b87c4d8d1ab3ec1d5198351d71b7199f7c64Behdad Esfahbod 1081ce7b87c4d8d1ab3ec1d5198351d71b7199f7c64Behdad EsfahbodHB_INTERNAL void 10957ac0ecb7843533b2e6e6d6c8a12b2a44437cc1cBehdad Esfahbod_hb_buffer_add_masks (hb_buffer_t *buffer, 110bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod hb_mask_t mask); 111bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod 112bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad EsfahbodHB_INTERNAL void 113bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod_hb_buffer_set_masks (hb_buffer_t *buffer, 11481c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod hb_mask_t value, 11581c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod hb_mask_t mask, 11681c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod unsigned int cluster_start, 11781c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod unsigned int cluster_end); 1181ce7b87c4d8d1ab3ec1d5198351d71b7199f7c64Behdad Esfahbod 119d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 120d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbodstruct _hb_buffer_t { 121d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod hb_reference_count_t ref_count; 122d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 123d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod /* Information about how the text in the buffer should be treated */ 1244e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod 125a7c5046d6b676a32298b97403a49235f7f255161Behdad Esfahbod hb_unicode_funcs_t *unicode; /* Unicode functions */ 126a7c5046d6b676a32298b97403a49235f7f255161Behdad Esfahbod hb_segment_properties_t props; /* Script, language, direction */ 127d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 128d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod /* Buffer contents */ 129d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 130910a33fe8457a8e13f7eb77fc92fa59c31f5e8fdBehdad Esfahbod unsigned int allocated; /* Length of allocated arrays */ 131d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 132a6a79df5fe2ed2cd307e7a991346faee164e70d9Behdad Esfahbod hb_bool_t have_output; /* Whether we have an output buffer going on */ 133a6a79df5fe2ed2cd307e7a991346faee164e70d9Behdad Esfahbod hb_bool_t have_positions; /* Whether we have positions */ 134a6a79df5fe2ed2cd307e7a991346faee164e70d9Behdad Esfahbod hb_bool_t in_error; /* Allocation failed */ 135910a33fe8457a8e13f7eb77fc92fa59c31f5e8fdBehdad Esfahbod 136910a33fe8457a8e13f7eb77fc92fa59c31f5e8fdBehdad Esfahbod unsigned int i; /* Cursor into ->info and ->pos arrays */ 137910a33fe8457a8e13f7eb77fc92fa59c31f5e8fdBehdad Esfahbod unsigned int len; /* Length of ->info and ->pos arrays */ 138910a33fe8457a8e13f7eb77fc92fa59c31f5e8fdBehdad Esfahbod unsigned int out_len; /* Length of ->out array */ 139d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 1407e7007a1c9bf2c07a8369752126ece8fa6164248Behdad Esfahbod hb_internal_glyph_info_t *info; 1419d5e26df0877aa5b187764ba09bd7bf221e92968Behdad Esfahbod hb_internal_glyph_info_t *out_info; 1421b621823f3e31b48c80cc8b0691dfa873ba086cdBehdad Esfahbod hb_internal_glyph_position_t *pos; 143d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 144d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod /* Other stuff */ 145d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 1461b621823f3e31b48c80cc8b0691dfa873ba086cdBehdad Esfahbod unsigned int max_lig_id; 147d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 148d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 149d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod /* Methods */ 150d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod inline unsigned int allocate_lig_id (void) { return max_lig_id++; } 151d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod inline void swap (void) { _hb_buffer_swap (this); } 1521d5e78013696b10751d8a35027619e81978e1312Behdad Esfahbod inline void clear_output (void) { _hb_buffer_clear_output (this); } 1531d5e78013696b10751d8a35027619e81978e1312Behdad Esfahbod inline void next_glyph (void) { _hb_buffer_next_glyph (this); } 15472071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod inline void add_output_glyphs (unsigned int num_in, 15572071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod unsigned int num_out, 15672071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod const hb_codepoint_t *glyph_data, 15772071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod unsigned short component, 15872071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod unsigned short ligID) 15972071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data, component, ligID); } 16072071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod inline void add_output_glyphs_be16 (unsigned int num_in, 16172071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod unsigned int num_out, 16272071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod const uint16_t *glyph_data_be, 16372071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod unsigned short component, 16472071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod unsigned short ligID) 16572071a8afaba2952fe42be093024ae9dbd37f233Behdad Esfahbod { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be, component, ligID); } 1661d5e78013696b10751d8a35027619e81978e1312Behdad Esfahbod inline void add_output_glyph (hb_codepoint_t glyph_index, 1671d5e78013696b10751d8a35027619e81978e1312Behdad Esfahbod unsigned short component = 0xFFFF, 1681d5e78013696b10751d8a35027619e81978e1312Behdad Esfahbod unsigned short ligID = 0xFFFF) 1691d5e78013696b10751d8a35027619e81978e1312Behdad Esfahbod { _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); } 1701d5e78013696b10751d8a35027619e81978e1312Behdad Esfahbod inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); } 1711ce7b87c4d8d1ab3ec1d5198351d71b7199f7c64Behdad Esfahbod 172bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod inline void reset_masks (hb_mask_t mask) 173bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod { 174bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod for (unsigned int i = 0; i < len; i++) 175bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod info[i].mask = mask; 176bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod } 177bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod inline void add_masks (hb_mask_t mask) 178bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod { 179bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod for (unsigned int i = 0; i < len; i++) 180bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod info[i].mask |= mask; 181bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod } 182bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod inline void set_masks (hb_mask_t value, 18381c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod hb_mask_t mask, 18481c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod unsigned int cluster_start, 18581c5e8724b740c6e42ed3a45e0574c7c5f3ad8e6Behdad Esfahbod unsigned int cluster_end) 186bd7378b2ef9793de4e7f57b920f29f48ac9d0c25Behdad Esfahbod { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); } 1871ce7b87c4d8d1ab3ec1d5198351d71b7199f7c64Behdad Esfahbod 188d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod}; 189d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 190d0316a81f59a4e814b0af78797d915d7ce04d119Behdad Esfahbod 191f96ffd43bce0ac6d9c897933c9be0e51d543e570Behdad EsfahbodHB_END_DECLS 1926b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 193da8edbb62204dc39f93d500ef85929e234e0bd19Behdad Esfahbod#endif /* HB_BUFFER_PRIVATE_HH */ 194