hb-buffer.cc revision 061cb4649342b005fb1de93abae25e889cc560bd
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 (); 181468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 18282ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod clear (); 18382ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod} 18482ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod 18582ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbodvoid 18682ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbodhb_buffer_t::clear (void) 18782ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod{ 18882ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod if (unlikely (hb_object_is_inert (this))) 18982ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod return; 19082ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod 191f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT; 192f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod props = default_props; 1934dc798de19c767b91fd3025c85593fa6809d1340Behdad Esfahbod flags = HB_BUFFER_FLAG_DEFAULT; 194468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 19596fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod content_type = HB_BUFFER_CONTENT_TYPE_INVALID; 1960594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod in_error = false; 1970594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = false; 1980594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_positions = false; 1993567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 200468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod idx = 0; 201468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod len = 0; 202468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len = 0; 20347ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod out_info = info; 2043567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 205468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod serial = 0; 206f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod memset (allocated_var_bytes, 0, sizeof allocated_var_bytes); 207f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod memset (allocated_var_owner, 0, sizeof allocated_var_owner); 20805207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 20905207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod memset (context, 0, sizeof context); 21005207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod memset (context_len, 0, sizeof context_len); 2113567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod} 2123567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 213468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 214468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::add (hb_codepoint_t codepoint, 215468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int cluster) 2163567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod{ 217468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_info_t *glyph; 218468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 219468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (!ensure (len + 1))) return; 220468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 221468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod glyph = &info[len]; 222468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 223468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod memset (glyph, 0, sizeof (*glyph)); 224468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod glyph->codepoint = codepoint; 22566ac2ff32e24f0d5658ca172147613081a133847Behdad Esfahbod glyph->mask = 1; 226468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod glyph->cluster = cluster; 227468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 228468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod len++; 2293567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod} 2306b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 231468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 232847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbodhb_buffer_t::add_info (const hb_glyph_info_t &glyph_info) 233847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod{ 234847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod if (unlikely (!ensure (len + 1))) return; 235847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 236847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod info[len] = glyph_info; 237847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 238847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod len++; 239847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod} 240847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 241847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 242847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbodvoid 2430bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbodhb_buffer_t::remove_output (void) 2440bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod{ 2450bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod if (unlikely (hb_object_is_inert (this))) 2460bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod return; 2470bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod 2480bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod have_output = false; 2490bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod have_positions = false; 2500bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod 2510bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod out_len = 0; 2520bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod out_info = info; 2530bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod} 2540bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod 2550bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbodvoid 256468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::clear_output (void) 257c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbod{ 258468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (hb_object_is_inert (this))) 259468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 260468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 2610594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = true; 2620594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_positions = false; 263a6a79df5fe2ed2cd307e7a991346faee164e70d9Behdad Esfahbod 264468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len = 0; 265468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info = info; 266468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 267468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 268468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 269468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::clear_positions (void) 270468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 271468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (hb_object_is_inert (this))) 272468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 273468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 2740594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = false; 2750594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_positions = true; 276468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 27747ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod out_len = 0; 27847ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod out_info = info; 27947ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod 280468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod memset (pos, 0, sizeof (pos[0]) * len); 281468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 282468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 283468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 284468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::swap_buffers (void) 285468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 286468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (in_error)) return; 287468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 288468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod assert (have_output); 2890594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = false; 290468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 291468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (out_info != info) 292e35bbd570a5d914f86f1ea83941ee4328f268059Behdad Esfahbod { 293468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_info_t *tmp_string; 294468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod tmp_string = info; 295468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info = out_info; 296468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info = tmp_string; 297468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod pos = (hb_glyph_position_t *) out_info; 298468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 299468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 300468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int tmp; 301468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod tmp = len; 302468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod len = out_len; 303468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len = tmp; 304468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 305468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod idx = 0; 306468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 307e35bbd570a5d914f86f1ea83941ee4328f268059Behdad Esfahbod 30869cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod 309468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 3109ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbodhb_buffer_t::replace_glyphs (unsigned int num_in, 3119ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod unsigned int num_out, 3128e3715f8a16b315c1c7dd4b256e7f68a36c53e7cBehdad Esfahbod const uint32_t *glyph_data) 3139ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod{ 31469cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (num_in, num_out))) return; 3159ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 316e88e14421a33ca5bdfd76bc0b2f801fcb6e78911Behdad Esfahbod merge_clusters (idx, idx + num_in); 3179ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 318e88e14421a33ca5bdfd76bc0b2f801fcb6e78911Behdad Esfahbod hb_glyph_info_t orig_info = info[idx]; 3199ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod hb_glyph_info_t *pinfo = &out_info[out_len]; 3209ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod for (unsigned int i = 0; i < num_out; i++) 3219ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod { 3229ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod *pinfo = orig_info; 3239ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod pinfo->codepoint = glyph_data[i]; 3249ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod pinfo++; 3259ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod } 3269ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 3279ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod idx += num_in; 3289ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod out_len += num_out; 3299ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod} 3309ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 3319ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbodvoid 332468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::output_glyph (hb_codepoint_t glyph_index) 333468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 33469cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (0, 1))) return; 335468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 336468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len] = info[idx]; 337468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len].codepoint = glyph_index; 338468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 339468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len++; 340468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 341468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 342468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 343847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbodhb_buffer_t::output_info (const hb_glyph_info_t &glyph_info) 344b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod{ 345b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod if (unlikely (!make_room_for (0, 1))) return; 346b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod 347b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod out_info[out_len] = glyph_info; 348b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod 349b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod out_len++; 350b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod} 351b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod 352b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbodvoid 353468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::copy_glyph (void) 354468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 35569cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (0, 1))) return; 356468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 357468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len] = info[idx]; 358468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 359468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len++; 360468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 361468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 3626b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbodbool 3636b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbodhb_buffer_t::move_to (unsigned int i) 3646b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod{ 3656b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod if (!have_output) 3666b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod { 3676b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod assert (i <= len); 3686b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod idx = i; 369da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod return true; 3706b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod } 371da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod 372da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod assert (i <= out_len + (len - idx)); 373da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod 374da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod if (out_len < i) 3756b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod { 3766b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod unsigned int count = i - out_len; 3776b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod if (unlikely (!make_room_for (count, count))) return false; 3786b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 3796b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod memmove (out_info + out_len, info + idx, count * sizeof (out_info[0])); 3806b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod idx += count; 3816b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod out_len += count; 3826b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod } 3836b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod else if (out_len > i) 3846b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod { 3856b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod /* Tricky part: rewinding... */ 3866b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod unsigned int count = out_len - i; 3876b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 3886b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod if (unlikely (idx < count && !shift_forward (count + 32))) return false; 3896b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 3906b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod assert (idx >= count); 3916b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 3926b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod idx -= count; 3936b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod out_len -= count; 3946b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod memmove (info + idx, out_info + out_len, count * sizeof (out_info[0])); 3956b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod } 396da72042c52ed3cc0ee19d3eabb8db7c7dd34d3edBehdad Esfahbod 3976b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod return true; 3986b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod} 3996b65a76b40522a4f57a6fedcbdfc5a4d736f1d3cBehdad Esfahbod 400468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 401468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::replace_glyph (hb_codepoint_t glyph_index) 402468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 40369cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (out_info != info || out_len != idx)) { 40469cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (1, 1))) return; 40569cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod out_info[out_len] = info[idx]; 40669cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod } 407468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len].codepoint = glyph_index; 408468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 409468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod idx++; 410468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len++; 411468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 412468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 41369cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod 414468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 415468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::set_masks (hb_mask_t value, 416468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_mask_t mask, 417468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int cluster_start, 418468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int cluster_end) 419468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 420468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_mask_t not_mask = ~mask; 421468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod value &= mask; 422468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 423468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (!mask) 424468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 425468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 426468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (cluster_start == 0 && cluster_end == (unsigned int)-1) { 427468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int count = len; 428468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (unsigned int i = 0; i < count; i++) 429468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[i].mask = (info[i].mask & not_mask) | value; 430468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 431468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 432468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 433468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int count = len; 434468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (unsigned int i = 0; i < count; i++) 435468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (cluster_start <= info[i].cluster && info[i].cluster < cluster_end) 436468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[i].mask = (info[i].mask & not_mask) | value; 437468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 438468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 439468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 440468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::reverse_range (unsigned int start, 441468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int end) 442468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 443468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int i, j; 444468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 445468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (start == end - 1) 446468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 447468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 448468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (i = start, j = end - 1; i < j; i++, j--) { 449468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_info_t t; 450468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 451468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod t = info[i]; 452468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[i] = info[j]; 453468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[j] = t; 454468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 455468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 456468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (pos) { 457468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (i = start, j = end - 1; i < j; i++, j--) { 458468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_position_t t; 459468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 460468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod t = pos[i]; 461468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod pos[i] = pos[j]; 462468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod pos[j] = t; 463468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 464468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 465468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 466468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 467468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 468468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::reverse (void) 469468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 470468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (!len)) 471468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 472468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 473468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse_range (0, len); 474468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 475468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 476468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 477468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::reverse_clusters (void) 478468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 479468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int i, start, count, last_cluster; 480468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 481468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (!len)) 482468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 483468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 484468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse (); 485468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 486468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod count = len; 487468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod start = 0; 488468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod last_cluster = info[0].cluster; 489468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (i = 1; i < count; i++) { 490468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (last_cluster != info[i].cluster) { 491468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse_range (start, i); 492468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod start = i; 493468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod last_cluster = info[i].cluster; 494468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 495468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 496468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse_range (start, i); 497a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod} 498a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod 49902aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbodvoid 500d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodhb_buffer_t::merge_clusters (unsigned int start, 501d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod unsigned int end) 502d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod{ 503fe3dabc08df7501010564f8844bd4d11771cc6a4Behdad Esfahbod if (unlikely (end - start < 2)) 504cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod return; 505cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod 506cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod unsigned int cluster = info[start].cluster; 507d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod 508d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start + 1; i < end; i++) 509cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod cluster = MIN (cluster, info[i].cluster); 510cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod 511cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod /* Extend end */ 512cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod while (end < len && info[end - 1].cluster == info[end].cluster) 513cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod end++; 514cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod 515cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod /* Extend start */ 516cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod while (idx < start && info[start - 1].cluster == info[start].cluster) 517cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod start--; 518cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod 519cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod /* If we hit the start of buffer, continue in out-buffer. */ 520cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod if (idx == start) 521cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod for (unsigned i = out_len; i && out_info[i - 1].cluster == info[start].cluster; i--) 522cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod out_info[i - 1].cluster = cluster; 523cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod 524d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start; i < end; i++) 525cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod info[i].cluster = cluster; 526d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod} 527d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodvoid 528d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodhb_buffer_t::merge_out_clusters (unsigned int start, 529d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod unsigned int end) 530d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod{ 531fe3dabc08df7501010564f8844bd4d11771cc6a4Behdad Esfahbod if (unlikely (end - start < 2)) 53272c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod return; 53372c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod 534cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod unsigned int cluster = out_info[start].cluster; 535d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod 536d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start + 1; i < end; i++) 537cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod cluster = MIN (cluster, out_info[i].cluster); 53872c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod 53972c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod /* Extend start */ 54072c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod while (start && out_info[start - 1].cluster == out_info[start].cluster) 54172c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod start--; 54272c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod 5435ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod /* Extend end */ 5445ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod while (end < out_len && out_info[end - 1].cluster == out_info[end].cluster) 5455ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod end++; 5465ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod 547e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod /* If we hit the end of out-buffer, continue in buffer. */ 548e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod if (end == out_len) 549e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod for (unsigned i = idx; i < len && info[i].cluster == out_info[end - 1].cluster; i++) 550e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod info[i].cluster = cluster; 551e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod 552d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start; i < end; i++) 553cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod out_info[i].cluster = cluster; 554d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod} 555d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod 556d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodvoid 5573f82f8ff07a9d16a7c047129658c1bbedfdb5436Behdad Esfahbodhb_buffer_t::guess_segment_properties (void) 55802aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod{ 5598465a05a89742295d4b009a9b4442eb0a899fd80Behdad Esfahbod assert (content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || 5608465a05a89742295d4b009a9b4442eb0a899fd80Behdad Esfahbod (!len && content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); 56196fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 56202aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* If script is set to INVALID, guess from buffer contents */ 56302aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (props.script == HB_SCRIPT_INVALID) { 56402aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod for (unsigned int i = 0; i < len; i++) { 565208f70f0553d73d2908b21b9552298029482a8b9Behdad Esfahbod hb_script_t script = unicode->script (info[i].codepoint); 56602aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (likely (script != HB_SCRIPT_COMMON && 56702aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod script != HB_SCRIPT_INHERITED && 56802aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod script != HB_SCRIPT_UNKNOWN)) { 56902aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod props.script = script; 57002aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod break; 57102aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 57202aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 57302aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 57402aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 57502aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* If direction is set to INVALID, guess from script */ 57602aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (props.direction == HB_DIRECTION_INVALID) { 57702aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod props.direction = hb_script_get_horizontal_direction (props.script); 57802aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 57902aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 58002aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* If language is not set, use default language from locale */ 58102aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (props.language == HB_LANGUAGE_INVALID) { 58202aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* TODO get_default_for_script? using $LANGUAGE */ 58302aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod props.language = hb_language_get_default (); 58402aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 58502aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod} 58602aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 58702aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 588a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbodstatic inline void 589a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahboddump_var_allocation (const hb_buffer_t *buffer) 590a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod{ 591a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod char buf[80]; 592a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod for (unsigned int i = 0; i < 8; i++) 593b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod buf[i] = '0' + buffer->allocated_var_bytes[7 - i]; 594a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod buf[8] = '\0'; 595a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod DEBUG_MSG (BUFFER, buffer, 596a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod "Current var allocation: %s", 597a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod buf); 598a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod} 5993567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 600f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbodvoid hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const char *owner) 601f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod{ 602b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (byte_i < 8 && byte_i + count <= 8); 603a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod 6046c15ddfe2b45383824b64058ae69939d002183a6Behdad Esfahbod if (DEBUG_ENABLED (BUFFER)) 605a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod dump_var_allocation (this); 606a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod DEBUG_MSG (BUFFER, this, 607a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod "Allocating var bytes %d..%d for %s", 608a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod byte_i, byte_i + count - 1, owner); 609a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod 610f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod for (unsigned int i = byte_i; i < byte_i + count; i++) { 611f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod assert (!allocated_var_bytes[i]); 612f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod allocated_var_bytes[i]++; 613f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod allocated_var_owner[i] = owner; 614f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod } 615f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod} 616f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod 617f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbodvoid hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const char *owner) 618f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod{ 6196c15ddfe2b45383824b64058ae69939d002183a6Behdad Esfahbod if (DEBUG_ENABLED (BUFFER)) 620b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod dump_var_allocation (this); 621b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod 622a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod DEBUG_MSG (BUFFER, this, 623a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod "Deallocating var bytes %d..%d for %s", 624a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod byte_i, byte_i + count - 1, owner); 625a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod 626b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (byte_i < 8 && byte_i + count <= 8); 627f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod for (unsigned int i = byte_i; i < byte_i + count; i++) { 628b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (allocated_var_bytes[i]); 629b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (0 == strcmp (allocated_var_owner[i], owner)); 630f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod allocated_var_bytes[i]--; 631f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod } 632f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod} 633f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod 634965c280de09b49d711cb78d629da321c802084deBehdad Esfahbodvoid hb_buffer_t::assert_var (unsigned int byte_i, unsigned int count, const char *owner) 635965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod{ 6366c15ddfe2b45383824b64058ae69939d002183a6Behdad Esfahbod if (DEBUG_ENABLED (BUFFER)) 637965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod dump_var_allocation (this); 638965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod 639965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod DEBUG_MSG (BUFFER, this, 640965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod "Asserting var bytes %d..%d for %s", 641965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod byte_i, byte_i + count - 1, owner); 642965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod 643965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod assert (byte_i < 8 && byte_i + count <= 8); 644965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod for (unsigned int i = byte_i; i < byte_i + count; i++) { 645965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod assert (allocated_var_bytes[i]); 646965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod assert (0 == strcmp (allocated_var_owner[i], owner)); 647965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod } 648965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod} 649965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod 650a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbodvoid hb_buffer_t::deallocate_var_all (void) 651a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod{ 652a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes)); 653a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod memset (allocated_var_owner, 0, sizeof (allocated_var_owner)); 654a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod} 655f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod 6566b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod/* Public API */ 6576b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 658288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 659085d4291a9f253a4b8e2eec8003ac11d02a9394fBehdad Esfahbod * hb_buffer_create: (Xconstructor) 660288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 661288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 662288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 663288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: (transfer full) 664288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 665288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 666288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 667b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbodhb_buffer_t * 668c54599ad269380c7aa28d885fcfd660fc2c10a7bBehdad Esfahbodhb_buffer_create (void) 6699f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod{ 670b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod hb_buffer_t *buffer; 671b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod 67247e71d9661946a4ffb96026bf1d697d788414ab5Behdad Esfahbod if (!(buffer = hb_object_create<hb_buffer_t> ())) 673f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod return hb_buffer_get_empty (); 6749f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 675468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reset (); 6765ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 67711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod return buffer; 67811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 6797a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod 680288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 681288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_empty: 682288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 683288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 684288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 685288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: (transfer full): 686288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 687288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 688288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 68911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_t * 69080a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbodhb_buffer_get_empty (void) 69180a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbod{ 692f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod static const hb_buffer_t _hb_buffer_nil = { 693f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod HB_OBJECT_HEADER_STATIC, 694f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod 695d5045a5f4017631a4660f985fe451c5a64c42ca0Behdad Esfahbod const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil), 696f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod HB_SEGMENT_PROPERTIES_DEFAULT, 6974dc798de19c767b91fd3025c85593fa6809d1340Behdad Esfahbod HB_BUFFER_FLAG_DEFAULT, 698f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod 69996fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod HB_BUFFER_CONTENT_TYPE_INVALID, 7000594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod true, /* in_error */ 7010594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod true, /* have_output */ 7020594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod true /* have_positions */ 70305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 70405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod /* Zero is good enough for everything else. */ 705f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod }; 706f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod 707f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod return const_cast<hb_buffer_t *> (&_hb_buffer_nil); 70880a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbod} 70980a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbod 710288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 711288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_reference: (skip) 712288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 713288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 714288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 715288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 716288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: (transfer full): 717288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 718288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 719288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 72080a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbodhb_buffer_t * 72111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_reference (hb_buffer_t *buffer) 72211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 72347e71d9661946a4ffb96026bf1d697d788414ab5Behdad Esfahbod return hb_object_reference (buffer); 72411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 725f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod 726288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 727288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_destroy: (skip) 728288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 729288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 730288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 731288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 732288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 733288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 7347a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbodvoid 73511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_destroy (hb_buffer_t *buffer) 7367a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod{ 73747e71d9661946a4ffb96026bf1d697d788414ab5Behdad Esfahbod if (!hb_object_destroy (buffer)) return; 73811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 7395ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod hb_unicode_funcs_destroy (buffer->unicode); 7405ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 7417e7007a1c9bf2c07a8369752126ece8fa6164248Behdad Esfahbod free (buffer->info); 7421b621823f3e31b48c80cc8b0691dfa873ba086cdBehdad Esfahbod free (buffer->pos); 74311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 744b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod free (buffer); 7457a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod} 7467a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod 747288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 748288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_user_data: (skip) 749288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 750288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @key: 751288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @data: 752288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @destroy: 753288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @replace: 754288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 755288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 756288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 757288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 758288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 759288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 760288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 7615fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_bool_t 7625fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_buffer_set_user_data (hb_buffer_t *buffer, 7635fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod hb_user_data_key_t *key, 7645fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod void * data, 76533ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod hb_destroy_func_t destroy, 76633ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod hb_bool_t replace) 7675fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod{ 76833ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod return hb_object_set_user_data (buffer, key, data, destroy, replace); 7695fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod} 7705fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 771288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 772288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_user_data: (skip) 773288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 774288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @key: 775288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 776288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 777288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 778288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 779288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 780288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 781288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 7825fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodvoid * 7835fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_buffer_get_user_data (hb_buffer_t *buffer, 7845fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod hb_user_data_key_t *key) 7855fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod{ 7865fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod return hb_object_get_user_data (buffer, key); 7875fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod} 7885fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 7895ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 790288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 791288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_content_type: 792288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 793288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @content_type: 794288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 795288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 796288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 797288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 798288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 7995ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodvoid 80096fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_set_content_type (hb_buffer_t *buffer, 80196fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod hb_buffer_content_type_t content_type) 80296fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod{ 80396fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod buffer->content_type = content_type; 80496fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod} 80596fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 806288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 807288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_content_type: 808288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 809288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 810288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 811288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 812288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 813288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 814288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 815288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 81696fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_content_type_t 81796fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_get_content_type (hb_buffer_t *buffer) 81896fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod{ 81996fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod return buffer->content_type; 82096fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod} 82196fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 82296fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 823288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 824288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_unicode_funcs: 825288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 826288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @unicode_funcs: 827288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 828288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 829288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 830288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 831288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 83296fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodvoid 8335ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_set_unicode_funcs (hb_buffer_t *buffer, 834288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod hb_unicode_funcs_t *unicode_funcs) 8355ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 836e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 837e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 838e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 839288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod if (!unicode_funcs) 840288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod unicode_funcs = hb_unicode_funcs_get_default (); 841d5045a5f4017631a4660f985fe451c5a64c42ca0Behdad Esfahbod 8420465e69832393cc1ed36508ec5d597fbab64877aBehdad Esfahbod 843288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod hb_unicode_funcs_reference (unicode_funcs); 8445ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod hb_unicode_funcs_destroy (buffer->unicode); 845288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod buffer->unicode = unicode_funcs; 8465ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 8475ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 848288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 849288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_unicode_funcs: 850288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 851288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 852288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 853288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 854288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 855288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 856288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 857288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 8585ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_unicode_funcs_t * 8595ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_get_unicode_funcs (hb_buffer_t *buffer) 8605ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 8615ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod return buffer->unicode; 8625ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 8635ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 864288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 865288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_direction: 866288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 867288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @direction: 868288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 869288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 870288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 871288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 872288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 8735ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodvoid 8745ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_set_direction (hb_buffer_t *buffer, 8755ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod hb_direction_t direction) 8765ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 8775ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 878e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 879e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 880e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 8814e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod buffer->props.direction = direction; 8825ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 8835ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 884288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 885288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_direction: 886288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 887288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 888288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 889288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 890288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 891288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 892288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 893288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 8945ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_direction_t 8955ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_get_direction (hb_buffer_t *buffer) 8965ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 8974e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod return buffer->props.direction; 8985ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 8995ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 900288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 901288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_script: 902288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 903288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @script: 904288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 905288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 906288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 907288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 908288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 909ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodvoid 910ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_set_script (hb_buffer_t *buffer, 911ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod hb_script_t script) 912ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 913e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 914e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 915e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 9164e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod buffer->props.script = script; 917ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 918ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 919288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 920288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_script: 921288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 922288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 923288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 924288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 925288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 926288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 927288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 928288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 929ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_script_t 930ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_get_script (hb_buffer_t *buffer) 931ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 9324e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod return buffer->props.script; 933ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 934ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 935288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 936288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_language: 937288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 938288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @language: 939288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 940288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 941288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 942288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 943288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 944ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodvoid 945ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_set_language (hb_buffer_t *buffer, 946ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod hb_language_t language) 947ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 948e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 949e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 950e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 9514e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod buffer->props.language = language; 952ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 953ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 954288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 955288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_language: 956288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 957288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 958288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 959288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 960288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 961288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 962288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 963288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 964ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_language_t 965ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_get_language (hb_buffer_t *buffer) 966ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 9674e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod return buffer->props.language; 968ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 969ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 970288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 971288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_segment_properties: 972288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 973288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @props: 974288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 975288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 976288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 977288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 978288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 9790c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodvoid 980f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_buffer_set_segment_properties (hb_buffer_t *buffer, 981f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod const hb_segment_properties_t *props) 982f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod{ 983f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 984f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod return; 985f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 986f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod buffer->props = *props; 987f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod} 988f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 989288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 990288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_segment_properties: 991288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 992288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @props: 993288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 994288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 995288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 996288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 997288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 998f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodvoid 999f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_buffer_get_segment_properties (hb_buffer_t *buffer, 1000f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod hb_segment_properties_t *props) 1001f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod{ 1002f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod *props = buffer->props; 1003f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod} 1004f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 1005f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 1006288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1007288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_flags: 1008288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1009288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @flags: 1010288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1011288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1012288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1013288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1014288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1015f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodvoid 10160c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_set_flags (hb_buffer_t *buffer, 10170c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod hb_buffer_flags_t flags) 10180c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod{ 10190c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 10200c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod return; 10210c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod 10220c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod buffer->flags = flags; 10230c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod} 10240c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod 1025288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1026288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_flags: 1027288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1028288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1029288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1030288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1031288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 1032288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1033288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1034288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 10350c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_flags_t 10360c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_get_flags (hb_buffer_t *buffer) 10370c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod{ 10380c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod return buffer->flags; 10390c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod} 10400c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod 10415ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 1042288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1043288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_reset: 1044288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1045288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1046288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1047288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1048288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1049288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 10507a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbodvoid 1051c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_buffer_reset (hb_buffer_t *buffer) 1052c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod{ 1053468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reset (); 10547a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod} 10557a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod 1056288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1057288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_clear_contents: 1058288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1059288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1060288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1061288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1062288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1063288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 106482ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbodvoid 10651172dc736280566426eb6dade1a886b2a0ca9aa4Behdad Esfahbodhb_buffer_clear_contents (hb_buffer_t *buffer) 106682ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod{ 106782ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod buffer->clear (); 106882ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod} 106982ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod 1070288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1071288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_pre_allocate: 1072288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1073288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @size: 1074288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1075288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1076288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1077288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 1078288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1079288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1080288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1081a6a79df5fe2ed2cd307e7a991346faee164e70d9Behdad Esfahbodhb_bool_t 108202a534b23f2d1e7475109563b9f61221ed020e8bRyan Lortiehb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size) 1083f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod{ 1084468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return buffer->ensure (size); 1085f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod} 1086f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod 1087288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1088288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_allocation_successful: 1089288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1090288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1091288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1092288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1093288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 1094288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1095288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1096288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1097aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbodhb_bool_t 1098aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbodhb_buffer_allocation_successful (hb_buffer_t *buffer) 1099aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod{ 1100aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod return !buffer->in_error; 1101aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod} 1102aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod 1103288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1104288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add: 1105288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1106288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @codepoint: 1107288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @cluster: 1108288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1109288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1110288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1111288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1112288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1113f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbodvoid 1114f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbodhb_buffer_add (hb_buffer_t *buffer, 1115f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbod hb_codepoint_t codepoint, 1116f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbod unsigned int cluster) 11176b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod{ 111866ac2ff32e24f0d5658ca172147613081a133847Behdad Esfahbod buffer->add (codepoint, cluster); 111905207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (1); 11209111b21ef99d5e53348176f683261b0101eb427fBehdad Esfahbod} 11219111b21ef99d5e53348176f683261b0101eb427fBehdad Esfahbod 1122288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1123288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_length: 1124288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1125288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @length: 1126288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1127288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1128288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1129288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 1130288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1131288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1132288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1133c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_bool_t 1134c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_buffer_set_length (hb_buffer_t *buffer, 1135c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod unsigned int length) 1136c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod{ 1137e1ac38f8dd04c29d2d4140f5a492cdaf25d72901Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 1138e1ac38f8dd04c29d2d4140f5a492cdaf25d72901Behdad Esfahbod return length == 0; 1139e1ac38f8dd04c29d2d4140f5a492cdaf25d72901Behdad Esfahbod 1140468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (!buffer->ensure (length)) 11410594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod return false; 1142c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod 1143c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod /* Wipe the new space */ 1144c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod if (length > buffer->len) { 1145c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod memset (buffer->info + buffer->len, 0, sizeof (buffer->info[0]) * (length - buffer->len)); 1146c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod if (buffer->have_positions) 1147c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod memset (buffer->pos + buffer->len, 0, sizeof (buffer->pos[0]) * (length - buffer->len)); 1148c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod } 1149c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod 1150c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod buffer->len = length; 115105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 115205207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod if (!length) 115305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (0); 115405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (1); 115505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 11560594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod return true; 1157c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod} 1158c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod 11595f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 11605f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_get_length: 11615f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 11625f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11635f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Returns the number of items in the buffer. 11645f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11655f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Return value: buffer length. 11665f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11675f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1168c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 116911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodunsigned int 11703d14528b8b2e7da425a9df7057fc9fb326d8298cBehdad Esfahbodhb_buffer_get_length (hb_buffer_t *buffer) 117111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 11726960350be97f24e97140391025b56369c393a3dfBehdad Esfahbod return buffer->len; 117311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 117411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 11755f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 11765f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_get_glyph_infos: 11775f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 11785f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @length: (out): output array length. 11795f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11805f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Returns buffer glyph information array. Returned pointer 11815f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * is valid as long as buffer contents are not modified. 11825f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11835f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Return value: (transfer none) (array length=length): buffer glyph information array. 11845f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11855f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1186c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 118711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_info_t * 118870566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortiehb_buffer_get_glyph_infos (hb_buffer_t *buffer, 118970566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie unsigned int *length) 119011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 119170566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie if (length) 119270566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie *length = buffer->len; 119370566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie 11947e7007a1c9bf2c07a8369752126ece8fa6164248Behdad Esfahbod return (hb_glyph_info_t *) buffer->info; 119511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 119611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 11975f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 11985f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_get_glyph_positions: 11995f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 12005f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @length: (out): output length. 12015f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12025f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Returns buffer glyph position array. Returned pointer 12035f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * is valid as long as buffer contents are not modified. 12045f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12055f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Return value: (transfer none) (array length=length): buffer glyph position array. 12065f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12075f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1208c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 120911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_position_t * 121070566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortiehb_buffer_get_glyph_positions (hb_buffer_t *buffer, 121170566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie unsigned int *length) 121211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 1213314905d7548d5be58354546d660754b807b6efb2Behdad Esfahbod if (!buffer->have_positions) 1214468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->clear_positions (); 121511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 121670566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie if (length) 121770566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie *length = buffer->len; 121870566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie 12191b621823f3e31b48c80cc8b0691dfa873ba086cdBehdad Esfahbod return (hb_glyph_position_t *) buffer->pos; 122011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 1221fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod 12225f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 12235f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_reverse: 12245f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 12255f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12265f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Reverses buffer contents. 12275f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12285f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1229c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 1230ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodvoid 1231ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodhb_buffer_reverse (hb_buffer_t *buffer) 1232ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod{ 1233468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reverse (); 1234ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod} 1235ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod 12365f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 12375f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_reverse_clusters: 12385f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 12395f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12405f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Reverses buffer clusters. That is, the buffer contents are 12415f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * reversed, then each cluster (consecutive items having the 12425f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * same cluster number) are reversed again. 12435f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12445f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1245c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 1246ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodvoid 1247ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodhb_buffer_reverse_clusters (hb_buffer_t *buffer) 1248ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod{ 1249468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reverse_clusters (); 1250ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod} 1251ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod 12525f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 12535f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_guess_segment_properties: 12545f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 12555f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12565f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Sets unset buffer segment properties based on buffer Unicode 12575f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * contents. If buffer is not empty, it must have content type 12585f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * %HB_BUFFER_CONTENT_TYPE_UNICODE. 12595f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12605f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * If buffer script is not set (ie. is %HB_SCRIPT_INVALID), it 12615f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * will be set to the Unicode script of the first character in 12625f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * the buffer that has a script other than %HB_SCRIPT_COMMON, 12635f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * %HB_SCRIPT_INHERITED, and %HB_SCRIPT_UNKNOWN. 12645f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12655f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Next, if buffer direction is not set (ie. is %HB_DIRECTION_INVALID), 12665f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * it will be set to the natural horizontal direction of the 12675f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * buffer script as returned by hb_script_get_horizontal_direction(). 12685f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12695f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Finally, if buffer language is not set (ie. is %HB_LANGUAGE_INVALID), 12705f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * it will be set to the process's default language as returned by 12715f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_language_get_default(). This may change in the future by 12725f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * taking buffer script into consideration when choosing a language. 12735f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12745f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1275c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 127602aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbodvoid 12773f82f8ff07a9d16a7c047129658c1bbedfdb5436Behdad Esfahbodhb_buffer_guess_segment_properties (hb_buffer_t *buffer) 127802aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod{ 12793f82f8ff07a9d16a7c047129658c1bbedfdb5436Behdad Esfahbod buffer->guess_segment_properties (); 128002aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod} 128102aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 12827f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbodtemplate <typename T> 12837f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbodstatic inline void 12847f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbodhb_buffer_add_utf (hb_buffer_t *buffer, 12857f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod const T *text, 12867f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod int text_length, 12877f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod unsigned int item_offset, 12887f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod int item_length) 12897f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod{ 12907f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || 12917f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod (!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); 12927f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 12937f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 12947f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod return; 12957f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 12961f66c3c1a0eb869c0d85a015235313177e0cec62Behdad Esfahbod if (text_length == -1) 12971f66c3c1a0eb869c0d85a015235313177e0cec62Behdad Esfahbod text_length = hb_utf_strlen (text); 12987f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 12997f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod if (item_length == -1) 13007f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod item_length = text_length - item_offset; 13017f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 13027f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod buffer->ensure (buffer->len + item_length * sizeof (T) / 4); 13037f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 1304da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod /* If buffer is empty and pre-context provided, install it. 1305da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * This check is written this way, to make sure people can 1306da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * provide pre-context in one add_utf() call, then provide 1307da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * text in a follow-up call. See: 1308da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * 1309da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * https://bugzilla.mozilla.org/show_bug.cgi?id=801410#c13 1310da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod */ 1311da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod if (!buffer->len && item_offset > 0) 131205207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 131305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod /* Add pre-context */ 131405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (0); 131505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod const T *prev = text + item_offset; 131605207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod const T *start = text; 131705207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod while (start < prev && buffer->context_len[0] < buffer->CONTEXT_LENGTH) 131805207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 131905207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod hb_codepoint_t u; 132005207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod prev = hb_utf_prev (prev, start, &u); 132105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->context[0][buffer->context_len[0]++] = u; 132205207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod } 132305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod } 132405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 132505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod const T *next = text + item_offset; 13267f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod const T *end = next + item_length; 132705207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod while (next < end) 132805207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 13297f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod hb_codepoint_t u; 13307f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod const T *old_next = next; 13317f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod next = hb_utf_next (next, end, &u); 133266ac2ff32e24f0d5658ca172147613081a133847Behdad Esfahbod buffer->add (u, old_next - (const T *) text); 133305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod } 133405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 133505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod /* Add post-context */ 133605207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (1); 133705207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod end = text + text_length; 133805207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod while (next < end && buffer->context_len[1] < buffer->CONTEXT_LENGTH) 133905207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 134005207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod hb_codepoint_t u; 134105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod next = hb_utf_next (next, end, &u); 134205207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->context[1][buffer->context_len[1]++] = u; 13437f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod } 13447f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 13457f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; 1346299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod} 1347299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod 1348288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1349288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add_utf8: 1350288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1351288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text: (array length=text_length): 1352288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text_length: 1353288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_offset: 1354288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_length: 1355288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1356288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1357288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1358288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1359288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1360299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodvoid 1361299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodhb_buffer_add_utf8 (hb_buffer_t *buffer, 1362299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod const char *text, 1363944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 1364299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_offset, 1365944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int item_length) 1366299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod{ 13677f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod hb_buffer_add_utf (buffer, (const uint8_t *) text, text_length, item_offset, item_length); 1368299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod} 1369299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod 1370288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1371288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add_utf16: 1372288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1373288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text: (array length=text_length): 1374288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text_length: 1375288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_offset: 1376288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_length: 1377288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1378288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1379288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1380288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1381288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1382299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodvoid 1383299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodhb_buffer_add_utf16 (hb_buffer_t *buffer, 1384299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod const uint16_t *text, 1385944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 1386299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_offset, 1387288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod int item_length) 1388299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod{ 13897f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod hb_buffer_add_utf (buffer, text, text_length, item_offset, item_length); 13900e0a4da9b7677a09e00d27313236e1f333864dd6Behdad Esfahbod} 13910e0a4da9b7677a09e00d27313236e1f333864dd6Behdad Esfahbod 1392288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1393288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add_utf32: 1394288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1395288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text: (array length=text_length): 1396288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text_length: 1397288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_offset: 1398288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_length: 1399288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1400288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1401288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1402288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1403288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1404299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodvoid 1405299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodhb_buffer_add_utf32 (hb_buffer_t *buffer, 1406299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod const uint32_t *text, 1407944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 1408299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_offset, 1409944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int item_length) 1410299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod{ 14117f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod hb_buffer_add_utf (buffer, text, text_length, item_offset, item_length); 1412299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod} 1413acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 1414acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 141539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodstatic int 141639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodcompare_info_codepoint (const hb_glyph_info_t *pa, 141739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod const hb_glyph_info_t *pb) 141839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod{ 141939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod return (int) pb->codepoint - (int) pa->codepoint; 142039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod} 142139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 142239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodstatic inline void 142339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodnormalize_glyphs_cluster (hb_buffer_t *buffer, 142439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int start, 142539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int end, 142639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod bool backward) 142739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod{ 142839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_glyph_position_t *pos = buffer->pos; 142939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 143039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod /* Total cluster advance */ 143139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_position_t total_x_advance = 0, total_y_advance = 0; 143239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (unsigned int i = start; i < end; i++) 143339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod { 143439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod total_x_advance += pos[i].x_advance; 143539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod total_y_advance += pos[i].y_advance; 143639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 143739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 143839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_position_t x_advance = 0, y_advance = 0; 143939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (unsigned int i = start; i < end; i++) 144039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod { 144139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].x_offset += x_advance; 144239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].y_offset += y_advance; 144339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 144439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod x_advance += pos[i].x_advance; 144539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod y_advance += pos[i].y_advance; 144639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 144739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].x_advance = 0; 144839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].y_advance = 0; 144939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 145039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 145139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod if (backward) 145239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod { 145339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod /* Transfer all cluster advance to the last glyph. */ 145439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[end - 1].x_advance = total_x_advance; 145539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[end - 1].y_advance = total_y_advance; 145639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 145739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_bubble_sort (buffer->info + start, end - start - 1, compare_info_codepoint, buffer->pos + start); 145839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } else { 145939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod /* Transfer all cluster advance to the first glyph. */ 146039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[start].x_advance += total_x_advance; 146139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[start].y_advance += total_y_advance; 146239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (unsigned int i = start + 1; i < end; i++) { 146339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].x_offset -= total_x_advance; 146439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].y_offset -= total_y_advance; 146539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 146639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_bubble_sort (buffer->info + start + 1, end - start - 1, compare_info_codepoint, buffer->pos + start + 1); 146739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 146839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod} 146939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 1470288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1471288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_normalize_glyphs: 1472288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1473288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1474288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1475288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1476288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1477288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 147839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodvoid 147939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodhb_buffer_normalize_glyphs (hb_buffer_t *buffer) 148039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod{ 148139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod assert (buffer->have_positions); 14827d37280600c157f3c4eae8746e99511702a58e8fBehdad Esfahbod assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); 148339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 148439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); 148539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 148639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int count = buffer->len; 148739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod if (unlikely (!count)) return; 148839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_glyph_info_t *info = buffer->info; 148939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 149039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int start = 0; 149139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int end; 149239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (end = start + 1; end < count; end++) 149339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod if (info[start].cluster != info[end].cluster) { 149439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod normalize_glyphs_cluster (buffer, start, end, backward); 149539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod start = end; 149639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 149739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod normalize_glyphs_cluster (buffer, start, end, backward); 149839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod} 1499