src/hb-coretext.cc | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
New commits: commit ac2085d4b391b0a72473ecac3dd6c22efe66833f Author: Jonathan Kew <[email protected]> Date: Thu Jul 26 15:58:45 2012 -0400 [CoreText] Ensure cluster indices in output buffer are non-decreasing. Does not provide Uniscribe-compatible results, but should at least avoid breaking hb-view due to out-of-order cluster values. For RTL runs, ensure cluster values are non-increasing (instead of non-decreasing). diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc index 65a1c73..c99ffc4 100644 --- a/src/hb-coretext.cc +++ b/src/hb-coretext.cc @@ -319,5 +319,42 @@ _hb_coretext_shape (hb_font_t *font, pos->y_offset = info->var2.u32; } + // Fix up clusters so that we never return out-of-order indices; + // if core text has reordered glyphs, we'll merge them to the + // beginning of the reordered cluster. + // This does *not* mean we'll form the same clusters as Uniscribe + // or the native OT backend, only that the cluster indices will be + // non-decreasing in the output buffer. + if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) { + unsigned int prev_cluster = 0; + for (unsigned int i = 0; i < count; i++) { + unsigned int curr_cluster = buffer->info[i].cluster; + if (curr_cluster < prev_cluster) { + for (unsigned int j = i; j > 0; j--) { + if (buffer->info[j - 1].cluster > curr_cluster) + buffer->info[j - 1].cluster = curr_cluster; + else + break; + } + } + prev_cluster = curr_cluster; + } + } else { + // For RTL runs, we make them non-increasing instead. + unsigned int prev_cluster = (unsigned int)-1; + for (unsigned int i = 0; i < count; i++) { + unsigned int curr_cluster = buffer->info[i].cluster; + if (curr_cluster > prev_cluster) { + for (unsigned int j = i; j > 0; j--) { + if (buffer->info[j - 1].cluster < curr_cluster) + buffer->info[j - 1].cluster = curr_cluster; + else + break; + } + } + prev_cluster = curr_cluster; + } + } + return true; } commit 441d3bb7de311d54b9f0a5210344f9a96e97e153 Author: Behdad Esfahbod <[email protected]> Date: Thu Jul 26 12:01:12 2012 -0400 Minor diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc index f49e76e..65a1c73 100644 --- a/src/hb-coretext.cc +++ b/src/hb-coretext.cc @@ -260,8 +260,8 @@ _hb_coretext_shape (hb_font_t *font, #define ALLOCATE_ARRAY(Type, name, len) \ Type *name = (Type *) scratch; \ - scratch += len * sizeof (name[0]); \ - scratch_size -= len * sizeof (name[0]); + scratch += (len) * sizeof ((name)[0]); \ + scratch_size -= (len) * sizeof ((name)[0]); const CGGlyph* glyphs = CTRunGetGlyphsPtr (run); if (!glyphs) { _______________________________________________ HarfBuzz mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/harfbuzz
