From 099472e08bf81d6dd8ca1647999592df6b7fdfb9 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 30 Aug 2017 16:45:06 -0700 Subject: [PATCH] hb_buffer_diff() tweak I like to have a mode where CONTAINS_NOTDEF and CONTAINS_DOTTEDCIRCLE are not returned. Abused a value of -1 for that. hb-shape now uses it. Fixes two of the six tests failing with --verify in test/shaping/run-tests.sh. --- src/hb-buffer.cc | 16 ++++++++-------- test/shaping/run-tests.sh | 4 ++-- util/options.hh | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index a45062aa..6b05d3a6 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -31,10 +31,6 @@ #include "hb-utf-private.hh" -#ifndef HB_DEBUG_BUFFER -#define HB_DEBUG_BUFFER (HB_DEBUG+0) -#endif - /** * SECTION: hb-buffer * @title: Buffers @@ -1885,6 +1881,9 @@ hb_buffer_t::sort (unsigned int start, unsigned int end, int(*compar)(const hb_g /** * hb_buffer_diff: * + * If dottedcircle_glyph is (hb_codepoint_t) -1 then %HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT + * and %HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT are never returned. This should be used by most + * callers if just comparing two buffers is needed. * * Since: 1.5.0 **/ @@ -1898,6 +1897,7 @@ hb_buffer_diff (hb_buffer_t *buffer, return HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH; hb_buffer_diff_flags_t result = HB_BUFFER_DIFF_FLAG_EQUAL; + bool contains = dottedcircle_glyph != (hb_codepoint_t) -1; unsigned int count = reference->len; @@ -1911,9 +1911,9 @@ hb_buffer_diff (hb_buffer_t *buffer, unsigned int i; for (i = 0; i < count; i++) { - if (info[i].codepoint == dottedcircle_glyph) + if (contains && info[i].codepoint == dottedcircle_glyph) result |= HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT; - else if (info[i].codepoint == 0) + if (contains && info[i].codepoint == 0) result |= HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT; } result |= HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH; @@ -1933,9 +1933,9 @@ hb_buffer_diff (hb_buffer_t *buffer, result |= HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH; if ((buf_info->mask & HB_GLYPH_FLAG_DEFINED) != (ref_info->mask & HB_GLYPH_FLAG_DEFINED)) result |= HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH; - if (ref_info->codepoint == dottedcircle_glyph) + if (contains && ref_info->codepoint == dottedcircle_glyph) result |= HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT; - else if (ref_info->codepoint == 0) + if (contains && ref_info->codepoint == 0) result |= HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT; buf_info++; ref_info++; diff --git a/test/shaping/run-tests.sh b/test/shaping/run-tests.sh index 9c496314..2b10e7c8 100755 --- a/test/shaping/run-tests.sh +++ b/test/shaping/run-tests.sh @@ -4,8 +4,8 @@ test "x$srcdir" = x && srcdir=. test "x$builddir" = x && builddir=. test "x$top_builddir" = x && top_builddir=../.. -#hb_shape="$top_builddir/util/hb-shape$EXEEXT --verify" -hb_shape="$top_builddir/util/hb-shape$EXEEXT" +hb_shape="$top_builddir/util/hb-shape$EXEEXT --verify" +#hb_shape="$top_builddir/util/hb-shape$EXEEXT" fails=0 diff --git a/util/options.hh b/util/options.hh index dbc4eaf9..9ad2225d 100644 --- a/util/options.hh +++ b/util/options.hh @@ -409,7 +409,7 @@ struct shape_options_t : option_group_t } bool ret = true; - hb_buffer_diff_flags_t diff = hb_buffer_diff (buffer, reconstruction, 0, 0); + hb_buffer_diff_flags_t diff = hb_buffer_diff (buffer, reconstruction, (hb_codepoint_t) -1, 0); if (diff) { if (error) -- GitLab