1a2a9a023f6472ba262f89e5327318996b8258d25Behdad Esfahbod/* 22409d5f8d7dd8b535ce5ea29e933f7db27d33793Behdad Esfahbod * Copyright © 1998-2004 David Turner and Werner Lemberg 32409d5f8d7dd8b535ce5ea29e933f7db27d33793Behdad Esfahbod * Copyright © 2004,2007,2009,2010 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. 13a2a9a023f6472ba262f89e5327318996b8258d25Behdad 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 */ 299f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 3022da7fd94d6318c52df69d70470a85464ffc533dBehdad Esfahbod#include "hb-buffer-private.hh" 317f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod#include "hb-utf-private.hh" 329f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 33f1322e52d557726baa010be8d35a594748e8fa1aBehdad Esfahbod 34a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod#ifndef HB_DEBUG_BUFFER 35a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod#define HB_DEBUG_BUFFER (HB_DEBUG+0) 36a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod#endif 37a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod 38f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 39f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_bool_t 40f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_segment_properties_equal (const hb_segment_properties_t *a, 41f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod const hb_segment_properties_t *b) 42f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod{ 43f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod return a->direction == b->direction && 44f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod a->script == b->script && 45f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod a->language == b->language && 46f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod a->reserved1 == b->reserved1 && 47f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod a->reserved2 == b->reserved2; 48f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 49f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod} 50f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 51f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodunsigned int 52f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_segment_properties_hash (const hb_segment_properties_t *p) 53f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod{ 54f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod return (unsigned int) p->direction ^ 55f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod (unsigned int) p->script ^ 56f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod (intptr_t) (p->language); 57f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod} 58f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 59f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 60f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 61a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod/* Here is how the buffer works internally: 62a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod * 63910a33fe8457a8e13f7eb77fc92fa59c31f5e8fdBehdad Esfahbod * There are two info pointers: info and out_info. They always have 64910a33fe8457a8e13f7eb77fc92fa59c31f5e8fdBehdad Esfahbod * the same allocated size, but different lengths. 65a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod * 669d5e26df0877aa5b187764ba09bd7bf221e92968Behdad Esfahbod * As an optimization, both info and out_info may point to the 677e7007a1c9bf2c07a8369752126ece8fa6164248Behdad Esfahbod * same piece of memory, which is owned by info. This remains the 68cc1a8a938b4c13e76b58825a9e1951c4134e634aBehdad Esfahbod * case as long as out_len doesn't exceed i at any time. 69468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod * In that case, swap_buffers() is no-op and the glyph operations operate 70910a33fe8457a8e13f7eb77fc92fa59c31f5e8fdBehdad Esfahbod * mostly in-place. 71a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod * 729d5e26df0877aa5b187764ba09bd7bf221e92968Behdad Esfahbod * As soon as out_info gets longer than info, out_info is moved over 73910a33fe8457a8e13f7eb77fc92fa59c31f5e8fdBehdad Esfahbod * to an alternate buffer (which we reuse the pos buffer for!), and its 74910a33fe8457a8e13f7eb77fc92fa59c31f5e8fdBehdad Esfahbod * current contents (out_len entries) are copied to the new place. 75468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod * This should all remain transparent to the user. swap_buffers() then 76910a33fe8457a8e13f7eb77fc92fa59c31f5e8fdBehdad Esfahbod * switches info and out_info. 77a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod */ 78a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod 79c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbod 80468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 81468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod/* Internal API */ 82468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 83468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodbool 84468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::enlarge (unsigned int size) 853567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod{ 86468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (in_error)) 870594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod return false; 883567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 89468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int new_allocated = allocated; 90e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod hb_glyph_position_t *new_pos = NULL; 91e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod hb_glyph_info_t *new_info = NULL; 92468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod bool separate_out = out_info != info; 933567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 94468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (_hb_unsigned_int_mul_overflows (size, sizeof (info[0])))) 95e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod goto done; 963567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 9738b015e57ffa75d3b078a368c23685beb7c3f946Behdad Esfahbod while (size >= new_allocated) 9865e0063eae2f3adb25315b8bd7b0e7757aa960f3Behdad Esfahbod new_allocated += (new_allocated >> 1) + 32; 993567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 100468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod ASSERT_STATIC (sizeof (info[0]) == sizeof (pos[0])); 101468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (_hb_unsigned_int_mul_overflows (new_allocated, sizeof (info[0])))) 102e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod goto done; 103e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 104468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod new_pos = (hb_glyph_position_t *) realloc (pos, new_allocated * sizeof (pos[0])); 105468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod new_info = (hb_glyph_info_t *) realloc (info, new_allocated * sizeof (info[0])); 1063567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 107e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahboddone: 1083567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod if (unlikely (!new_pos || !new_info)) 1090594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod in_error = true; 1103567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 1113567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod if (likely (new_pos)) 112468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod pos = new_pos; 1133567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 1143567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod if (likely (new_info)) 115468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info = new_info; 116468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 117468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info = separate_out ? (hb_glyph_info_t *) pos : info; 118468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (likely (!in_error)) 119468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod allocated = new_allocated; 120468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 121468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return likely (!in_error); 122468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 123468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 124468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodbool 125468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::make_room_for (unsigned int num_in, 126468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int num_out) 127468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 1280594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod if (unlikely (!ensure (out_len + num_out))) return false; 129468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 130468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (out_info == info && 131468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len + num_out > idx + num_in) 132468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod { 133468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod assert (have_output); 134468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 135468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info = (hb_glyph_info_t *) pos; 136468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod memcpy (out_info, info, out_len * sizeof (out_info[0])); 137468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 138468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 1390594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod return true; 140468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 141468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 1426b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbodbool 1436b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbodhb_buffer_t::shift_forward (unsigned int count) 1446b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod{ 1456b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod assert (have_output); 1466b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod if (unlikely (!ensure (len + count))) return false; 1476b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 1486b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod memmove (info + idx + count, info + idx, (len - idx) * sizeof (info[0])); 1496b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod len += count; 1506b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod idx += count; 1516b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 1526b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod return true; 1536b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod} 1546b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 15568c372ed2eac76a6d347811293fe2ba2fd6a1eedBehdad Esfahbodhb_buffer_t::scratch_buffer_t * 15668c372ed2eac76a6d347811293fe2ba2fd6a1eedBehdad Esfahbodhb_buffer_t::get_scratch_buffer (unsigned int *size) 157e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbod{ 1580594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = false; 1590594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_positions = false; 16047ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod 161e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbod out_len = 0; 16247ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod out_info = info; 16347ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod 164061cb4649342b005fb1de93abae25e889cc560bdBehdad Esfahbod assert ((uintptr_t) pos % sizeof (scratch_buffer_t) == 0); 16568c372ed2eac76a6d347811293fe2ba2fd6a1eedBehdad Esfahbod *size = allocated * sizeof (pos[0]) / sizeof (scratch_buffer_t); 166061cb4649342b005fb1de93abae25e889cc560bdBehdad Esfahbod return (scratch_buffer_t *) (void *) pos; 167e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbod} 168e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbod 169468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 17069cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod 171468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod/* HarfBuzz-Internal API */ 172468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 173468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 174468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::reset (void) 175468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 176468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (hb_object_is_inert (this))) 177468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 178468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 179468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_unicode_funcs_destroy (unicode); 180d5045a5f4017631a4660f985fe451c5a64c42ca0Behdad Esfahbod unicode = hb_unicode_funcs_get_default (); 181976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod replacement = HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT; 182468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 18382ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod clear (); 18482ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod} 18582ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod 18682ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbodvoid 18782ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbodhb_buffer_t::clear (void) 18882ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod{ 18982ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod if (unlikely (hb_object_is_inert (this))) 19082ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod return; 19182ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod 192f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT; 193f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod props = default_props; 1944dc798de19c767b91fd3025c85593fa6809d1340Behdad Esfahbod flags = HB_BUFFER_FLAG_DEFAULT; 195468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 19696fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod content_type = HB_BUFFER_CONTENT_TYPE_INVALID; 1970594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod in_error = false; 1980594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = false; 1990594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_positions = false; 2003567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 201468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod idx = 0; 202468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod len = 0; 203468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len = 0; 20447ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod out_info = info; 2053567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 206468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod serial = 0; 207f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod memset (allocated_var_bytes, 0, sizeof allocated_var_bytes); 208f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod memset (allocated_var_owner, 0, sizeof allocated_var_owner); 20905207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 21005207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod memset (context, 0, sizeof context); 21105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod memset (context_len, 0, sizeof context_len); 2123567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod} 2133567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 214468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 215468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::add (hb_codepoint_t codepoint, 216468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int cluster) 2173567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod{ 218468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_info_t *glyph; 219468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 220468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (!ensure (len + 1))) return; 221468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 222468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod glyph = &info[len]; 223468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 224468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod memset (glyph, 0, sizeof (*glyph)); 225468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod glyph->codepoint = codepoint; 22666ac2ff32e24f0d5658ca172147613081a133847Behdad Esfahbod glyph->mask = 1; 227468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod glyph->cluster = cluster; 228468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 229468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod len++; 2303567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod} 2316b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 232468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 233847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbodhb_buffer_t::add_info (const hb_glyph_info_t &glyph_info) 234847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod{ 235847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod if (unlikely (!ensure (len + 1))) return; 236847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 237847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod info[len] = glyph_info; 238847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 239847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod len++; 240847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod} 241847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 242847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 243847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbodvoid 2440bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbodhb_buffer_t::remove_output (void) 2450bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod{ 2460bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod if (unlikely (hb_object_is_inert (this))) 2470bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod return; 2480bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod 2490bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod have_output = false; 2500bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod have_positions = false; 2510bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod 2520bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod out_len = 0; 2530bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod out_info = info; 2540bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod} 2550bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod 2560bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbodvoid 257468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::clear_output (void) 258c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbod{ 259468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (hb_object_is_inert (this))) 260468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 261468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 2620594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = true; 2630594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_positions = false; 264a6a79df5fe2ed2cd307e7a991346faee164e70d9Behdad Esfahbod 265468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len = 0; 266468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info = info; 267468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 268468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 269468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 270468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::clear_positions (void) 271468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 272468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (hb_object_is_inert (this))) 273468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 274468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 2750594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = false; 2760594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_positions = true; 277468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 27847ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod out_len = 0; 27947ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod out_info = info; 28047ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod 281468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod memset (pos, 0, sizeof (pos[0]) * len); 282468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 283468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 284468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 285468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::swap_buffers (void) 286468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 287468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (in_error)) return; 288468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 289468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod assert (have_output); 2900594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = false; 291468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 292468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (out_info != info) 293e35bbd570a5d914f86f1ea83941ee4328f268059Behdad Esfahbod { 294468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_info_t *tmp_string; 295468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod tmp_string = info; 296468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info = out_info; 297468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info = tmp_string; 298468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod pos = (hb_glyph_position_t *) out_info; 299468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 300468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 301468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int tmp; 302468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod tmp = len; 303468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod len = out_len; 304468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len = tmp; 305468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 306468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod idx = 0; 307468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 308e35bbd570a5d914f86f1ea83941ee4328f268059Behdad Esfahbod 30969cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod 310468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 3119ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbodhb_buffer_t::replace_glyphs (unsigned int num_in, 3129ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod unsigned int num_out, 3138e3715f8a16b315c1c7dd4b256e7f68a36c53e7cBehdad Esfahbod const uint32_t *glyph_data) 3149ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod{ 31569cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (num_in, num_out))) return; 3169ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 317e88e14421a33ca5bdfd76bc0b2f801fcb6e78911Behdad Esfahbod merge_clusters (idx, idx + num_in); 3189ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 319e88e14421a33ca5bdfd76bc0b2f801fcb6e78911Behdad Esfahbod hb_glyph_info_t orig_info = info[idx]; 3209ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod hb_glyph_info_t *pinfo = &out_info[out_len]; 3219ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod for (unsigned int i = 0; i < num_out; i++) 3229ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod { 3239ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod *pinfo = orig_info; 3249ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod pinfo->codepoint = glyph_data[i]; 3259ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod pinfo++; 3269ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod } 3279ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 3289ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod idx += num_in; 3299ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod out_len += num_out; 3309ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod} 3319ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 3329ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbodvoid 333468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::output_glyph (hb_codepoint_t glyph_index) 334468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 33569cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (0, 1))) return; 336468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 337468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len] = info[idx]; 338468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len].codepoint = glyph_index; 339468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 340468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len++; 341468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 342468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 343468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 344847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbodhb_buffer_t::output_info (const hb_glyph_info_t &glyph_info) 345b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod{ 346b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod if (unlikely (!make_room_for (0, 1))) return; 347b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod 348b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod out_info[out_len] = glyph_info; 349b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod 350b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod out_len++; 351b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod} 352b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod 353b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbodvoid 354468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::copy_glyph (void) 355468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 35669cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (0, 1))) return; 357468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 358468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len] = info[idx]; 359468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 360468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len++; 361468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 362468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 3636b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbodbool 3646b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbodhb_buffer_t::move_to (unsigned int i) 3656b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod{ 3666b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod if (!have_output) 3676b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod { 3686b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod assert (i <= len); 3696b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod idx = i; 370da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod return true; 3716b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod } 372da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod 373da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod assert (i <= out_len + (len - idx)); 374da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod 375da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod if (out_len < i) 3766b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod { 3776b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod unsigned int count = i - out_len; 3786b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod if (unlikely (!make_room_for (count, count))) return false; 3796b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 3806b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod memmove (out_info + out_len, info + idx, count * sizeof (out_info[0])); 3816b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod idx += count; 3826b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod out_len += count; 3836b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod } 3846b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod else if (out_len > i) 3856b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod { 3866b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod /* Tricky part: rewinding... */ 3876b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod unsigned int count = out_len - i; 3886b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 3896b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod if (unlikely (idx < count && !shift_forward (count + 32))) return false; 3906b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 3916b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod assert (idx >= count); 3926b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 3936b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod idx -= count; 3946b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod out_len -= count; 3956b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod memmove (info + idx, out_info + out_len, count * sizeof (out_info[0])); 3966b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod } 397da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod 3986b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod return true; 3996b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod} 4006b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 401468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 402468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::replace_glyph (hb_codepoint_t glyph_index) 403468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 40469cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (out_info != info || out_len != idx)) { 40569cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (1, 1))) return; 40669cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod out_info[out_len] = info[idx]; 40769cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod } 408468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len].codepoint = glyph_index; 409468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 410468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod idx++; 411468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len++; 412468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 413468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 41469cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod 415468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 416468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::set_masks (hb_mask_t value, 417468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_mask_t mask, 418468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int cluster_start, 419468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int cluster_end) 420468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 421468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_mask_t not_mask = ~mask; 422468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod value &= mask; 423468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 424468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (!mask) 425468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 426468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 427468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (cluster_start == 0 && cluster_end == (unsigned int)-1) { 428468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int count = len; 429468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (unsigned int i = 0; i < count; i++) 430468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[i].mask = (info[i].mask & not_mask) | value; 431468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 432468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 433468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 434468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int count = len; 435468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (unsigned int i = 0; i < count; i++) 436468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (cluster_start <= info[i].cluster && info[i].cluster < cluster_end) 437468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[i].mask = (info[i].mask & not_mask) | value; 438468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 439468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 440468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 441468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::reverse_range (unsigned int start, 442468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int end) 443468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 444468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int i, j; 445468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 446468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (start == end - 1) 447468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 448468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 449468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (i = start, j = end - 1; i < j; i++, j--) { 450468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_info_t t; 451468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 452468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod t = info[i]; 453468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[i] = info[j]; 454468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[j] = t; 455468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 456468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 457468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (pos) { 458468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (i = start, j = end - 1; i < j; i++, j--) { 459468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_position_t t; 460468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 461468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod t = pos[i]; 462468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod pos[i] = pos[j]; 463468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod pos[j] = t; 464468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 465468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 466468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 467468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 468468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 469468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::reverse (void) 470468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 471468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (!len)) 472468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 473468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 474468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse_range (0, len); 475468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 476468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 477468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 478468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::reverse_clusters (void) 479468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 480468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int i, start, count, last_cluster; 481468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 482468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (!len)) 483468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 484468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 485468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse (); 486468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 487468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod count = len; 488468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod start = 0; 489468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod last_cluster = info[0].cluster; 490468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (i = 1; i < count; i++) { 491468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (last_cluster != info[i].cluster) { 492468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse_range (start, i); 493468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod start = i; 494468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod last_cluster = info[i].cluster; 495468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 496468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 497468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse_range (start, i); 498a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod} 499a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod 50002aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbodvoid 501d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodhb_buffer_t::merge_clusters (unsigned int start, 502d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod unsigned int end) 503d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod{ 50466c6a48b6ce9dab6375ba1a23d7e450d6974852aBehdad Esfahbod#ifdef HB_NO_MERGE_CLUSTERS 50566c6a48b6ce9dab6375ba1a23d7e450d6974852aBehdad Esfahbod return; 50666c6a48b6ce9dab6375ba1a23d7e450d6974852aBehdad Esfahbod#endif 50766c6a48b6ce9dab6375ba1a23d7e450d6974852aBehdad Esfahbod 508fe3dabc08df7501010564f8844bd4d11771cc6a4Behdad Esfahbod if (unlikely (end - start < 2)) 509cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod return; 510cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod 511cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod unsigned int cluster = info[start].cluster; 512d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod 513d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start + 1; i < end; i++) 514cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod cluster = MIN (cluster, info[i].cluster); 515cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod 516cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod /* Extend end */ 517cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod while (end < len && info[end - 1].cluster == info[end].cluster) 518cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod end++; 519cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod 520cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod /* Extend start */ 521cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod while (idx < start && info[start - 1].cluster == info[start].cluster) 522cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod start--; 523cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod 524cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod /* If we hit the start of buffer, continue in out-buffer. */ 525cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod if (idx == start) 526cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod for (unsigned i = out_len; i && out_info[i - 1].cluster == info[start].cluster; i--) 527cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod out_info[i - 1].cluster = cluster; 528cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod 529d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start; i < end; i++) 530cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod info[i].cluster = cluster; 531d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod} 532d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodvoid 533d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodhb_buffer_t::merge_out_clusters (unsigned int start, 534d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod unsigned int end) 535d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod{ 53666c6a48b6ce9dab6375ba1a23d7e450d6974852aBehdad Esfahbod#ifdef HB_NO_MERGE_CLUSTERS 53766c6a48b6ce9dab6375ba1a23d7e450d6974852aBehdad Esfahbod return; 53866c6a48b6ce9dab6375ba1a23d7e450d6974852aBehdad Esfahbod#endif 53966c6a48b6ce9dab6375ba1a23d7e450d6974852aBehdad Esfahbod 540fe3dabc08df7501010564f8844bd4d11771cc6a4Behdad Esfahbod if (unlikely (end - start < 2)) 54172c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod return; 54272c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod 543cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod unsigned int cluster = out_info[start].cluster; 544d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod 545d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start + 1; i < end; i++) 546cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod cluster = MIN (cluster, out_info[i].cluster); 54772c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod 54872c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod /* Extend start */ 54972c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod while (start && out_info[start - 1].cluster == out_info[start].cluster) 55072c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod start--; 55172c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod 5525ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod /* Extend end */ 5535ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod while (end < out_len && out_info[end - 1].cluster == out_info[end].cluster) 5545ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod end++; 5555ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod 556e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod /* If we hit the end of out-buffer, continue in buffer. */ 557e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod if (end == out_len) 558e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod for (unsigned i = idx; i < len && info[i].cluster == out_info[end - 1].cluster; i++) 559e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod info[i].cluster = cluster; 560e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod 561d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start; i < end; i++) 562cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod out_info[i].cluster = cluster; 563d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod} 564d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod 565d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodvoid 5663f82f8ff07a9d16a7c047129658c1bbedfdb5436Behdad Esfahbodhb_buffer_t::guess_segment_properties (void) 56702aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod{ 5688465a05a89742295d4b009a9b4442eb0a899fd80Behdad Esfahbod assert (content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || 5698465a05a89742295d4b009a9b4442eb0a899fd80Behdad Esfahbod (!len && content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); 57096fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 57102aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* If script is set to INVALID, guess from buffer contents */ 57202aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (props.script == HB_SCRIPT_INVALID) { 57302aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod for (unsigned int i = 0; i < len; i++) { 574208f70f0553d73d2908b21b9552298029482a8b9Behdad Esfahbod hb_script_t script = unicode->script (info[i].codepoint); 57502aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (likely (script != HB_SCRIPT_COMMON && 57602aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod script != HB_SCRIPT_INHERITED && 57702aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod script != HB_SCRIPT_UNKNOWN)) { 57802aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod props.script = script; 57902aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod break; 58002aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 58102aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 58202aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 58302aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 58402aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* If direction is set to INVALID, guess from script */ 58502aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (props.direction == HB_DIRECTION_INVALID) { 58602aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod props.direction = hb_script_get_horizontal_direction (props.script); 58702aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 58802aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 58902aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* If language is not set, use default language from locale */ 59002aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (props.language == HB_LANGUAGE_INVALID) { 59102aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* TODO get_default_for_script? using $LANGUAGE */ 59202aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod props.language = hb_language_get_default (); 59302aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 59402aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod} 59502aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 59602aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 597a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbodstatic inline void 598a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahboddump_var_allocation (const hb_buffer_t *buffer) 599a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod{ 600a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod char buf[80]; 601a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod for (unsigned int i = 0; i < 8; i++) 602b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod buf[i] = '0' + buffer->allocated_var_bytes[7 - i]; 603a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod buf[8] = '\0'; 604a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod DEBUG_MSG (BUFFER, buffer, 605a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod "Current var allocation: %s", 606a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod buf); 607a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod} 6083567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 609f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbodvoid hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const char *owner) 610f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod{ 611b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (byte_i < 8 && byte_i + count <= 8); 612a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod 6136c15ddfe2b45383824b64058ae69939d002183a6Behdad Esfahbod if (DEBUG_ENABLED (BUFFER)) 614a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod dump_var_allocation (this); 615a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod DEBUG_MSG (BUFFER, this, 616a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod "Allocating var bytes %d..%d for %s", 617a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod byte_i, byte_i + count - 1, owner); 618a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod 619f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod for (unsigned int i = byte_i; i < byte_i + count; i++) { 620f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod assert (!allocated_var_bytes[i]); 621f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod allocated_var_bytes[i]++; 622f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod allocated_var_owner[i] = owner; 623f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod } 624f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod} 625f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod 626f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbodvoid hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const char *owner) 627f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod{ 6286c15ddfe2b45383824b64058ae69939d002183a6Behdad Esfahbod if (DEBUG_ENABLED (BUFFER)) 629b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod dump_var_allocation (this); 630b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod 631a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod DEBUG_MSG (BUFFER, this, 632a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod "Deallocating var bytes %d..%d for %s", 633a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod byte_i, byte_i + count - 1, owner); 634a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod 635b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (byte_i < 8 && byte_i + count <= 8); 636f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod for (unsigned int i = byte_i; i < byte_i + count; i++) { 637b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (allocated_var_bytes[i]); 638b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (0 == strcmp (allocated_var_owner[i], owner)); 639f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod allocated_var_bytes[i]--; 640f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod } 641f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod} 642f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod 643965c280de09b49d711cb78d629da321c802084deBehdad Esfahbodvoid hb_buffer_t::assert_var (unsigned int byte_i, unsigned int count, const char *owner) 644965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod{ 6456c15ddfe2b45383824b64058ae69939d002183a6Behdad Esfahbod if (DEBUG_ENABLED (BUFFER)) 646965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod dump_var_allocation (this); 647965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod 648965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod DEBUG_MSG (BUFFER, this, 649965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod "Asserting var bytes %d..%d for %s", 650965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod byte_i, byte_i + count - 1, owner); 651965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod 652965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod assert (byte_i < 8 && byte_i + count <= 8); 653965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod for (unsigned int i = byte_i; i < byte_i + count; i++) { 654965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod assert (allocated_var_bytes[i]); 655965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod assert (0 == strcmp (allocated_var_owner[i], owner)); 656965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod } 657965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod} 658965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod 659a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbodvoid hb_buffer_t::deallocate_var_all (void) 660a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod{ 661a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes)); 662a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod memset (allocated_var_owner, 0, sizeof (allocated_var_owner)); 663a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod} 664f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod 6656b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod/* Public API */ 6666b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 667288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 668085d4291a9f253a4b8e2eec8003ac11d02a9394fBehdad Esfahbod * hb_buffer_create: (Xconstructor) 669288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 670288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 671288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 672288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: (transfer full) 673288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 674288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 675288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 676b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbodhb_buffer_t * 677c54599ad269380c7aa28d885fcfd660fc2c10a7bBehdad Esfahbodhb_buffer_create (void) 6789f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod{ 679b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod hb_buffer_t *buffer; 680b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod 68147e71d9661946a4ffb96026bf1d697d788414ab5Behdad Esfahbod if (!(buffer = hb_object_create<hb_buffer_t> ())) 682f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod return hb_buffer_get_empty (); 6839f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 684468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reset (); 6855ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 68611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod return buffer; 68711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 6887a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod 689288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 690288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_empty: 691288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 692288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 693288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 694288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: (transfer full): 695288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 696288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 697288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 69811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_t * 69980a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbodhb_buffer_get_empty (void) 70080a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbod{ 701f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod static const hb_buffer_t _hb_buffer_nil = { 702f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod HB_OBJECT_HEADER_STATIC, 703f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod 704d5045a5f4017631a4660f985fe451c5a64c42ca0Behdad Esfahbod const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil), 705f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod HB_SEGMENT_PROPERTIES_DEFAULT, 7064dc798de19c767b91fd3025c85593fa6809d1340Behdad Esfahbod HB_BUFFER_FLAG_DEFAULT, 707976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT, 708f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod 70996fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod HB_BUFFER_CONTENT_TYPE_INVALID, 7100594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod true, /* in_error */ 7110594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod true, /* have_output */ 7120594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod true /* have_positions */ 71305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 71405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod /* Zero is good enough for everything else. */ 715f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod }; 716f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod 717f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod return const_cast<hb_buffer_t *> (&_hb_buffer_nil); 71880a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbod} 71980a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbod 720288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 721288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_reference: (skip) 722288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 723288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 724288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 725288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 726288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: (transfer full): 727288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 728288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 729288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 73080a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbodhb_buffer_t * 73111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_reference (hb_buffer_t *buffer) 73211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 73347e71d9661946a4ffb96026bf1d697d788414ab5Behdad Esfahbod return hb_object_reference (buffer); 73411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 735f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod 736288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 737288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_destroy: (skip) 738288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 739288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 740288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 741288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 742288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 743288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 7447a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbodvoid 74511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_destroy (hb_buffer_t *buffer) 7467a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod{ 74747e71d9661946a4ffb96026bf1d697d788414ab5Behdad Esfahbod if (!hb_object_destroy (buffer)) return; 74811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 7495ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod hb_unicode_funcs_destroy (buffer->unicode); 7505ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 7517e7007a1c9bf2c07a8369752126ece8fa6164248Behdad Esfahbod free (buffer->info); 7521b621823f3e31b48c80cc8b0691dfa873ba086cdBehdad Esfahbod free (buffer->pos); 75311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 754b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod free (buffer); 7557a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod} 7567a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod 757288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 758288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_user_data: (skip) 759288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 760288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @key: 761288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @data: 762288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @destroy: 763288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @replace: 764288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 765288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 766288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 767288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 768288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 769288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 770288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 7715fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_bool_t 7725fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_buffer_set_user_data (hb_buffer_t *buffer, 7735fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod hb_user_data_key_t *key, 7745fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod void * data, 77533ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod hb_destroy_func_t destroy, 77633ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod hb_bool_t replace) 7775fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod{ 77833ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod return hb_object_set_user_data (buffer, key, data, destroy, replace); 7795fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod} 7805fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 781288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 782288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_user_data: (skip) 783288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 784288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @key: 785288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 786288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 787288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 788288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 789288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 790288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 791288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 7925fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodvoid * 7935fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_buffer_get_user_data (hb_buffer_t *buffer, 7945fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod hb_user_data_key_t *key) 7955fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod{ 7965fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod return hb_object_get_user_data (buffer, key); 7975fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod} 7985fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 7995ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 800288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 801288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_content_type: 802288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 803288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @content_type: 804288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 805288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 806288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 807288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 808288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 8095ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodvoid 81096fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_set_content_type (hb_buffer_t *buffer, 81196fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod hb_buffer_content_type_t content_type) 81296fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod{ 81396fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod buffer->content_type = content_type; 81496fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod} 81596fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 816288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 817288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_content_type: 818288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 819288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 820288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 821288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 822288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 823288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 824288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 825288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 82696fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_content_type_t 82796fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_get_content_type (hb_buffer_t *buffer) 82896fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod{ 82996fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod return buffer->content_type; 83096fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod} 83196fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 83296fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 833288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 834288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_unicode_funcs: 835288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 836288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @unicode_funcs: 837288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 838288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 839288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 840288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 841288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 84296fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodvoid 8435ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_set_unicode_funcs (hb_buffer_t *buffer, 844288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod hb_unicode_funcs_t *unicode_funcs) 8455ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 846e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 847e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 848e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 849288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod if (!unicode_funcs) 850288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod unicode_funcs = hb_unicode_funcs_get_default (); 851d5045a5f4017631a4660f985fe451c5a64c42ca0Behdad Esfahbod 8520465e69832393cc1ed36508ec5d597fbab64877aBehdad Esfahbod 853288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod hb_unicode_funcs_reference (unicode_funcs); 8545ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod hb_unicode_funcs_destroy (buffer->unicode); 855288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod buffer->unicode = unicode_funcs; 8565ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 8575ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 858288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 859288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_unicode_funcs: 860288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 861288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 862288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 863288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 864288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 865288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 866288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 867288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 8685ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_unicode_funcs_t * 8695ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_get_unicode_funcs (hb_buffer_t *buffer) 8705ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 8715ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod return buffer->unicode; 8725ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 8735ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 874288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 875288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_direction: 876288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 877288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @direction: 878288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 879288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 880288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 881288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 882288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 8835ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodvoid 8845ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_set_direction (hb_buffer_t *buffer, 8855ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod hb_direction_t direction) 8865ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 8875ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 888e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 889e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 890e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 8914e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod buffer->props.direction = direction; 8925ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 8935ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 894288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 895288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_direction: 896288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 897288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 898288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 899288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 900288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 901288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 902288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 903288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 9045ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_direction_t 9055ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_get_direction (hb_buffer_t *buffer) 9065ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 9074e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod return buffer->props.direction; 9085ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 9095ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 910288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 911288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_script: 912288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 913288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @script: 914288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 915288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 916288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 917288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 918288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 919ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodvoid 920ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_set_script (hb_buffer_t *buffer, 921ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod hb_script_t script) 922ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 923e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 924e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 925e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 9264e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod buffer->props.script = script; 927ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 928ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 929288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 930288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_script: 931288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 932288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 933288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 934288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 935288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 936288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 937288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 938288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 939ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_script_t 940ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_get_script (hb_buffer_t *buffer) 941ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 9424e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod return buffer->props.script; 943ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 944ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 945288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 946288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_language: 947288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 948288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @language: 949288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 950288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 951288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 952288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 953288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 954ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodvoid 955ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_set_language (hb_buffer_t *buffer, 956ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod hb_language_t language) 957ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 958e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 959e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 960e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 9614e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod buffer->props.language = language; 962ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 963ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 964288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 965288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_language: 966288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 967288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 968288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 969288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 970288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 971288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 972288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 973288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 974ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_language_t 975ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_get_language (hb_buffer_t *buffer) 976ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 9774e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod return buffer->props.language; 978ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 979ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 980288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 981288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_segment_properties: 982288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 983288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @props: 984288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 985288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 986288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 987288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 988288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 9890c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodvoid 990f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_buffer_set_segment_properties (hb_buffer_t *buffer, 991f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod const hb_segment_properties_t *props) 992f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod{ 993f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 994f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod return; 995f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 996f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod buffer->props = *props; 997f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod} 998f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 999288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1000288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_segment_properties: 1001288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1002288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @props: 1003288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1004288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1005288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1006288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1007288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1008f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodvoid 1009f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_buffer_get_segment_properties (hb_buffer_t *buffer, 1010f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod hb_segment_properties_t *props) 1011f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod{ 1012f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod *props = buffer->props; 1013f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod} 1014f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 1015f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 1016288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1017288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_flags: 1018288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1019288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @flags: 1020288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1021288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1022288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1023288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1024288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1025f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodvoid 10260c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_set_flags (hb_buffer_t *buffer, 10270c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod hb_buffer_flags_t flags) 10280c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod{ 10290c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 10300c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod return; 10310c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod 10320c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod buffer->flags = flags; 10330c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod} 10340c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod 1035288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1036288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_flags: 1037288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1038288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1039288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1040288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1041288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 1042288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1043288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1044288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 10450c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_flags_t 10460c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_get_flags (hb_buffer_t *buffer) 10470c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod{ 10480c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod return buffer->flags; 10490c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod} 10500c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod 10515ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 1052288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1053976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * hb_buffer_set_replacement_codepoint: 1054976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * @buffer: a buffer. 1055976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * @replacement: 1056976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * 1057976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * 1058976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * 1059976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * Since: 1.0 1060976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod **/ 1061976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbodvoid 1062976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbodhb_buffer_set_replacement_codepoint (hb_buffer_t *buffer, 1063976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod hb_codepoint_t replacement) 1064976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod{ 1065976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 1066976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod return; 1067976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod 1068976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod buffer->replacement = replacement; 1069976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod} 1070976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod 1071976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod/** 1072976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * hb_buffer_get_replacement_codepoint: 1073976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * @buffer: a buffer. 1074976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * 1075976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * 1076976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * 1077976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * Return value: 1078976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * 1079976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod * Since: 1.0 1080976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod **/ 1081976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbodhb_codepoint_t 1082976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbodhb_buffer_get_replacement_codepoint (hb_buffer_t *buffer) 1083976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod{ 1084976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod return buffer->replacement; 1085976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod} 1086976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod 1087976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod 1088976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod/** 1089288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_reset: 1090288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1091288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1092288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1093288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1094288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1095288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 10967a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbodvoid 1097c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_buffer_reset (hb_buffer_t *buffer) 1098c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod{ 1099468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reset (); 11007a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod} 11017a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod 1102288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1103288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_clear_contents: 1104288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1105288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1106288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1107288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1108288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1109288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 111082ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbodvoid 11111172dc736280566426eb6dade1a886b2a0ca9aa4Behdad Esfahbodhb_buffer_clear_contents (hb_buffer_t *buffer) 111282ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod{ 111382ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod buffer->clear (); 111482ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod} 111582ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod 1116288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1117288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_pre_allocate: 1118288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1119288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @size: 1120288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1121288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1122288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1123288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 1124288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1125288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1126288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1127a6a79df5fe2ed2cd307e7a991346faee164e70d9Behdad Esfahbodhb_bool_t 112802a534b23f2d1e7475109563b9f61221ed020e8bRyan Lortiehb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size) 1129f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod{ 1130468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return buffer->ensure (size); 1131f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod} 1132f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod 1133288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1134288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_allocation_successful: 1135288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1136288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1137288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1138288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1139288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 1140288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1141288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1142288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1143aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbodhb_bool_t 1144aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbodhb_buffer_allocation_successful (hb_buffer_t *buffer) 1145aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod{ 1146aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod return !buffer->in_error; 1147aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod} 1148aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod 1149288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1150288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add: 1151288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1152288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @codepoint: 1153288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @cluster: 1154288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1155288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1156288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1157288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1158288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1159f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbodvoid 1160f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbodhb_buffer_add (hb_buffer_t *buffer, 1161f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbod hb_codepoint_t codepoint, 1162f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbod unsigned int cluster) 11636b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod{ 116466ac2ff32e24f0d5658ca172147613081a133847Behdad Esfahbod buffer->add (codepoint, cluster); 116505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (1); 11669111b21ef99d5e53348176f683261b0101eb427fBehdad Esfahbod} 11679111b21ef99d5e53348176f683261b0101eb427fBehdad Esfahbod 1168288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1169288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_length: 1170288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1171288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @length: 1172288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1173288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1174288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1175288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 1176288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1177288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1178288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1179c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_bool_t 1180c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_buffer_set_length (hb_buffer_t *buffer, 1181c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod unsigned int length) 1182c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod{ 1183e1ac38f8dd04c29d2d4140f5a492cdaf25d72901Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 1184e1ac38f8dd04c29d2d4140f5a492cdaf25d72901Behdad Esfahbod return length == 0; 1185e1ac38f8dd04c29d2d4140f5a492cdaf25d72901Behdad Esfahbod 1186468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (!buffer->ensure (length)) 11870594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod return false; 1188c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod 1189c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod /* Wipe the new space */ 1190c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod if (length > buffer->len) { 1191c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod memset (buffer->info + buffer->len, 0, sizeof (buffer->info[0]) * (length - buffer->len)); 1192c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod if (buffer->have_positions) 1193c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod memset (buffer->pos + buffer->len, 0, sizeof (buffer->pos[0]) * (length - buffer->len)); 1194c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod } 1195c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod 1196c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod buffer->len = length; 119705207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 119805207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod if (!length) 119902c6c8cd6e8c93b63c75b25de6bf76bb45755bb4Behdad Esfahbod { 120002c6c8cd6e8c93b63c75b25de6bf76bb45755bb4Behdad Esfahbod buffer->content_type = HB_BUFFER_CONTENT_TYPE_INVALID; 120105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (0); 120202c6c8cd6e8c93b63c75b25de6bf76bb45755bb4Behdad Esfahbod } 120305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (1); 120405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 12050594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod return true; 1206c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod} 1207c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod 12085f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 12095f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_get_length: 12105f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 12115f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12125f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Returns the number of items in the buffer. 12135f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12145f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Return value: buffer length. 12155f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12165f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1217c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 121811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodunsigned int 12193d14528b8b2e7da425a9df7057fc9fb326d8298cBehdad Esfahbodhb_buffer_get_length (hb_buffer_t *buffer) 122011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 12216960350be97f24e97140391025b56369c393a3dfBehdad Esfahbod return buffer->len; 122211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 122311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 12245f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 12255f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_get_glyph_infos: 12265f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 12275f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @length: (out): output array length. 12285f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12295f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Returns buffer glyph information array. Returned pointer 12305f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * is valid as long as buffer contents are not modified. 12315f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12325f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Return value: (transfer none) (array length=length): buffer glyph information array. 12335f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12345f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1235c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 123611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_info_t * 123770566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortiehb_buffer_get_glyph_infos (hb_buffer_t *buffer, 123870566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie unsigned int *length) 123911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 124070566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie if (length) 124170566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie *length = buffer->len; 124270566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie 12437e7007a1c9bf2c07a8369752126ece8fa6164248Behdad Esfahbod return (hb_glyph_info_t *) buffer->info; 124411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 124511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 12465f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 12475f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_get_glyph_positions: 12485f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 12495f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @length: (out): output length. 12505f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12515f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Returns buffer glyph position array. Returned pointer 12525f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * is valid as long as buffer contents are not modified. 12535f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12545f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Return value: (transfer none) (array length=length): buffer glyph position array. 12555f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12565f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1257c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 125811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_position_t * 125970566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortiehb_buffer_get_glyph_positions (hb_buffer_t *buffer, 126070566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie unsigned int *length) 126111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 1262314905d7548d5be58354546d660754b807b6efb2Behdad Esfahbod if (!buffer->have_positions) 1263468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->clear_positions (); 126411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 126570566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie if (length) 126670566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie *length = buffer->len; 126770566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie 12681b621823f3e31b48c80cc8b0691dfa873ba086cdBehdad Esfahbod return (hb_glyph_position_t *) buffer->pos; 126911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 1270fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod 12715f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 12725f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_reverse: 12735f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 12745f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12755f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Reverses buffer contents. 12765f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12775f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1278c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 1279ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodvoid 1280ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodhb_buffer_reverse (hb_buffer_t *buffer) 1281ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod{ 1282468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reverse (); 1283ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod} 1284ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod 12855f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 12865f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_reverse_clusters: 12875f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 12885f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12895f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Reverses buffer clusters. That is, the buffer contents are 12905f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * reversed, then each cluster (consecutive items having the 12915f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * same cluster number) are reversed again. 12925f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12935f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1294c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 1295ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodvoid 1296ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodhb_buffer_reverse_clusters (hb_buffer_t *buffer) 1297ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod{ 1298468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reverse_clusters (); 1299ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod} 1300ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod 13015f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 13025f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_guess_segment_properties: 13035f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 13045f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 13055f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Sets unset buffer segment properties based on buffer Unicode 13065f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * contents. If buffer is not empty, it must have content type 13075f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * %HB_BUFFER_CONTENT_TYPE_UNICODE. 13085f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 13095f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * If buffer script is not set (ie. is %HB_SCRIPT_INVALID), it 13105f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * will be set to the Unicode script of the first character in 13115f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * the buffer that has a script other than %HB_SCRIPT_COMMON, 13125f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * %HB_SCRIPT_INHERITED, and %HB_SCRIPT_UNKNOWN. 13135f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 13145f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Next, if buffer direction is not set (ie. is %HB_DIRECTION_INVALID), 13155f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * it will be set to the natural horizontal direction of the 13165f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * buffer script as returned by hb_script_get_horizontal_direction(). 13175f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 13185f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Finally, if buffer language is not set (ie. is %HB_LANGUAGE_INVALID), 13195f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * it will be set to the process's default language as returned by 13205f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_language_get_default(). This may change in the future by 13215f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * taking buffer script into consideration when choosing a language. 13225f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 13235f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1324c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 132502aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbodvoid 13263f82f8ff07a9d16a7c047129658c1bbedfdb5436Behdad Esfahbodhb_buffer_guess_segment_properties (hb_buffer_t *buffer) 132702aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod{ 13283f82f8ff07a9d16a7c047129658c1bbedfdb5436Behdad Esfahbod buffer->guess_segment_properties (); 132902aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod} 133002aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 1331bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbodtemplate <bool validate, typename T> 13327f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbodstatic inline void 13337f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbodhb_buffer_add_utf (hb_buffer_t *buffer, 13347f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod const T *text, 13357f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod int text_length, 13367f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod unsigned int item_offset, 13377f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod int item_length) 13387f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod{ 1339bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod typedef hb_utf_t<T, true> utf_t; 1340976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod const hb_codepoint_t replacement = buffer->replacement; 1341625dbf141a05f1ae81a7b8cbc529996370101284Behdad Esfahbod 13427f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || 13437f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod (!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); 13447f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 13457f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 13467f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod return; 13477f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 13481f66c3c1a0eb869c0d85a015235313177e0cec62Behdad Esfahbod if (text_length == -1) 1349625dbf141a05f1ae81a7b8cbc529996370101284Behdad Esfahbod text_length = utf_t::strlen (text); 13507f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 13517f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod if (item_length == -1) 13527f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod item_length = text_length - item_offset; 13537f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 13547f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod buffer->ensure (buffer->len + item_length * sizeof (T) / 4); 13557f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 1356da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod /* If buffer is empty and pre-context provided, install it. 1357da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * This check is written this way, to make sure people can 1358da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * provide pre-context in one add_utf() call, then provide 1359da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * text in a follow-up call. See: 1360da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * 1361da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * https://bugzilla.mozilla.org/show_bug.cgi?id=801410#c13 1362da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod */ 1363da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod if (!buffer->len && item_offset > 0) 136405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 136505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod /* Add pre-context */ 136605207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (0); 136705207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod const T *prev = text + item_offset; 136805207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod const T *start = text; 136905207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod while (start < prev && buffer->context_len[0] < buffer->CONTEXT_LENGTH) 137005207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 137105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod hb_codepoint_t u; 1372976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod prev = utf_t::prev (prev, start, &u, replacement); 137305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->context[0][buffer->context_len[0]++] = u; 137405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod } 137505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod } 137605207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 137705207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod const T *next = text + item_offset; 13787f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod const T *end = next + item_length; 137905207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod while (next < end) 138005207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 13817f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod hb_codepoint_t u; 13827f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod const T *old_next = next; 1383976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod next = utf_t::next (next, end, &u, replacement); 138466ac2ff32e24f0d5658ca172147613081a133847Behdad Esfahbod buffer->add (u, old_next - (const T *) text); 138505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod } 138605207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 138705207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod /* Add post-context */ 138805207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (1); 138905207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod end = text + text_length; 139005207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod while (next < end && buffer->context_len[1] < buffer->CONTEXT_LENGTH) 139105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 139205207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod hb_codepoint_t u; 1393976c8f455221eb599d1c446eafd88d51d7d2aa65Behdad Esfahbod next = utf_t::next (next, end, &u, replacement); 139405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->context[1][buffer->context_len[1]++] = u; 13957f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod } 13967f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 13977f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; 1398299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod} 1399299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod 1400288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1401288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add_utf8: 1402288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1403288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text: (array length=text_length): 1404288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text_length: 1405288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_offset: 1406288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_length: 1407288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1408288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1409288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1410288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1411288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1412299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodvoid 1413299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodhb_buffer_add_utf8 (hb_buffer_t *buffer, 1414299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod const char *text, 1415944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 1416299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_offset, 1417944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int item_length) 1418299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod{ 1419bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod hb_buffer_add_utf<true> (buffer, (const uint8_t *) text, text_length, item_offset, item_length); 1420299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod} 1421299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod 1422288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1423288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add_utf16: 1424288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1425288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text: (array length=text_length): 1426288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text_length: 1427288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_offset: 1428288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_length: 1429288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1430288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1431288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1432288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1433288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1434299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodvoid 1435299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodhb_buffer_add_utf16 (hb_buffer_t *buffer, 1436299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod const uint16_t *text, 1437944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 1438299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_offset, 1439288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod int item_length) 1440299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod{ 1441bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod hb_buffer_add_utf<true> (buffer, text, text_length, item_offset, item_length); 14420e0a4da9b7677a09e00d27313236e1f333864dd6Behdad Esfahbod} 14430e0a4da9b7677a09e00d27313236e1f333864dd6Behdad Esfahbod 1444288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1445288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add_utf32: 1446288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1447288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text: (array length=text_length): 1448288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text_length: 1449288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_offset: 1450288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_length: 1451288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1452288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1453288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1454288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1455288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1456299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodvoid 1457299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodhb_buffer_add_utf32 (hb_buffer_t *buffer, 1458299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod const uint32_t *text, 1459944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 1460299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_offset, 1461944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int item_length) 1462299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod{ 1463bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod hb_buffer_add_utf<true> (buffer, text, text_length, item_offset, item_length); 1464bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod} 1465bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod 1466bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod/** 1467bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod * hb_buffer_add_codepoints: 1468bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod * @buffer: a buffer. 1469bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod * @text: (array length=text_length): 1470bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod * @text_length: 1471bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod * @item_offset: 1472bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod * @item_length: 1473bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod * 1474bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod * 1475bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod * 1476bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod * Since: 1.0 1477bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod **/ 1478bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbodvoid 1479bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbodhb_buffer_add_codepoints (hb_buffer_t *buffer, 1480bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod const hb_codepoint_t *text, 1481bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod int text_length, 1482bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod unsigned int item_offset, 1483bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod int item_length) 1484bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod{ 1485bcba8b45024e1eca8be77ca2657de1dc44dbf8fbBehdad Esfahbod hb_buffer_add_utf<false> (buffer, text, text_length, item_offset, item_length); 1486299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod} 1487acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 1488acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 148939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodstatic int 149039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodcompare_info_codepoint (const hb_glyph_info_t *pa, 149139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod const hb_glyph_info_t *pb) 149239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod{ 149339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod return (int) pb->codepoint - (int) pa->codepoint; 149439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod} 149539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 149639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodstatic inline void 149739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodnormalize_glyphs_cluster (hb_buffer_t *buffer, 149839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int start, 149939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int end, 150039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod bool backward) 150139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod{ 150239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_glyph_position_t *pos = buffer->pos; 150339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 150439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod /* Total cluster advance */ 150539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_position_t total_x_advance = 0, total_y_advance = 0; 150639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (unsigned int i = start; i < end; i++) 150739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod { 150839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod total_x_advance += pos[i].x_advance; 150939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod total_y_advance += pos[i].y_advance; 151039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 151139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 151239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_position_t x_advance = 0, y_advance = 0; 151339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (unsigned int i = start; i < end; i++) 151439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod { 151539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].x_offset += x_advance; 151639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].y_offset += y_advance; 151739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 151839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod x_advance += pos[i].x_advance; 151939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod y_advance += pos[i].y_advance; 152039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 152139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].x_advance = 0; 152239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].y_advance = 0; 152339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 152439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 152539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod if (backward) 152639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod { 152739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod /* Transfer all cluster advance to the last glyph. */ 152839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[end - 1].x_advance = total_x_advance; 152939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[end - 1].y_advance = total_y_advance; 153039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 153139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_bubble_sort (buffer->info + start, end - start - 1, compare_info_codepoint, buffer->pos + start); 153239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } else { 153339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod /* Transfer all cluster advance to the first glyph. */ 153439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[start].x_advance += total_x_advance; 153539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[start].y_advance += total_y_advance; 153639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (unsigned int i = start + 1; i < end; i++) { 153739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].x_offset -= total_x_advance; 153839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].y_offset -= total_y_advance; 153939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 154039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_bubble_sort (buffer->info + start + 1, end - start - 1, compare_info_codepoint, buffer->pos + start + 1); 154139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 154239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod} 154339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 1544288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1545288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_normalize_glyphs: 1546288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1547288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1548288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1549288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1550288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1551288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 155239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodvoid 155339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodhb_buffer_normalize_glyphs (hb_buffer_t *buffer) 155439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod{ 155539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod assert (buffer->have_positions); 15567d37280600c157f3c4eae8746e99511702a58e8fBehdad Esfahbod assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); 155739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 155839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); 155939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 156039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int count = buffer->len; 156139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod if (unlikely (!count)) return; 156239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_glyph_info_t *info = buffer->info; 156339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 156439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int start = 0; 156539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int end; 156639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (end = start + 1; end < count; end++) 156739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod if (info[start].cluster != info[end].cluster) { 156839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod normalize_glyphs_cluster (buffer, start, end, backward); 156939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod start = end; 157039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 157139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod normalize_glyphs_cluster (buffer, start, end, backward); 157239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod} 1573