hb-buffer.cc revision 288f2899979bcc9e68f8115cb76e3271ed0e17bc
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 142e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbodvoid * 143e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbodhb_buffer_t::get_scratch_buffer (unsigned int *size) 144e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbod{ 1450594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = false; 1460594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_positions = false; 14747ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod 148e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbod out_len = 0; 14947ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod out_info = info; 15047ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod 151e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbod *size = allocated * sizeof (pos[0]); 152e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbod return pos; 153e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbod} 154e62df43649e31b7815c272f01808b3f726c7d07dBehdad Esfahbod 155468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 15669cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod 157468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod/* HarfBuzz-Internal API */ 158468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 159468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 160468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::reset (void) 161468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 162468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (hb_object_is_inert (this))) 163468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 164468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 165468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_unicode_funcs_destroy (unicode); 166d5045a5f4017631a4660f985fe451c5a64c42ca0Behdad Esfahbod unicode = hb_unicode_funcs_get_default (); 167468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 16882ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod clear (); 16982ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod} 17082ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod 17182ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbodvoid 17282ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbodhb_buffer_t::clear (void) 17382ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod{ 17482ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod if (unlikely (hb_object_is_inert (this))) 17582ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod return; 17682ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod 177f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT; 178f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod props = default_props; 1794dc798de19c767b91fd3025c85593fa6809d1340Behdad Esfahbod flags = HB_BUFFER_FLAG_DEFAULT; 180468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 18196fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod content_type = HB_BUFFER_CONTENT_TYPE_INVALID; 1820594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod in_error = false; 1830594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = false; 1840594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_positions = false; 1853567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 186468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod idx = 0; 187468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod len = 0; 188468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len = 0; 18947ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod out_info = info; 1903567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 191468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod serial = 0; 192f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod memset (allocated_var_bytes, 0, sizeof allocated_var_bytes); 193f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod memset (allocated_var_owner, 0, sizeof allocated_var_owner); 19405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 19505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod memset (context, 0, sizeof context); 19605207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod memset (context_len, 0, sizeof context_len); 1973567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod} 1983567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 199468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 200468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::add (hb_codepoint_t codepoint, 201468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int cluster) 2023567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod{ 203468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_info_t *glyph; 204468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 205468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (!ensure (len + 1))) return; 206468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 207468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod glyph = &info[len]; 208468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 209468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod memset (glyph, 0, sizeof (*glyph)); 210468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod glyph->codepoint = codepoint; 21166ac2ff32e24f0d5658ca172147613081a133847Behdad Esfahbod glyph->mask = 1; 212468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod glyph->cluster = cluster; 213468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 214468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod len++; 2153567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod} 2166b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 217468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 218847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbodhb_buffer_t::add_info (const hb_glyph_info_t &glyph_info) 219847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod{ 220847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod if (unlikely (!ensure (len + 1))) return; 221847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 222847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod info[len] = glyph_info; 223847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 224847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod len++; 225847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod} 226847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 227847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbod 228847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbodvoid 2290bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbodhb_buffer_t::remove_output (void) 2300bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod{ 2310bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod if (unlikely (hb_object_is_inert (this))) 2320bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod return; 2330bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod 2340bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod have_output = false; 2350bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod have_positions = false; 2360bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod 2370bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod out_len = 0; 2380bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod out_info = info; 2390bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod} 2400bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbod 2410bc7a38463bfb37f12efeb1b8cb2024cf4a347bcBehdad Esfahbodvoid 242468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::clear_output (void) 243c968fc2dc87cf85b53f60a40db59d5ee7b992edfBehdad Esfahbod{ 244468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (hb_object_is_inert (this))) 245468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 246468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 2470594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = true; 2480594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_positions = false; 249a6a79df5fe2ed2cd307e7a991346faee164e70d9Behdad Esfahbod 250468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len = 0; 251468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info = info; 252468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 253468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 254468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 255468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::clear_positions (void) 256468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 257468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (hb_object_is_inert (this))) 258468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 259468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 2600594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = false; 2610594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_positions = true; 262468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 26347ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod out_len = 0; 26447ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod out_info = info; 26547ef931f13778b894090139a64238a5ab9ac1154Behdad Esfahbod 266468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod memset (pos, 0, sizeof (pos[0]) * len); 267468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 268468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 269468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 270468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::swap_buffers (void) 271468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 272468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (in_error)) return; 273468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 274468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod assert (have_output); 2750594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod have_output = false; 276468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 277468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (out_info != info) 278e35bbd570a5d914f86f1ea83941ee4328f268059Behdad Esfahbod { 279468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_info_t *tmp_string; 280468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod tmp_string = info; 281468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info = out_info; 282468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info = tmp_string; 283468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod pos = (hb_glyph_position_t *) out_info; 284468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 285468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 286468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int tmp; 287468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod tmp = len; 288468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod len = out_len; 289468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len = tmp; 290468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 291468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod idx = 0; 292468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 293e35bbd570a5d914f86f1ea83941ee4328f268059Behdad Esfahbod 29469cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod 295468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 2969ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbodhb_buffer_t::replace_glyphs (unsigned int num_in, 2979ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod unsigned int num_out, 2988e3715f8a16b315c1c7dd4b256e7f68a36c53e7cBehdad Esfahbod const uint32_t *glyph_data) 2999ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod{ 30069cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (num_in, num_out))) return; 3019ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 302e88e14421a33ca5bdfd76bc0b2f801fcb6e78911Behdad Esfahbod merge_clusters (idx, idx + num_in); 3039ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 304e88e14421a33ca5bdfd76bc0b2f801fcb6e78911Behdad Esfahbod hb_glyph_info_t orig_info = info[idx]; 3059ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod hb_glyph_info_t *pinfo = &out_info[out_len]; 3069ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod for (unsigned int i = 0; i < num_out; i++) 3079ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod { 3089ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod *pinfo = orig_info; 3099ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod pinfo->codepoint = glyph_data[i]; 3109ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod pinfo++; 3119ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod } 3129ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 3139ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod idx += num_in; 3149ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod out_len += num_out; 3159ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod} 3169ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbod 3179ebe8c0286856d46430ae184ba7303bd34485883Behdad Esfahbodvoid 318468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::output_glyph (hb_codepoint_t glyph_index) 319468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 32069cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (0, 1))) return; 321468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 322468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len] = info[idx]; 323468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len].codepoint = glyph_index; 324468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 325468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len++; 326468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 327468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 328468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 329847794e929831750e97525137ab5e285ccd1064eBehdad Esfahbodhb_buffer_t::output_info (const hb_glyph_info_t &glyph_info) 330b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod{ 331b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod if (unlikely (!make_room_for (0, 1))) return; 332b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod 333b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod out_info[out_len] = glyph_info; 334b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod 335b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod out_len++; 336b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod} 337b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbod 338b85800f9de8976a7418ef9df467d3080c6ab0199Behdad Esfahbodvoid 339468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::copy_glyph (void) 340468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 34169cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (0, 1))) return; 342468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 343468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len] = info[idx]; 344468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 345468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len++; 346468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 347468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 348468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 349468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::replace_glyph (hb_codepoint_t glyph_index) 350468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 35169cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (out_info != info || out_len != idx)) { 35269cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod if (unlikely (!make_room_for (1, 1))) return; 35369cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod out_info[out_len] = info[idx]; 35469cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod } 355468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_info[out_len].codepoint = glyph_index; 356468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 357468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod idx++; 358468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod out_len++; 359468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 360468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 36169cc492dc120847ed00cae65ec958593ebf550c5Behdad Esfahbod 362468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 363468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::set_masks (hb_mask_t value, 364468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_mask_t mask, 365468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int cluster_start, 366468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int cluster_end) 367468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 368468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_mask_t not_mask = ~mask; 369468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod value &= mask; 370468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 371468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (!mask) 372468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 373468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 374468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (cluster_start == 0 && cluster_end == (unsigned int)-1) { 375468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int count = len; 376468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (unsigned int i = 0; i < count; i++) 377468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[i].mask = (info[i].mask & not_mask) | value; 378468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 379468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 380468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 381468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int count = len; 382468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (unsigned int i = 0; i < count; i++) 383468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (cluster_start <= info[i].cluster && info[i].cluster < cluster_end) 384468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[i].mask = (info[i].mask & not_mask) | value; 385468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 386468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 387468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 388468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::reverse_range (unsigned int start, 389468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int end) 390468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 391468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int i, j; 392468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 393468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (start == end - 1) 394468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 395468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 396468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (i = start, j = end - 1; i < j; i++, j--) { 397468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_info_t t; 398468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 399468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod t = info[i]; 400468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[i] = info[j]; 401468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod info[j] = t; 402468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 403468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 404468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (pos) { 405468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (i = start, j = end - 1; i < j; i++, j--) { 406468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod hb_glyph_position_t t; 407468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 408468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod t = pos[i]; 409468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod pos[i] = pos[j]; 410468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod pos[j] = t; 411468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 412468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 413468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 414468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 415468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 416468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::reverse (void) 417468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 418468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (!len)) 419468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 420468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 421468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse_range (0, len); 422468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod} 423468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 424468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodvoid 425468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbodhb_buffer_t::reverse_clusters (void) 426468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod{ 427468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod unsigned int i, start, count, last_cluster; 428468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 429468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (unlikely (!len)) 430468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return; 431468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 432468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse (); 433468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod 434468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod count = len; 435468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod start = 0; 436468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod last_cluster = info[0].cluster; 437468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod for (i = 1; i < count; i++) { 438468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (last_cluster != info[i].cluster) { 439468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse_range (start, i); 440468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod start = i; 441468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod last_cluster = info[i].cluster; 442468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 443468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod } 444468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod reverse_range (start, i); 445a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod} 446a8abb8b994c3cd89808e8f7128a0c04b23eb3edeBehdad Esfahbod 44702aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbodvoid 448d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodhb_buffer_t::merge_clusters (unsigned int start, 449d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod unsigned int end) 450d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod{ 451fe3dabc08df7501010564f8844bd4d11771cc6a4Behdad Esfahbod if (unlikely (end - start < 2)) 452cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod return; 453cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod 454cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod unsigned int cluster = info[start].cluster; 455d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod 456d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start + 1; i < end; i++) 457cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod cluster = MIN (cluster, info[i].cluster); 458cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod 459cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod /* Extend end */ 460cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod while (end < len && info[end - 1].cluster == info[end].cluster) 461cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod end++; 462cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod 463cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod /* Extend start */ 464cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod while (idx < start && info[start - 1].cluster == info[start].cluster) 465cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod start--; 466cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod 467cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod /* If we hit the start of buffer, continue in out-buffer. */ 468cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod if (idx == start) 469cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod for (unsigned i = out_len; i && out_info[i - 1].cluster == info[start].cluster; i--) 470cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod out_info[i - 1].cluster = cluster; 471cd5891493df06fdb92e1ae526d29dee8df250235Behdad Esfahbod 472d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start; i < end; i++) 473cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod info[i].cluster = cluster; 474d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod} 475d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodvoid 476d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodhb_buffer_t::merge_out_clusters (unsigned int start, 477d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod unsigned int end) 478d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod{ 479fe3dabc08df7501010564f8844bd4d11771cc6a4Behdad Esfahbod if (unlikely (end - start < 2)) 48072c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod return; 48172c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod 482cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod unsigned int cluster = out_info[start].cluster; 483d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod 484d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start + 1; i < end; i++) 485cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod cluster = MIN (cluster, out_info[i].cluster); 48672c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod 48772c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod /* Extend start */ 48872c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod while (start && out_info[start - 1].cluster == out_info[start].cluster) 48972c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod start--; 49072c0a1878313e7232d554bc226f4c6dc01418a95Behdad Esfahbod 4915ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod /* Extend end */ 4925ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod while (end < out_len && out_info[end - 1].cluster == out_info[end].cluster) 4935ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod end++; 4945ced012d9f58c51d557a835593c3277e35fe3b35Behdad Esfahbod 495e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod /* If we hit the end of out-buffer, continue in buffer. */ 496e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod if (end == out_len) 497e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod for (unsigned i = idx; i < len && info[i].cluster == out_info[end - 1].cluster; i++) 498e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod info[i].cluster = cluster; 499e51d2b6ed1c794ac28c5610bfd01dbc9fb383633Behdad Esfahbod 500d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod for (unsigned int i = start; i < end; i++) 501cafa6f372721fd6b0a7c0da68b9421d3e94931bcBehdad Esfahbod out_info[i].cluster = cluster; 502d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod} 503d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbod 504d4cc44716c1e098f8abbc0e495404598026ef242Behdad Esfahbodvoid 5053f82f8ff07a9d16a7c047129658c1bbedfdb5436Behdad Esfahbodhb_buffer_t::guess_segment_properties (void) 50602aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod{ 5078465a05a89742295d4b009a9b4442eb0a899fd80Behdad Esfahbod assert (content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || 5088465a05a89742295d4b009a9b4442eb0a899fd80Behdad Esfahbod (!len && content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); 50996fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 51002aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* If script is set to INVALID, guess from buffer contents */ 51102aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (props.script == HB_SCRIPT_INVALID) { 51202aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod for (unsigned int i = 0; i < len; i++) { 513208f70f0553d73d2908b21b9552298029482a8b9Behdad Esfahbod hb_script_t script = unicode->script (info[i].codepoint); 51402aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (likely (script != HB_SCRIPT_COMMON && 51502aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod script != HB_SCRIPT_INHERITED && 51602aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod script != HB_SCRIPT_UNKNOWN)) { 51702aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod props.script = script; 51802aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod break; 51902aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 52002aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 52102aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 52202aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 52302aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* If direction is set to INVALID, guess from script */ 52402aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (props.direction == HB_DIRECTION_INVALID) { 52502aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod props.direction = hb_script_get_horizontal_direction (props.script); 52602aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 52702aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 52802aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* If language is not set, use default language from locale */ 52902aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod if (props.language == HB_LANGUAGE_INVALID) { 53002aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod /* TODO get_default_for_script? using $LANGUAGE */ 53102aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod props.language = hb_language_get_default (); 53202aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod } 53302aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod} 53402aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 53502aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 536a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbodstatic inline void 537a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahboddump_var_allocation (const hb_buffer_t *buffer) 538a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod{ 539a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod char buf[80]; 540a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod for (unsigned int i = 0; i < 8; i++) 541b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod buf[i] = '0' + buffer->allocated_var_bytes[7 - i]; 542a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod buf[8] = '\0'; 543a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod DEBUG_MSG (BUFFER, buffer, 544a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod "Current var allocation: %s", 545a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod buf); 546a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod} 5473567b87cce541dfb0af7caf024ec67c9d3c09214Behdad Esfahbod 548f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbodvoid hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const char *owner) 549f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod{ 550b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (byte_i < 8 && byte_i + count <= 8); 551a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod 5526c15ddfe2b45383824b64058ae69939d002183a6Behdad Esfahbod if (DEBUG_ENABLED (BUFFER)) 553a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod dump_var_allocation (this); 554a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod DEBUG_MSG (BUFFER, this, 555a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod "Allocating var bytes %d..%d for %s", 556a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod byte_i, byte_i + count - 1, owner); 557a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod 558f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod for (unsigned int i = byte_i; i < byte_i + count; i++) { 559f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod assert (!allocated_var_bytes[i]); 560f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod allocated_var_bytes[i]++; 561f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod allocated_var_owner[i] = owner; 562f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod } 563f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod} 564f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod 565f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbodvoid hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const char *owner) 566f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod{ 5676c15ddfe2b45383824b64058ae69939d002183a6Behdad Esfahbod if (DEBUG_ENABLED (BUFFER)) 568b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod dump_var_allocation (this); 569b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod 570a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod DEBUG_MSG (BUFFER, this, 571a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod "Deallocating var bytes %d..%d for %s", 572a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod byte_i, byte_i + count - 1, owner); 573a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod 574b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (byte_i < 8 && byte_i + count <= 8); 575f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod for (unsigned int i = byte_i; i < byte_i + count; i++) { 576b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (allocated_var_bytes[i]); 577b65c06025d2b54a44f716e030d4b10072c65bea8Behdad Esfahbod assert (0 == strcmp (allocated_var_owner[i], owner)); 578f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod allocated_var_bytes[i]--; 579f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod } 580f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod} 581f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod 582965c280de09b49d711cb78d629da321c802084deBehdad Esfahbodvoid hb_buffer_t::assert_var (unsigned int byte_i, unsigned int count, const char *owner) 583965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod{ 5846c15ddfe2b45383824b64058ae69939d002183a6Behdad Esfahbod if (DEBUG_ENABLED (BUFFER)) 585965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod dump_var_allocation (this); 586965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod 587965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod DEBUG_MSG (BUFFER, this, 588965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod "Asserting var bytes %d..%d for %s", 589965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod byte_i, byte_i + count - 1, owner); 590965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod 591965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod assert (byte_i < 8 && byte_i + count <= 8); 592965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod for (unsigned int i = byte_i; i < byte_i + count; i++) { 593965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod assert (allocated_var_bytes[i]); 594965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod assert (0 == strcmp (allocated_var_owner[i], owner)); 595965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod } 596965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod} 597965c280de09b49d711cb78d629da321c802084deBehdad Esfahbod 598a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbodvoid hb_buffer_t::deallocate_var_all (void) 599a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod{ 600a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes)); 601a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod memset (allocated_var_owner, 0, sizeof (allocated_var_owner)); 602a9ad3d3460ba863a8d8f3766ccbeab288c3c6822Behdad Esfahbod} 603f4a579bc42fb811ff5c391a0e97b7d8656ef59b1Behdad Esfahbod 6046b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod/* Public API */ 6056b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod 606288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 607288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_create: (constructor) 608288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 609288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 610288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 611288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: (transfer full) 612288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 613288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 614288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 615b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbodhb_buffer_t * 616c54599ad269380c7aa28d885fcfd660fc2c10a7bBehdad Esfahbodhb_buffer_create (void) 6179f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod{ 618b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod hb_buffer_t *buffer; 619b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod 62047e71d9661946a4ffb96026bf1d697d788414ab5Behdad Esfahbod if (!(buffer = hb_object_create<hb_buffer_t> ())) 621f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod return hb_buffer_get_empty (); 6229f8da38cd108590514b71756b752d98952a9221fBehdad Esfahbod 623468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reset (); 6245ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 62511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod return buffer; 62611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 6277a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod 628288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 629288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_empty: 630288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 631288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 632288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 633288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: (transfer full): 634288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 635288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 636288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 63711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_t * 63880a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbodhb_buffer_get_empty (void) 63980a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbod{ 640f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod static const hb_buffer_t _hb_buffer_nil = { 641f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod HB_OBJECT_HEADER_STATIC, 642f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod 643d5045a5f4017631a4660f985fe451c5a64c42ca0Behdad Esfahbod const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil), 644f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod HB_SEGMENT_PROPERTIES_DEFAULT, 6454dc798de19c767b91fd3025c85593fa6809d1340Behdad Esfahbod HB_BUFFER_FLAG_DEFAULT, 646f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod 64796fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod HB_BUFFER_CONTENT_TYPE_INVALID, 6480594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod true, /* in_error */ 6490594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod true, /* have_output */ 6500594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod true /* have_positions */ 65105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 65205207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod /* Zero is good enough for everything else. */ 653f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod }; 654f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod 655f06ab8a4262c759b4723614fd28f55ee77aa8466Behdad Esfahbod return const_cast<hb_buffer_t *> (&_hb_buffer_nil); 65680a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbod} 65780a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbod 658288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 659288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_reference: (skip) 660288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 661288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 662288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 663288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 664288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: (transfer full): 665288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 666288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 667288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 66880a6833b032bc63b4e8c3da6489d3767af1168f3Behdad Esfahbodhb_buffer_t * 66911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_reference (hb_buffer_t *buffer) 67011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 67147e71d9661946a4ffb96026bf1d697d788414ab5Behdad Esfahbod return hb_object_reference (buffer); 67211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 673f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod 674288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 675288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_destroy: (skip) 676288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 677288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 678288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 679288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 680288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 681288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 6827a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbodvoid 68311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_buffer_destroy (hb_buffer_t *buffer) 6847a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod{ 68547e71d9661946a4ffb96026bf1d697d788414ab5Behdad Esfahbod if (!hb_object_destroy (buffer)) return; 68611fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 6875ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod hb_unicode_funcs_destroy (buffer->unicode); 6885ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 6897e7007a1c9bf2c07a8369752126ece8fa6164248Behdad Esfahbod free (buffer->info); 6901b621823f3e31b48c80cc8b0691dfa873ba086cdBehdad Esfahbod free (buffer->pos); 69111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 692b857b49c82782d29d6d189f1a9f4a84d39cd84eaBehdad Esfahbod free (buffer); 6937a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod} 6947a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod 695288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 696288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_user_data: (skip) 697288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 698288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @key: 699288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @data: 700288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @destroy: 701288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @replace: 702288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 703288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 704288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 705288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 706288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 707288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 708288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 7095fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_bool_t 7105fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_buffer_set_user_data (hb_buffer_t *buffer, 7115fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod hb_user_data_key_t *key, 7125fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod void * data, 71333ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod hb_destroy_func_t destroy, 71433ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod hb_bool_t replace) 7155fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod{ 71633ccc77902660ed4b49184e5ec99f4fd0ef63175Behdad Esfahbod return hb_object_set_user_data (buffer, key, data, destroy, replace); 7175fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod} 7185fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 719288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 720288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_user_data: (skip) 721288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 722288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @key: 723288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 724288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 725288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 726288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 727288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 728288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 729288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 7305fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodvoid * 7315fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbodhb_buffer_get_user_data (hb_buffer_t *buffer, 7325fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod hb_user_data_key_t *key) 7335fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod{ 7345fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod return hb_object_get_user_data (buffer, key); 7355fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod} 7365fa849b77d49da2212825ebb1bea9145713b8449Behdad Esfahbod 7375ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 738288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 739288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_content_type: 740288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 741288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @content_type: 742288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 743288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 744288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 745288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 746288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 7475ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodvoid 74896fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_set_content_type (hb_buffer_t *buffer, 74996fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod hb_buffer_content_type_t content_type) 75096fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod{ 75196fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod buffer->content_type = content_type; 75296fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod} 75396fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 754288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 755288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_content_type: 756288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 757288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 758288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 759288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 760288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 761288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 762288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 763288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 76496fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_content_type_t 76596fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodhb_buffer_get_content_type (hb_buffer_t *buffer) 76696fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod{ 76796fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod return buffer->content_type; 76896fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod} 76996fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 77096fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbod 771288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 772288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_unicode_funcs: 773288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 774288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @unicode_funcs: 775288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 776288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 777288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 778288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 779288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 78096fdc04e5c6daafce3d45e7508418e4db94df44cBehdad Esfahbodvoid 7815ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_set_unicode_funcs (hb_buffer_t *buffer, 782288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod hb_unicode_funcs_t *unicode_funcs) 7835ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 784e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 785e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 786e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 787288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod if (!unicode_funcs) 788288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod unicode_funcs = hb_unicode_funcs_get_default (); 789d5045a5f4017631a4660f985fe451c5a64c42ca0Behdad Esfahbod 7900465e69832393cc1ed36508ec5d597fbab64877aBehdad Esfahbod 791288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod hb_unicode_funcs_reference (unicode_funcs); 7925ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod hb_unicode_funcs_destroy (buffer->unicode); 793288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod buffer->unicode = unicode_funcs; 7945ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 7955ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 796288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 797288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_unicode_funcs: 798288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 799288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 800288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 801288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 802288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 803288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 804288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 805288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 8065ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_unicode_funcs_t * 8075ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_get_unicode_funcs (hb_buffer_t *buffer) 8085ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 8095ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod return buffer->unicode; 8105ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 8115ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 812288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 813288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_direction: 814288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 815288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @direction: 816288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 817288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 818288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 819288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 820288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 8215ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodvoid 8225ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_set_direction (hb_buffer_t *buffer, 8235ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod hb_direction_t direction) 8245ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 8255ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 826e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 827e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 828e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 8294e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod buffer->props.direction = direction; 8305ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 8315ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 832288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 833288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_direction: 834288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 835288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 836288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 837288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 838288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 839288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 840288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 841288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 8425ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_direction_t 8435ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbodhb_buffer_get_direction (hb_buffer_t *buffer) 8445ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod{ 8454e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod return buffer->props.direction; 8465ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod} 8475ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 848288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 849288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_script: 850288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 851288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @script: 852288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 853288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 854288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 855288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 856288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 857ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodvoid 858ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_set_script (hb_buffer_t *buffer, 859ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod hb_script_t script) 860ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 861e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 862e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 863e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 8644e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod buffer->props.script = script; 865ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 866ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 867288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 868288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_script: 869288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 870288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 871288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 872288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 873288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 874288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 875288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 876288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 877ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_script_t 878ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_get_script (hb_buffer_t *buffer) 879ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 8804e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod return buffer->props.script; 881ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 882ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 883288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 884288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_language: 885288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 886288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @language: 887288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 888288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 889288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 890288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 891288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 892ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodvoid 893ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_set_language (hb_buffer_t *buffer, 894ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod hb_language_t language) 895ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 896e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 897e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod return; 898e0db4b868f9fdd8e680890f87dd4e13a1c27b7a1Behdad Esfahbod 8994e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod buffer->props.language = language; 900ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 901ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 902288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 903288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_language: 904288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 905288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 906288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 907288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 908288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 909288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 910288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 911288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 912ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_language_t 913ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbodhb_buffer_get_language (hb_buffer_t *buffer) 914ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod{ 9154e4ef24e46f273ad2bdda2f718223e05b37dd50fBehdad Esfahbod return buffer->props.language; 916ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod} 917ae070b7d39d03bd8bc1244f687b24db505f4af3fBehdad Esfahbod 918288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 919288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_segment_properties: 920288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 921288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @props: 922288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 923288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 924288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 925288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 926288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 9270c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodvoid 928f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_buffer_set_segment_properties (hb_buffer_t *buffer, 929f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod const hb_segment_properties_t *props) 930f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod{ 931f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 932f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod return; 933f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 934f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod buffer->props = *props; 935f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod} 936f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 937288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 938288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_segment_properties: 939288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 940288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @props: 941288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 942288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 943288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 944288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 945288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 946f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodvoid 947f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodhb_buffer_get_segment_properties (hb_buffer_t *buffer, 948f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod hb_segment_properties_t *props) 949f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod{ 950f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod *props = buffer->props; 951f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod} 952f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 953f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod 954288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 955288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_flags: 956288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 957288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @flags: 958288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 959288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 960288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 961288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 962288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 963f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbodvoid 9640c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_set_flags (hb_buffer_t *buffer, 9650c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod hb_buffer_flags_t flags) 9660c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod{ 9670c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 9680c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod return; 9690c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod 9700c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod buffer->flags = flags; 9710c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod} 9720c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod 973288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 974288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_get_flags: 975288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 976288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 977288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 978288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 979288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 980288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 981288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 982288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 9830c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_flags_t 9840c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbodhb_buffer_get_flags (hb_buffer_t *buffer) 9850c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod{ 9860c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod return buffer->flags; 9870c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod} 9880c7df2222862122ebbdc8665a21d6771ef5e0252Behdad Esfahbod 9895ebabecef382c3e8b0a2a5657b2c01f7ff37d796Behdad Esfahbod 990288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 991288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_reset: 992288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 993288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 994288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 995288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 996288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 997288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 9987a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbodvoid 999c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_buffer_reset (hb_buffer_t *buffer) 1000c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod{ 1001468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reset (); 10027a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod} 10037a26864308bd1ca8d5f47d798411cac7239b7d38Behdad Esfahbod 1004288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1005288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_clear_contents: 1006288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1007288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1008288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1009288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1010288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1011288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 101282ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbodvoid 10131172dc736280566426eb6dade1a886b2a0ca9aa4Behdad Esfahbodhb_buffer_clear_contents (hb_buffer_t *buffer) 101482ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod{ 101582ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod buffer->clear (); 101682ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod} 101782ecaff736e245e117d70b6ec1497508c6eb08d2Behdad Esfahbod 1018288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1019288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_pre_allocate: 1020288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1021288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @size: 1022288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1023288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1024288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1025288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 1026288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1027288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1028288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1029a6a79df5fe2ed2cd307e7a991346faee164e70d9Behdad Esfahbodhb_bool_t 103002a534b23f2d1e7475109563b9f61221ed020e8bRyan Lortiehb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size) 1031f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod{ 1032468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod return buffer->ensure (size); 1033f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod} 1034f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbod 1035288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1036288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_allocation_successful: 1037288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1038288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1039288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1040288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1041288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 1042288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1043288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1044288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1045aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbodhb_bool_t 1046aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbodhb_buffer_allocation_successful (hb_buffer_t *buffer) 1047aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod{ 1048aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod return !buffer->in_error; 1049aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod} 1050aab0de50e23727b69fa8c3d4e05c50c114c62835Behdad Esfahbod 1051288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1052288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add: 1053288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1054288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @codepoint: 1055288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @cluster: 1056288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1057288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1058288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1059288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1060288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1061f9cd1014f8f4d0394b5e0e9eefc1e2af13c59cabBehdad Esfahbodvoid 1062f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbodhb_buffer_add (hb_buffer_t *buffer, 1063f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbod hb_codepoint_t codepoint, 1064f85faee9b3cb841ea977403945e2c877ab32b97aBehdad Esfahbod unsigned int cluster) 10656b347138b597c41af24453f630336ba2fc033dc5Behdad Esfahbod{ 106666ac2ff32e24f0d5658ca172147613081a133847Behdad Esfahbod buffer->add (codepoint, cluster); 106705207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (1); 10689111b21ef99d5e53348176f683261b0101eb427fBehdad Esfahbod} 10699111b21ef99d5e53348176f683261b0101eb427fBehdad Esfahbod 1070288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1071288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_set_length: 1072288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1073288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @length: 1074288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1075288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1076288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1077288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Return value: 1078288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1079288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1080288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1081c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_bool_t 1082c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbodhb_buffer_set_length (hb_buffer_t *buffer, 1083c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod unsigned int length) 1084c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod{ 1085e1ac38f8dd04c29d2d4140f5a492cdaf25d72901Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 1086e1ac38f8dd04c29d2d4140f5a492cdaf25d72901Behdad Esfahbod return length == 0; 1087e1ac38f8dd04c29d2d4140f5a492cdaf25d72901Behdad Esfahbod 1088468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod if (!buffer->ensure (length)) 10890594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod return false; 1090c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod 1091c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod /* Wipe the new space */ 1092c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod if (length > buffer->len) { 1093c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod memset (buffer->info + buffer->len, 0, sizeof (buffer->info[0]) * (length - buffer->len)); 1094c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod if (buffer->have_positions) 1095c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod memset (buffer->pos + buffer->len, 0, sizeof (buffer->pos[0]) * (length - buffer->len)); 1096c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod } 1097c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod 1098c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod buffer->len = length; 109905207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 110005207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod if (!length) 110105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (0); 110205207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (1); 110305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 11040594a2448440208efa0acac9a5d8d52d43108289Behdad Esfahbod return true; 1105c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod} 1106c910bec863215f918c659f58debbc7fe5264d7b6Behdad Esfahbod 11075f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 11085f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_get_length: 11095f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 11105f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11115f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Returns the number of items in the buffer. 11125f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11135f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Return value: buffer length. 11145f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11155f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1116c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 111711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodunsigned int 11183d14528b8b2e7da425a9df7057fc9fb326d8298cBehdad Esfahbodhb_buffer_get_length (hb_buffer_t *buffer) 111911fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 11206960350be97f24e97140391025b56369c393a3dfBehdad Esfahbod return buffer->len; 112111fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 112211fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 11235f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 11245f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_get_glyph_infos: 11255f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 11265f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @length: (out): output array length. 11275f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11285f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Returns buffer glyph information array. Returned pointer 11295f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * is valid as long as buffer contents are not modified. 11305f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11315f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Return value: (transfer none) (array length=length): buffer glyph information array. 11325f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11335f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1134c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 113511fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_info_t * 113670566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortiehb_buffer_get_glyph_infos (hb_buffer_t *buffer, 113770566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie unsigned int *length) 113811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 113970566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie if (length) 114070566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie *length = buffer->len; 114170566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie 11427e7007a1c9bf2c07a8369752126ece8fa6164248Behdad Esfahbod return (hb_glyph_info_t *) buffer->info; 114311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 114411fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 11455f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 11465f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_get_glyph_positions: 11475f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 11485f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @length: (out): output length. 11495f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11505f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Returns buffer glyph position array. Returned pointer 11515f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * is valid as long as buffer contents are not modified. 11525f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11535f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Return value: (transfer none) (array length=length): buffer glyph position array. 11545f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11555f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1156c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 115711fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbodhb_glyph_position_t * 115870566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortiehb_buffer_get_glyph_positions (hb_buffer_t *buffer, 115970566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie unsigned int *length) 116011fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod{ 1161314905d7548d5be58354546d660754b807b6efb2Behdad Esfahbod if (!buffer->have_positions) 1162468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->clear_positions (); 116311fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod 116470566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie if (length) 116570566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie *length = buffer->len; 116670566befc59cfa8b9c43ac682749c40ea783b1ddRyan Lortie 11671b621823f3e31b48c80cc8b0691dfa873ba086cdBehdad Esfahbod return (hb_glyph_position_t *) buffer->pos; 116811fbb5487d9900a019440ef8235f35c9f525decbBehdad Esfahbod} 1169fbaf8ffa098bd2b6fb4f4bc2d04b360a319c4af5Behdad Esfahbod 11705f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 11715f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_reverse: 11725f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 11735f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11745f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Reverses buffer contents. 11755f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11765f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1177c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 1178ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodvoid 1179ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodhb_buffer_reverse (hb_buffer_t *buffer) 1180ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod{ 1181468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reverse (); 1182ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod} 1183ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod 11845f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 11855f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_reverse_clusters: 11865f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 11875f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11885f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Reverses buffer clusters. That is, the buffer contents are 11895f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * reversed, then each cluster (consecutive items having the 11905f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * same cluster number) are reversed again. 11915f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 11925f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1193c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 1194ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodvoid 1195ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbodhb_buffer_reverse_clusters (hb_buffer_t *buffer) 1196ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod{ 1197468e9cb25c9bc14781b7013e447d763f93bf76a3Behdad Esfahbod buffer->reverse_clusters (); 1198ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod} 1199ff44f88df2c46920f3ec2384ef321a4c7bb0f6efBehdad Esfahbod 12005f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod/** 12015f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_buffer_guess_segment_properties: 12025f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * @buffer: a buffer. 12035f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12045f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Sets unset buffer segment properties based on buffer Unicode 12055f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * contents. If buffer is not empty, it must have content type 12065f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * %HB_BUFFER_CONTENT_TYPE_UNICODE. 12075f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12085f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * If buffer script is not set (ie. is %HB_SCRIPT_INVALID), it 12095f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * will be set to the Unicode script of the first character in 12105f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * the buffer that has a script other than %HB_SCRIPT_COMMON, 12115f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * %HB_SCRIPT_INHERITED, and %HB_SCRIPT_UNKNOWN. 12125f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12135f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Next, if buffer direction is not set (ie. is %HB_DIRECTION_INVALID), 12145f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * it will be set to the natural horizontal direction of the 12155f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * buffer script as returned by hb_script_get_horizontal_direction(). 12165f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12175f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Finally, if buffer language is not set (ie. is %HB_LANGUAGE_INVALID), 12185f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * it will be set to the process's default language as returned by 12195f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * hb_language_get_default(). This may change in the future by 12205f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * taking buffer script into consideration when choosing a language. 12215f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * 12225f512017ba615ba6ac8e5da2ea0c57a72db2c26bBehdad Esfahbod * Since: 1.0 1223c44b81833d5bfb9a926d348a76463314c3ec2018Behdad Esfahbod **/ 122402aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbodvoid 12253f82f8ff07a9d16a7c047129658c1bbedfdb5436Behdad Esfahbodhb_buffer_guess_segment_properties (hb_buffer_t *buffer) 122602aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod{ 12273f82f8ff07a9d16a7c047129658c1bbedfdb5436Behdad Esfahbod buffer->guess_segment_properties (); 122802aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod} 122902aeca985b570763342c35e99af90025bfa088d5Behdad Esfahbod 12307f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbodtemplate <typename T> 12317f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbodstatic inline void 12327f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbodhb_buffer_add_utf (hb_buffer_t *buffer, 12337f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod const T *text, 12347f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod int text_length, 12357f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod unsigned int item_offset, 12367f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod int item_length) 12377f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod{ 12387f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || 12397f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod (!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); 12407f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 12417f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod if (unlikely (hb_object_is_inert (buffer))) 12427f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod return; 12437f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 12441f66c3c1a0eb869c0d85a015235313177e0cec62Behdad Esfahbod if (text_length == -1) 12451f66c3c1a0eb869c0d85a015235313177e0cec62Behdad Esfahbod text_length = hb_utf_strlen (text); 12467f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 12477f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod if (item_length == -1) 12487f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod item_length = text_length - item_offset; 12497f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 12507f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod buffer->ensure (buffer->len + item_length * sizeof (T) / 4); 12517f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 1252da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod /* If buffer is empty and pre-context provided, install it. 1253da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * This check is written this way, to make sure people can 1254da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * provide pre-context in one add_utf() call, then provide 1255da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * text in a follow-up call. See: 1256da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * 1257da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod * https://bugzilla.mozilla.org/show_bug.cgi?id=801410#c13 1258da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod */ 1259da70111ab234e8b740ce6fb1789a1809fbec0c44Behdad Esfahbod if (!buffer->len && item_offset > 0) 126005207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 126105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod /* Add pre-context */ 126205207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (0); 126305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod const T *prev = text + item_offset; 126405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod const T *start = text; 126505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod while (start < prev && buffer->context_len[0] < buffer->CONTEXT_LENGTH) 126605207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 126705207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod hb_codepoint_t u; 126805207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod prev = hb_utf_prev (prev, start, &u); 126905207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->context[0][buffer->context_len[0]++] = u; 127005207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod } 127105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod } 127205207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 127305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod const T *next = text + item_offset; 12747f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod const T *end = next + item_length; 127505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod while (next < end) 127605207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 12777f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod hb_codepoint_t u; 12787f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod const T *old_next = next; 12797f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod next = hb_utf_next (next, end, &u); 128066ac2ff32e24f0d5658ca172147613081a133847Behdad Esfahbod buffer->add (u, old_next - (const T *) text); 128105207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod } 128205207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod 128305207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod /* Add post-context */ 128405207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->clear_context (1); 128505207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod end = text + text_length; 128605207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod while (next < end && buffer->context_len[1] < buffer->CONTEXT_LENGTH) 128705207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod { 128805207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod hb_codepoint_t u; 128905207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod next = hb_utf_next (next, end, &u); 129005207a79e0ae1769c5feaebe3fd99bdf9cfcf834Behdad Esfahbod buffer->context[1][buffer->context_len[1]++] = u; 12917f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod } 12927f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod 12937f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; 1294299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod} 1295299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod 1296288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1297288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add_utf8: 1298288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1299288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text: (array length=text_length): 1300288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text_length: 1301288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_offset: 1302288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_length: 1303288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1304288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1305288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1306288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1307288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1308299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodvoid 1309299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodhb_buffer_add_utf8 (hb_buffer_t *buffer, 1310299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod const char *text, 1311944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 1312299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_offset, 1313944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int item_length) 1314299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod{ 13157f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod hb_buffer_add_utf (buffer, (const uint8_t *) text, text_length, item_offset, item_length); 1316299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod} 1317299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod 1318288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1319288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add_utf16: 1320288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1321288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text: (array length=text_length): 1322288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text_length: 1323288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_offset: 1324288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_length: 1325288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1326288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1327288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1328288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1329288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1330299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodvoid 1331299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodhb_buffer_add_utf16 (hb_buffer_t *buffer, 1332299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod const uint16_t *text, 1333944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 1334299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_offset, 1335288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod int item_length) 1336299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod{ 13377f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod hb_buffer_add_utf (buffer, text, text_length, item_offset, item_length); 13380e0a4da9b7677a09e00d27313236e1f333864dd6Behdad Esfahbod} 13390e0a4da9b7677a09e00d27313236e1f333864dd6Behdad Esfahbod 1340288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1341288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_add_utf32: 1342288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1343288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text: (array length=text_length): 1344288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @text_length: 1345288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_offset: 1346288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @item_length: 1347288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1348288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1349288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1350288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1351288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 1352299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodvoid 1353299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbodhb_buffer_add_utf32 (hb_buffer_t *buffer, 1354299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod const uint32_t *text, 1355944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int text_length, 1356299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod unsigned int item_offset, 1357944b2ba1ce076385f985212bbdf2df96a8a995f0Behdad Esfahbod int item_length) 1358299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod{ 13597f19ae7b9f806a2e35206b2ad41651c5f80b2537Behdad Esfahbod hb_buffer_add_utf (buffer, text, text_length, item_offset, item_length); 1360299f08961ffcea27e8def4f0743d0c86ef8dadf1Behdad Esfahbod} 1361acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 1362acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 136339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodstatic int 136439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodcompare_info_codepoint (const hb_glyph_info_t *pa, 136539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod const hb_glyph_info_t *pb) 136639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod{ 136739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod return (int) pb->codepoint - (int) pa->codepoint; 136839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod} 136939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 137039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodstatic inline void 137139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodnormalize_glyphs_cluster (hb_buffer_t *buffer, 137239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int start, 137339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int end, 137439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod bool backward) 137539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod{ 137639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_glyph_position_t *pos = buffer->pos; 137739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 137839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod /* Total cluster advance */ 137939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_position_t total_x_advance = 0, total_y_advance = 0; 138039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (unsigned int i = start; i < end; i++) 138139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod { 138239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod total_x_advance += pos[i].x_advance; 138339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod total_y_advance += pos[i].y_advance; 138439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 138539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 138639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_position_t x_advance = 0, y_advance = 0; 138739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (unsigned int i = start; i < end; i++) 138839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod { 138939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].x_offset += x_advance; 139039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].y_offset += y_advance; 139139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 139239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod x_advance += pos[i].x_advance; 139339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod y_advance += pos[i].y_advance; 139439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 139539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].x_advance = 0; 139639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].y_advance = 0; 139739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 139839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 139939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod if (backward) 140039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod { 140139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod /* Transfer all cluster advance to the last glyph. */ 140239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[end - 1].x_advance = total_x_advance; 140339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[end - 1].y_advance = total_y_advance; 140439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 140539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_bubble_sort (buffer->info + start, end - start - 1, compare_info_codepoint, buffer->pos + start); 140639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } else { 140739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod /* Transfer all cluster advance to the first glyph. */ 140839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[start].x_advance += total_x_advance; 140939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[start].y_advance += total_y_advance; 141039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (unsigned int i = start + 1; i < end; i++) { 141139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].x_offset -= total_x_advance; 141239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod pos[i].y_offset -= total_y_advance; 141339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 141439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_bubble_sort (buffer->info + start + 1, end - start - 1, compare_info_codepoint, buffer->pos + start + 1); 141539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 141639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod} 141739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 1418288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod/** 1419288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * hb_buffer_normalize_glyphs: 1420288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * @buffer: a buffer. 1421288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1422288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1423288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * 1424288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod * Since: 1.0 1425288f2899979bcc9e68f8115cb76e3271ed0e17bcBehdad Esfahbod **/ 142639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodvoid 142739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbodhb_buffer_normalize_glyphs (hb_buffer_t *buffer) 142839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod{ 142939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod assert (buffer->have_positions); 14307d37280600c157f3c4eae8746e99511702a58e8fBehdad Esfahbod assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); 143139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 143239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); 143339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 143439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int count = buffer->len; 143539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod if (unlikely (!count)) return; 143639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod hb_glyph_info_t *info = buffer->info; 143739b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod 143839b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int start = 0; 143939b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod unsigned int end; 144039b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod for (end = start + 1; end < count; end++) 144139b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod if (info[start].cluster != info[end].cluster) { 144239b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod normalize_glyphs_cluster (buffer, start, end, backward); 144339b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod start = end; 144439b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod } 144539b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod normalize_glyphs_cluster (buffer, start, end, backward); 144639b17837b4064d59c18cebb49c1c0b5b8cc0c117Behdad Esfahbod} 1447