michael@0: /* michael@0: * Copyright © 1998-2004 David Turner and Werner Lemberg michael@0: * Copyright © 2004,2007,2009,2010 Red Hat, Inc. michael@0: * Copyright © 2011,2012 Google, Inc. michael@0: * michael@0: * This is part of HarfBuzz, a text shaping library. michael@0: * michael@0: * Permission is hereby granted, without written agreement and without michael@0: * license or royalty fees, to use, copy, modify, and distribute this michael@0: * software and its documentation for any purpose, provided that the michael@0: * above copyright notice and the following two paragraphs appear in michael@0: * all copies of this software. michael@0: * michael@0: * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR michael@0: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES michael@0: * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN michael@0: * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH michael@0: * DAMAGE. michael@0: * michael@0: * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, michael@0: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND michael@0: * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS michael@0: * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO michael@0: * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. michael@0: * michael@0: * Red Hat Author(s): Owen Taylor, Behdad Esfahbod michael@0: * Google Author(s): Behdad Esfahbod michael@0: */ michael@0: michael@0: #include "hb-buffer-private.hh" michael@0: #include "hb-utf-private.hh" michael@0: michael@0: michael@0: #ifndef HB_DEBUG_BUFFER michael@0: #define HB_DEBUG_BUFFER (HB_DEBUG+0) michael@0: #endif michael@0: michael@0: michael@0: hb_bool_t michael@0: hb_segment_properties_equal (const hb_segment_properties_t *a, michael@0: const hb_segment_properties_t *b) michael@0: { michael@0: return a->direction == b->direction && michael@0: a->script == b->script && michael@0: a->language == b->language && michael@0: a->reserved1 == b->reserved1 && michael@0: a->reserved2 == b->reserved2; michael@0: michael@0: } michael@0: michael@0: unsigned int michael@0: hb_segment_properties_hash (const hb_segment_properties_t *p) michael@0: { michael@0: return (unsigned int) p->direction ^ michael@0: (unsigned int) p->script ^ michael@0: (intptr_t) (p->language); michael@0: } michael@0: michael@0: michael@0: michael@0: /* Here is how the buffer works internally: michael@0: * michael@0: * There are two info pointers: info and out_info. They always have michael@0: * the same allocated size, but different lengths. michael@0: * michael@0: * As an optimization, both info and out_info may point to the michael@0: * same piece of memory, which is owned by info. This remains the michael@0: * case as long as out_len doesn't exceed i at any time. michael@0: * In that case, swap_buffers() is no-op and the glyph operations operate michael@0: * mostly in-place. michael@0: * michael@0: * As soon as out_info gets longer than info, out_info is moved over michael@0: * to an alternate buffer (which we reuse the pos buffer for!), and its michael@0: * current contents (out_len entries) are copied to the new place. michael@0: * This should all remain transparent to the user. swap_buffers() then michael@0: * switches info and out_info. michael@0: */ michael@0: michael@0: michael@0: michael@0: /* Internal API */ michael@0: michael@0: bool michael@0: hb_buffer_t::enlarge (unsigned int size) michael@0: { michael@0: if (unlikely (in_error)) michael@0: return false; michael@0: michael@0: unsigned int new_allocated = allocated; michael@0: hb_glyph_position_t *new_pos = NULL; michael@0: hb_glyph_info_t *new_info = NULL; michael@0: bool separate_out = out_info != info; michael@0: michael@0: if (unlikely (_hb_unsigned_int_mul_overflows (size, sizeof (info[0])))) michael@0: goto done; michael@0: michael@0: while (size >= new_allocated) michael@0: new_allocated += (new_allocated >> 1) + 32; michael@0: michael@0: ASSERT_STATIC (sizeof (info[0]) == sizeof (pos[0])); michael@0: if (unlikely (_hb_unsigned_int_mul_overflows (new_allocated, sizeof (info[0])))) michael@0: goto done; michael@0: michael@0: new_pos = (hb_glyph_position_t *) realloc (pos, new_allocated * sizeof (pos[0])); michael@0: new_info = (hb_glyph_info_t *) realloc (info, new_allocated * sizeof (info[0])); michael@0: michael@0: done: michael@0: if (unlikely (!new_pos || !new_info)) michael@0: in_error = true; michael@0: michael@0: if (likely (new_pos)) michael@0: pos = new_pos; michael@0: michael@0: if (likely (new_info)) michael@0: info = new_info; michael@0: michael@0: out_info = separate_out ? (hb_glyph_info_t *) pos : info; michael@0: if (likely (!in_error)) michael@0: allocated = new_allocated; michael@0: michael@0: return likely (!in_error); michael@0: } michael@0: michael@0: bool michael@0: hb_buffer_t::make_room_for (unsigned int num_in, michael@0: unsigned int num_out) michael@0: { michael@0: if (unlikely (!ensure (out_len + num_out))) return false; michael@0: michael@0: if (out_info == info && michael@0: out_len + num_out > idx + num_in) michael@0: { michael@0: assert (have_output); michael@0: michael@0: out_info = (hb_glyph_info_t *) pos; michael@0: memcpy (out_info, info, out_len * sizeof (out_info[0])); michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: hb_buffer_t::shift_forward (unsigned int count) michael@0: { michael@0: assert (have_output); michael@0: if (unlikely (!ensure (len + count))) return false; michael@0: michael@0: memmove (info + idx + count, info + idx, (len - idx) * sizeof (info[0])); michael@0: len += count; michael@0: idx += count; michael@0: michael@0: return true; michael@0: } michael@0: michael@0: hb_buffer_t::scratch_buffer_t * michael@0: hb_buffer_t::get_scratch_buffer (unsigned int *size) michael@0: { michael@0: have_output = false; michael@0: have_positions = false; michael@0: michael@0: out_len = 0; michael@0: out_info = info; michael@0: michael@0: assert ((uintptr_t) pos % sizeof (scratch_buffer_t) == 0); michael@0: *size = allocated * sizeof (pos[0]) / sizeof (scratch_buffer_t); michael@0: return (scratch_buffer_t *) (void *) pos; michael@0: } michael@0: michael@0: michael@0: michael@0: /* HarfBuzz-Internal API */ michael@0: michael@0: void michael@0: hb_buffer_t::reset (void) michael@0: { michael@0: if (unlikely (hb_object_is_inert (this))) michael@0: return; michael@0: michael@0: hb_unicode_funcs_destroy (unicode); michael@0: unicode = hb_unicode_funcs_get_default (); michael@0: michael@0: clear (); michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::clear (void) michael@0: { michael@0: if (unlikely (hb_object_is_inert (this))) michael@0: return; michael@0: michael@0: hb_segment_properties_t default_props = HB_SEGMENT_PROPERTIES_DEFAULT; michael@0: props = default_props; michael@0: flags = HB_BUFFER_FLAG_DEFAULT; michael@0: michael@0: content_type = HB_BUFFER_CONTENT_TYPE_INVALID; michael@0: in_error = false; michael@0: have_output = false; michael@0: have_positions = false; michael@0: michael@0: idx = 0; michael@0: len = 0; michael@0: out_len = 0; michael@0: out_info = info; michael@0: michael@0: serial = 0; michael@0: memset (allocated_var_bytes, 0, sizeof allocated_var_bytes); michael@0: memset (allocated_var_owner, 0, sizeof allocated_var_owner); michael@0: michael@0: memset (context, 0, sizeof context); michael@0: memset (context_len, 0, sizeof context_len); michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::add (hb_codepoint_t codepoint, michael@0: unsigned int cluster) michael@0: { michael@0: hb_glyph_info_t *glyph; michael@0: michael@0: if (unlikely (!ensure (len + 1))) return; michael@0: michael@0: glyph = &info[len]; michael@0: michael@0: memset (glyph, 0, sizeof (*glyph)); michael@0: glyph->codepoint = codepoint; michael@0: glyph->mask = 1; michael@0: glyph->cluster = cluster; michael@0: michael@0: len++; michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::add_info (const hb_glyph_info_t &glyph_info) michael@0: { michael@0: if (unlikely (!ensure (len + 1))) return; michael@0: michael@0: info[len] = glyph_info; michael@0: michael@0: len++; michael@0: } michael@0: michael@0: michael@0: void michael@0: hb_buffer_t::remove_output (void) michael@0: { michael@0: if (unlikely (hb_object_is_inert (this))) michael@0: return; michael@0: michael@0: have_output = false; michael@0: have_positions = false; michael@0: michael@0: out_len = 0; michael@0: out_info = info; michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::clear_output (void) michael@0: { michael@0: if (unlikely (hb_object_is_inert (this))) michael@0: return; michael@0: michael@0: have_output = true; michael@0: have_positions = false; michael@0: michael@0: out_len = 0; michael@0: out_info = info; michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::clear_positions (void) michael@0: { michael@0: if (unlikely (hb_object_is_inert (this))) michael@0: return; michael@0: michael@0: have_output = false; michael@0: have_positions = true; michael@0: michael@0: out_len = 0; michael@0: out_info = info; michael@0: michael@0: memset (pos, 0, sizeof (pos[0]) * len); michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::swap_buffers (void) michael@0: { michael@0: if (unlikely (in_error)) return; michael@0: michael@0: assert (have_output); michael@0: have_output = false; michael@0: michael@0: if (out_info != info) michael@0: { michael@0: hb_glyph_info_t *tmp_string; michael@0: tmp_string = info; michael@0: info = out_info; michael@0: out_info = tmp_string; michael@0: pos = (hb_glyph_position_t *) out_info; michael@0: } michael@0: michael@0: unsigned int tmp; michael@0: tmp = len; michael@0: len = out_len; michael@0: out_len = tmp; michael@0: michael@0: idx = 0; michael@0: } michael@0: michael@0: michael@0: void michael@0: hb_buffer_t::replace_glyphs (unsigned int num_in, michael@0: unsigned int num_out, michael@0: const uint32_t *glyph_data) michael@0: { michael@0: if (unlikely (!make_room_for (num_in, num_out))) return; michael@0: michael@0: merge_clusters (idx, idx + num_in); michael@0: michael@0: hb_glyph_info_t orig_info = info[idx]; michael@0: hb_glyph_info_t *pinfo = &out_info[out_len]; michael@0: for (unsigned int i = 0; i < num_out; i++) michael@0: { michael@0: *pinfo = orig_info; michael@0: pinfo->codepoint = glyph_data[i]; michael@0: pinfo++; michael@0: } michael@0: michael@0: idx += num_in; michael@0: out_len += num_out; michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::output_glyph (hb_codepoint_t glyph_index) michael@0: { michael@0: if (unlikely (!make_room_for (0, 1))) return; michael@0: michael@0: out_info[out_len] = info[idx]; michael@0: out_info[out_len].codepoint = glyph_index; michael@0: michael@0: out_len++; michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::output_info (const hb_glyph_info_t &glyph_info) michael@0: { michael@0: if (unlikely (!make_room_for (0, 1))) return; michael@0: michael@0: out_info[out_len] = glyph_info; michael@0: michael@0: out_len++; michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::copy_glyph (void) michael@0: { michael@0: if (unlikely (!make_room_for (0, 1))) return; michael@0: michael@0: out_info[out_len] = info[idx]; michael@0: michael@0: out_len++; michael@0: } michael@0: michael@0: bool michael@0: hb_buffer_t::move_to (unsigned int i) michael@0: { michael@0: if (!have_output) michael@0: { michael@0: assert (i <= len); michael@0: idx = i; michael@0: return true; michael@0: } michael@0: michael@0: assert (i <= out_len + (len - idx)); michael@0: michael@0: if (out_len < i) michael@0: { michael@0: unsigned int count = i - out_len; michael@0: if (unlikely (!make_room_for (count, count))) return false; michael@0: michael@0: memmove (out_info + out_len, info + idx, count * sizeof (out_info[0])); michael@0: idx += count; michael@0: out_len += count; michael@0: } michael@0: else if (out_len > i) michael@0: { michael@0: /* Tricky part: rewinding... */ michael@0: unsigned int count = out_len - i; michael@0: michael@0: if (unlikely (idx < count && !shift_forward (count + 32))) return false; michael@0: michael@0: assert (idx >= count); michael@0: michael@0: idx -= count; michael@0: out_len -= count; michael@0: memmove (info + idx, out_info + out_len, count * sizeof (out_info[0])); michael@0: } michael@0: michael@0: return true; michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::replace_glyph (hb_codepoint_t glyph_index) michael@0: { michael@0: if (unlikely (out_info != info || out_len != idx)) { michael@0: if (unlikely (!make_room_for (1, 1))) return; michael@0: out_info[out_len] = info[idx]; michael@0: } michael@0: out_info[out_len].codepoint = glyph_index; michael@0: michael@0: idx++; michael@0: out_len++; michael@0: } michael@0: michael@0: michael@0: void michael@0: hb_buffer_t::set_masks (hb_mask_t value, michael@0: hb_mask_t mask, michael@0: unsigned int cluster_start, michael@0: unsigned int cluster_end) michael@0: { michael@0: hb_mask_t not_mask = ~mask; michael@0: value &= mask; michael@0: michael@0: if (!mask) michael@0: return; michael@0: michael@0: if (cluster_start == 0 && cluster_end == (unsigned int)-1) { michael@0: unsigned int count = len; michael@0: for (unsigned int i = 0; i < count; i++) michael@0: info[i].mask = (info[i].mask & not_mask) | value; michael@0: return; michael@0: } michael@0: michael@0: unsigned int count = len; michael@0: for (unsigned int i = 0; i < count; i++) michael@0: if (cluster_start <= info[i].cluster && info[i].cluster < cluster_end) michael@0: info[i].mask = (info[i].mask & not_mask) | value; michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::reverse_range (unsigned int start, michael@0: unsigned int end) michael@0: { michael@0: unsigned int i, j; michael@0: michael@0: if (start == end - 1) michael@0: return; michael@0: michael@0: for (i = start, j = end - 1; i < j; i++, j--) { michael@0: hb_glyph_info_t t; michael@0: michael@0: t = info[i]; michael@0: info[i] = info[j]; michael@0: info[j] = t; michael@0: } michael@0: michael@0: if (pos) { michael@0: for (i = start, j = end - 1; i < j; i++, j--) { michael@0: hb_glyph_position_t t; michael@0: michael@0: t = pos[i]; michael@0: pos[i] = pos[j]; michael@0: pos[j] = t; michael@0: } michael@0: } michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::reverse (void) michael@0: { michael@0: if (unlikely (!len)) michael@0: return; michael@0: michael@0: reverse_range (0, len); michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::reverse_clusters (void) michael@0: { michael@0: unsigned int i, start, count, last_cluster; michael@0: michael@0: if (unlikely (!len)) michael@0: return; michael@0: michael@0: reverse (); michael@0: michael@0: count = len; michael@0: start = 0; michael@0: last_cluster = info[0].cluster; michael@0: for (i = 1; i < count; i++) { michael@0: if (last_cluster != info[i].cluster) { michael@0: reverse_range (start, i); michael@0: start = i; michael@0: last_cluster = info[i].cluster; michael@0: } michael@0: } michael@0: reverse_range (start, i); michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::merge_clusters (unsigned int start, michael@0: unsigned int end) michael@0: { michael@0: if (unlikely (end - start < 2)) michael@0: return; michael@0: michael@0: unsigned int cluster = info[start].cluster; michael@0: michael@0: for (unsigned int i = start + 1; i < end; i++) michael@0: cluster = MIN (cluster, info[i].cluster); michael@0: michael@0: /* Extend end */ michael@0: while (end < len && info[end - 1].cluster == info[end].cluster) michael@0: end++; michael@0: michael@0: /* Extend start */ michael@0: while (idx < start && info[start - 1].cluster == info[start].cluster) michael@0: start--; michael@0: michael@0: /* If we hit the start of buffer, continue in out-buffer. */ michael@0: if (idx == start) michael@0: for (unsigned i = out_len; i && out_info[i - 1].cluster == info[start].cluster; i--) michael@0: out_info[i - 1].cluster = cluster; michael@0: michael@0: for (unsigned int i = start; i < end; i++) michael@0: info[i].cluster = cluster; michael@0: } michael@0: void michael@0: hb_buffer_t::merge_out_clusters (unsigned int start, michael@0: unsigned int end) michael@0: { michael@0: if (unlikely (end - start < 2)) michael@0: return; michael@0: michael@0: unsigned int cluster = out_info[start].cluster; michael@0: michael@0: for (unsigned int i = start + 1; i < end; i++) michael@0: cluster = MIN (cluster, out_info[i].cluster); michael@0: michael@0: /* Extend start */ michael@0: while (start && out_info[start - 1].cluster == out_info[start].cluster) michael@0: start--; michael@0: michael@0: /* Extend end */ michael@0: while (end < out_len && out_info[end - 1].cluster == out_info[end].cluster) michael@0: end++; michael@0: michael@0: /* If we hit the end of out-buffer, continue in buffer. */ michael@0: if (end == out_len) michael@0: for (unsigned i = idx; i < len && info[i].cluster == out_info[end - 1].cluster; i++) michael@0: info[i].cluster = cluster; michael@0: michael@0: for (unsigned int i = start; i < end; i++) michael@0: out_info[i].cluster = cluster; michael@0: } michael@0: michael@0: void michael@0: hb_buffer_t::guess_segment_properties (void) michael@0: { michael@0: assert (content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || michael@0: (!len && content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); michael@0: michael@0: /* If script is set to INVALID, guess from buffer contents */ michael@0: if (props.script == HB_SCRIPT_INVALID) { michael@0: for (unsigned int i = 0; i < len; i++) { michael@0: hb_script_t script = unicode->script (info[i].codepoint); michael@0: if (likely (script != HB_SCRIPT_COMMON && michael@0: script != HB_SCRIPT_INHERITED && michael@0: script != HB_SCRIPT_UNKNOWN)) { michael@0: props.script = script; michael@0: break; michael@0: } michael@0: } michael@0: } michael@0: michael@0: /* If direction is set to INVALID, guess from script */ michael@0: if (props.direction == HB_DIRECTION_INVALID) { michael@0: props.direction = hb_script_get_horizontal_direction (props.script); michael@0: } michael@0: michael@0: /* If language is not set, use default language from locale */ michael@0: if (props.language == HB_LANGUAGE_INVALID) { michael@0: /* TODO get_default_for_script? using $LANGUAGE */ michael@0: props.language = hb_language_get_default (); michael@0: } michael@0: } michael@0: michael@0: michael@0: static inline void michael@0: dump_var_allocation (const hb_buffer_t *buffer) michael@0: { michael@0: char buf[80]; michael@0: for (unsigned int i = 0; i < 8; i++) michael@0: buf[i] = '0' + buffer->allocated_var_bytes[7 - i]; michael@0: buf[8] = '\0'; michael@0: DEBUG_MSG (BUFFER, buffer, michael@0: "Current var allocation: %s", michael@0: buf); michael@0: } michael@0: michael@0: void hb_buffer_t::allocate_var (unsigned int byte_i, unsigned int count, const char *owner) michael@0: { michael@0: assert (byte_i < 8 && byte_i + count <= 8); michael@0: michael@0: if (DEBUG_ENABLED (BUFFER)) michael@0: dump_var_allocation (this); michael@0: DEBUG_MSG (BUFFER, this, michael@0: "Allocating var bytes %d..%d for %s", michael@0: byte_i, byte_i + count - 1, owner); michael@0: michael@0: for (unsigned int i = byte_i; i < byte_i + count; i++) { michael@0: assert (!allocated_var_bytes[i]); michael@0: allocated_var_bytes[i]++; michael@0: allocated_var_owner[i] = owner; michael@0: } michael@0: } michael@0: michael@0: void hb_buffer_t::deallocate_var (unsigned int byte_i, unsigned int count, const char *owner) michael@0: { michael@0: if (DEBUG_ENABLED (BUFFER)) michael@0: dump_var_allocation (this); michael@0: michael@0: DEBUG_MSG (BUFFER, this, michael@0: "Deallocating var bytes %d..%d for %s", michael@0: byte_i, byte_i + count - 1, owner); michael@0: michael@0: assert (byte_i < 8 && byte_i + count <= 8); michael@0: for (unsigned int i = byte_i; i < byte_i + count; i++) { michael@0: assert (allocated_var_bytes[i]); michael@0: assert (0 == strcmp (allocated_var_owner[i], owner)); michael@0: allocated_var_bytes[i]--; michael@0: } michael@0: } michael@0: michael@0: void hb_buffer_t::assert_var (unsigned int byte_i, unsigned int count, const char *owner) michael@0: { michael@0: if (DEBUG_ENABLED (BUFFER)) michael@0: dump_var_allocation (this); michael@0: michael@0: DEBUG_MSG (BUFFER, this, michael@0: "Asserting var bytes %d..%d for %s", michael@0: byte_i, byte_i + count - 1, owner); michael@0: michael@0: assert (byte_i < 8 && byte_i + count <= 8); michael@0: for (unsigned int i = byte_i; i < byte_i + count; i++) { michael@0: assert (allocated_var_bytes[i]); michael@0: assert (0 == strcmp (allocated_var_owner[i], owner)); michael@0: } michael@0: } michael@0: michael@0: void hb_buffer_t::deallocate_var_all (void) michael@0: { michael@0: memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes)); michael@0: memset (allocated_var_owner, 0, sizeof (allocated_var_owner)); michael@0: } michael@0: michael@0: /* Public API */ michael@0: michael@0: /** michael@0: * hb_buffer_create: (Xconstructor) michael@0: * michael@0: * michael@0: * michael@0: * Return value: (transfer full) michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_buffer_t * michael@0: hb_buffer_create (void) michael@0: { michael@0: hb_buffer_t *buffer; michael@0: michael@0: if (!(buffer = hb_object_create ())) michael@0: return hb_buffer_get_empty (); michael@0: michael@0: buffer->reset (); michael@0: michael@0: return buffer; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_empty: michael@0: * michael@0: * michael@0: * michael@0: * Return value: (transfer full): michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_buffer_t * michael@0: hb_buffer_get_empty (void) michael@0: { michael@0: static const hb_buffer_t _hb_buffer_nil = { michael@0: HB_OBJECT_HEADER_STATIC, michael@0: michael@0: const_cast (&_hb_unicode_funcs_nil), michael@0: HB_SEGMENT_PROPERTIES_DEFAULT, michael@0: HB_BUFFER_FLAG_DEFAULT, michael@0: michael@0: HB_BUFFER_CONTENT_TYPE_INVALID, michael@0: true, /* in_error */ michael@0: true, /* have_output */ michael@0: true /* have_positions */ michael@0: michael@0: /* Zero is good enough for everything else. */ michael@0: }; michael@0: michael@0: return const_cast (&_hb_buffer_nil); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_reference: (skip) michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Return value: (transfer full): michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_buffer_t * michael@0: hb_buffer_reference (hb_buffer_t *buffer) michael@0: { michael@0: return hb_object_reference (buffer); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_destroy: (skip) michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_destroy (hb_buffer_t *buffer) michael@0: { michael@0: if (!hb_object_destroy (buffer)) return; michael@0: michael@0: hb_unicode_funcs_destroy (buffer->unicode); michael@0: michael@0: free (buffer->info); michael@0: free (buffer->pos); michael@0: michael@0: free (buffer); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_set_user_data: (skip) michael@0: * @buffer: a buffer. michael@0: * @key: michael@0: * @data: michael@0: * @destroy: michael@0: * @replace: michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_bool_t michael@0: hb_buffer_set_user_data (hb_buffer_t *buffer, michael@0: hb_user_data_key_t *key, michael@0: void * data, michael@0: hb_destroy_func_t destroy, michael@0: hb_bool_t replace) michael@0: { michael@0: return hb_object_set_user_data (buffer, key, data, destroy, replace); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_user_data: (skip) michael@0: * @buffer: a buffer. michael@0: * @key: michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void * michael@0: hb_buffer_get_user_data (hb_buffer_t *buffer, michael@0: hb_user_data_key_t *key) michael@0: { michael@0: return hb_object_get_user_data (buffer, key); michael@0: } michael@0: michael@0: michael@0: /** michael@0: * hb_buffer_set_content_type: michael@0: * @buffer: a buffer. michael@0: * @content_type: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_set_content_type (hb_buffer_t *buffer, michael@0: hb_buffer_content_type_t content_type) michael@0: { michael@0: buffer->content_type = content_type; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_content_type: michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_buffer_content_type_t michael@0: hb_buffer_get_content_type (hb_buffer_t *buffer) michael@0: { michael@0: return buffer->content_type; michael@0: } michael@0: michael@0: michael@0: /** michael@0: * hb_buffer_set_unicode_funcs: michael@0: * @buffer: a buffer. michael@0: * @unicode_funcs: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_set_unicode_funcs (hb_buffer_t *buffer, michael@0: hb_unicode_funcs_t *unicode_funcs) michael@0: { michael@0: if (unlikely (hb_object_is_inert (buffer))) michael@0: return; michael@0: michael@0: if (!unicode_funcs) michael@0: unicode_funcs = hb_unicode_funcs_get_default (); michael@0: michael@0: michael@0: hb_unicode_funcs_reference (unicode_funcs); michael@0: hb_unicode_funcs_destroy (buffer->unicode); michael@0: buffer->unicode = unicode_funcs; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_unicode_funcs: michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_unicode_funcs_t * michael@0: hb_buffer_get_unicode_funcs (hb_buffer_t *buffer) michael@0: { michael@0: return buffer->unicode; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_set_direction: michael@0: * @buffer: a buffer. michael@0: * @direction: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_set_direction (hb_buffer_t *buffer, michael@0: hb_direction_t direction) michael@0: michael@0: { michael@0: if (unlikely (hb_object_is_inert (buffer))) michael@0: return; michael@0: michael@0: buffer->props.direction = direction; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_direction: michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_direction_t michael@0: hb_buffer_get_direction (hb_buffer_t *buffer) michael@0: { michael@0: return buffer->props.direction; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_set_script: michael@0: * @buffer: a buffer. michael@0: * @script: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_set_script (hb_buffer_t *buffer, michael@0: hb_script_t script) michael@0: { michael@0: if (unlikely (hb_object_is_inert (buffer))) michael@0: return; michael@0: michael@0: buffer->props.script = script; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_script: michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_script_t michael@0: hb_buffer_get_script (hb_buffer_t *buffer) michael@0: { michael@0: return buffer->props.script; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_set_language: michael@0: * @buffer: a buffer. michael@0: * @language: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_set_language (hb_buffer_t *buffer, michael@0: hb_language_t language) michael@0: { michael@0: if (unlikely (hb_object_is_inert (buffer))) michael@0: return; michael@0: michael@0: buffer->props.language = language; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_language: michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_language_t michael@0: hb_buffer_get_language (hb_buffer_t *buffer) michael@0: { michael@0: return buffer->props.language; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_set_segment_properties: michael@0: * @buffer: a buffer. michael@0: * @props: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_set_segment_properties (hb_buffer_t *buffer, michael@0: const hb_segment_properties_t *props) michael@0: { michael@0: if (unlikely (hb_object_is_inert (buffer))) michael@0: return; michael@0: michael@0: buffer->props = *props; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_segment_properties: michael@0: * @buffer: a buffer. michael@0: * @props: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_get_segment_properties (hb_buffer_t *buffer, michael@0: hb_segment_properties_t *props) michael@0: { michael@0: *props = buffer->props; michael@0: } michael@0: michael@0: michael@0: /** michael@0: * hb_buffer_set_flags: michael@0: * @buffer: a buffer. michael@0: * @flags: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_set_flags (hb_buffer_t *buffer, michael@0: hb_buffer_flags_t flags) michael@0: { michael@0: if (unlikely (hb_object_is_inert (buffer))) michael@0: return; michael@0: michael@0: buffer->flags = flags; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_flags: michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_buffer_flags_t michael@0: hb_buffer_get_flags (hb_buffer_t *buffer) michael@0: { michael@0: return buffer->flags; michael@0: } michael@0: michael@0: michael@0: /** michael@0: * hb_buffer_reset: michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_reset (hb_buffer_t *buffer) michael@0: { michael@0: buffer->reset (); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_clear_contents: michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_clear_contents (hb_buffer_t *buffer) michael@0: { michael@0: buffer->clear (); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_pre_allocate: michael@0: * @buffer: a buffer. michael@0: * @size: michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_bool_t michael@0: hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size) michael@0: { michael@0: return buffer->ensure (size); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_allocation_successful: michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_bool_t michael@0: hb_buffer_allocation_successful (hb_buffer_t *buffer) michael@0: { michael@0: return !buffer->in_error; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_add: michael@0: * @buffer: a buffer. michael@0: * @codepoint: michael@0: * @cluster: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_add (hb_buffer_t *buffer, michael@0: hb_codepoint_t codepoint, michael@0: unsigned int cluster) michael@0: { michael@0: buffer->add (codepoint, cluster); michael@0: buffer->clear_context (1); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_set_length: michael@0: * @buffer: a buffer. michael@0: * @length: michael@0: * michael@0: * michael@0: * michael@0: * Return value: michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_bool_t michael@0: hb_buffer_set_length (hb_buffer_t *buffer, michael@0: unsigned int length) michael@0: { michael@0: if (unlikely (hb_object_is_inert (buffer))) michael@0: return length == 0; michael@0: michael@0: if (!buffer->ensure (length)) michael@0: return false; michael@0: michael@0: /* Wipe the new space */ michael@0: if (length > buffer->len) { michael@0: memset (buffer->info + buffer->len, 0, sizeof (buffer->info[0]) * (length - buffer->len)); michael@0: if (buffer->have_positions) michael@0: memset (buffer->pos + buffer->len, 0, sizeof (buffer->pos[0]) * (length - buffer->len)); michael@0: } michael@0: michael@0: buffer->len = length; michael@0: michael@0: if (!length) michael@0: { michael@0: buffer->content_type = HB_BUFFER_CONTENT_TYPE_INVALID; michael@0: buffer->clear_context (0); michael@0: } michael@0: buffer->clear_context (1); michael@0: michael@0: return true; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_length: michael@0: * @buffer: a buffer. michael@0: * michael@0: * Returns the number of items in the buffer. michael@0: * michael@0: * Return value: buffer length. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: unsigned int michael@0: hb_buffer_get_length (hb_buffer_t *buffer) michael@0: { michael@0: return buffer->len; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_glyph_infos: michael@0: * @buffer: a buffer. michael@0: * @length: (out): output array length. michael@0: * michael@0: * Returns buffer glyph information array. Returned pointer michael@0: * is valid as long as buffer contents are not modified. michael@0: * michael@0: * Return value: (transfer none) (array length=length): buffer glyph information array. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_glyph_info_t * michael@0: hb_buffer_get_glyph_infos (hb_buffer_t *buffer, michael@0: unsigned int *length) michael@0: { michael@0: if (length) michael@0: *length = buffer->len; michael@0: michael@0: return (hb_glyph_info_t *) buffer->info; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_get_glyph_positions: michael@0: * @buffer: a buffer. michael@0: * @length: (out): output length. michael@0: * michael@0: * Returns buffer glyph position array. Returned pointer michael@0: * is valid as long as buffer contents are not modified. michael@0: * michael@0: * Return value: (transfer none) (array length=length): buffer glyph position array. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: hb_glyph_position_t * michael@0: hb_buffer_get_glyph_positions (hb_buffer_t *buffer, michael@0: unsigned int *length) michael@0: { michael@0: if (!buffer->have_positions) michael@0: buffer->clear_positions (); michael@0: michael@0: if (length) michael@0: *length = buffer->len; michael@0: michael@0: return (hb_glyph_position_t *) buffer->pos; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_reverse: michael@0: * @buffer: a buffer. michael@0: * michael@0: * Reverses buffer contents. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_reverse (hb_buffer_t *buffer) michael@0: { michael@0: buffer->reverse (); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_reverse_clusters: michael@0: * @buffer: a buffer. michael@0: * michael@0: * Reverses buffer clusters. That is, the buffer contents are michael@0: * reversed, then each cluster (consecutive items having the michael@0: * same cluster number) are reversed again. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_reverse_clusters (hb_buffer_t *buffer) michael@0: { michael@0: buffer->reverse_clusters (); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_guess_segment_properties: michael@0: * @buffer: a buffer. michael@0: * michael@0: * Sets unset buffer segment properties based on buffer Unicode michael@0: * contents. If buffer is not empty, it must have content type michael@0: * %HB_BUFFER_CONTENT_TYPE_UNICODE. michael@0: * michael@0: * If buffer script is not set (ie. is %HB_SCRIPT_INVALID), it michael@0: * will be set to the Unicode script of the first character in michael@0: * the buffer that has a script other than %HB_SCRIPT_COMMON, michael@0: * %HB_SCRIPT_INHERITED, and %HB_SCRIPT_UNKNOWN. michael@0: * michael@0: * Next, if buffer direction is not set (ie. is %HB_DIRECTION_INVALID), michael@0: * it will be set to the natural horizontal direction of the michael@0: * buffer script as returned by hb_script_get_horizontal_direction(). michael@0: * michael@0: * Finally, if buffer language is not set (ie. is %HB_LANGUAGE_INVALID), michael@0: * it will be set to the process's default language as returned by michael@0: * hb_language_get_default(). This may change in the future by michael@0: * taking buffer script into consideration when choosing a language. michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_guess_segment_properties (hb_buffer_t *buffer) michael@0: { michael@0: buffer->guess_segment_properties (); michael@0: } michael@0: michael@0: template michael@0: static inline void michael@0: hb_buffer_add_utf (hb_buffer_t *buffer, michael@0: const T *text, michael@0: int text_length, michael@0: unsigned int item_offset, michael@0: int item_length) michael@0: { michael@0: assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE || michael@0: (!buffer->len && buffer->content_type == HB_BUFFER_CONTENT_TYPE_INVALID)); michael@0: michael@0: if (unlikely (hb_object_is_inert (buffer))) michael@0: return; michael@0: michael@0: if (text_length == -1) michael@0: text_length = hb_utf_strlen (text); michael@0: michael@0: if (item_length == -1) michael@0: item_length = text_length - item_offset; michael@0: michael@0: buffer->ensure (buffer->len + item_length * sizeof (T) / 4); michael@0: michael@0: /* If buffer is empty and pre-context provided, install it. michael@0: * This check is written this way, to make sure people can michael@0: * provide pre-context in one add_utf() call, then provide michael@0: * text in a follow-up call. See: michael@0: * michael@0: * https://bugzilla.mozilla.org/show_bug.cgi?id=801410#c13 michael@0: */ michael@0: if (!buffer->len && item_offset > 0) michael@0: { michael@0: /* Add pre-context */ michael@0: buffer->clear_context (0); michael@0: const T *prev = text + item_offset; michael@0: const T *start = text; michael@0: while (start < prev && buffer->context_len[0] < buffer->CONTEXT_LENGTH) michael@0: { michael@0: hb_codepoint_t u; michael@0: prev = hb_utf_prev (prev, start, &u); michael@0: buffer->context[0][buffer->context_len[0]++] = u; michael@0: } michael@0: } michael@0: michael@0: const T *next = text + item_offset; michael@0: const T *end = next + item_length; michael@0: while (next < end) michael@0: { michael@0: hb_codepoint_t u; michael@0: const T *old_next = next; michael@0: next = hb_utf_next (next, end, &u); michael@0: buffer->add (u, old_next - (const T *) text); michael@0: } michael@0: michael@0: /* Add post-context */ michael@0: buffer->clear_context (1); michael@0: end = text + text_length; michael@0: while (next < end && buffer->context_len[1] < buffer->CONTEXT_LENGTH) michael@0: { michael@0: hb_codepoint_t u; michael@0: next = hb_utf_next (next, end, &u); michael@0: buffer->context[1][buffer->context_len[1]++] = u; michael@0: } michael@0: michael@0: buffer->content_type = HB_BUFFER_CONTENT_TYPE_UNICODE; michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_add_utf8: michael@0: * @buffer: a buffer. michael@0: * @text: (array length=text_length): michael@0: * @text_length: michael@0: * @item_offset: michael@0: * @item_length: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_add_utf8 (hb_buffer_t *buffer, michael@0: const char *text, michael@0: int text_length, michael@0: unsigned int item_offset, michael@0: int item_length) michael@0: { michael@0: hb_buffer_add_utf (buffer, (const uint8_t *) text, text_length, item_offset, item_length); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_add_utf16: michael@0: * @buffer: a buffer. michael@0: * @text: (array length=text_length): michael@0: * @text_length: michael@0: * @item_offset: michael@0: * @item_length: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_add_utf16 (hb_buffer_t *buffer, michael@0: const uint16_t *text, michael@0: int text_length, michael@0: unsigned int item_offset, michael@0: int item_length) michael@0: { michael@0: hb_buffer_add_utf (buffer, text, text_length, item_offset, item_length); michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_add_utf32: michael@0: * @buffer: a buffer. michael@0: * @text: (array length=text_length): michael@0: * @text_length: michael@0: * @item_offset: michael@0: * @item_length: michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_add_utf32 (hb_buffer_t *buffer, michael@0: const uint32_t *text, michael@0: int text_length, michael@0: unsigned int item_offset, michael@0: int item_length) michael@0: { michael@0: hb_buffer_add_utf (buffer, text, text_length, item_offset, item_length); michael@0: } michael@0: michael@0: michael@0: static int michael@0: compare_info_codepoint (const hb_glyph_info_t *pa, michael@0: const hb_glyph_info_t *pb) michael@0: { michael@0: return (int) pb->codepoint - (int) pa->codepoint; michael@0: } michael@0: michael@0: static inline void michael@0: normalize_glyphs_cluster (hb_buffer_t *buffer, michael@0: unsigned int start, michael@0: unsigned int end, michael@0: bool backward) michael@0: { michael@0: hb_glyph_position_t *pos = buffer->pos; michael@0: michael@0: /* Total cluster advance */ michael@0: hb_position_t total_x_advance = 0, total_y_advance = 0; michael@0: for (unsigned int i = start; i < end; i++) michael@0: { michael@0: total_x_advance += pos[i].x_advance; michael@0: total_y_advance += pos[i].y_advance; michael@0: } michael@0: michael@0: hb_position_t x_advance = 0, y_advance = 0; michael@0: for (unsigned int i = start; i < end; i++) michael@0: { michael@0: pos[i].x_offset += x_advance; michael@0: pos[i].y_offset += y_advance; michael@0: michael@0: x_advance += pos[i].x_advance; michael@0: y_advance += pos[i].y_advance; michael@0: michael@0: pos[i].x_advance = 0; michael@0: pos[i].y_advance = 0; michael@0: } michael@0: michael@0: if (backward) michael@0: { michael@0: /* Transfer all cluster advance to the last glyph. */ michael@0: pos[end - 1].x_advance = total_x_advance; michael@0: pos[end - 1].y_advance = total_y_advance; michael@0: michael@0: hb_bubble_sort (buffer->info + start, end - start - 1, compare_info_codepoint, buffer->pos + start); michael@0: } else { michael@0: /* Transfer all cluster advance to the first glyph. */ michael@0: pos[start].x_advance += total_x_advance; michael@0: pos[start].y_advance += total_y_advance; michael@0: for (unsigned int i = start + 1; i < end; i++) { michael@0: pos[i].x_offset -= total_x_advance; michael@0: pos[i].y_offset -= total_y_advance; michael@0: } michael@0: hb_bubble_sort (buffer->info + start + 1, end - start - 1, compare_info_codepoint, buffer->pos + start + 1); michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * hb_buffer_normalize_glyphs: michael@0: * @buffer: a buffer. michael@0: * michael@0: * michael@0: * michael@0: * Since: 1.0 michael@0: **/ michael@0: void michael@0: hb_buffer_normalize_glyphs (hb_buffer_t *buffer) michael@0: { michael@0: assert (buffer->have_positions); michael@0: assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_GLYPHS); michael@0: michael@0: bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction); michael@0: michael@0: unsigned int count = buffer->len; michael@0: if (unlikely (!count)) return; michael@0: hb_glyph_info_t *info = buffer->info; michael@0: michael@0: unsigned int start = 0; michael@0: unsigned int end; michael@0: for (end = start + 1; end < count; end++) michael@0: if (info[start].cluster != info[end].cluster) { michael@0: normalize_glyphs_cluster (buffer, start, end, backward); michael@0: start = end; michael@0: } michael@0: normalize_glyphs_cluster (buffer, start, end, backward); michael@0: }