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.
This commit is contained in:
Behdad Esfahbod 2017-08-30 16:45:06 -07:00
parent e8b364b860
commit 099472e08b
3 changed files with 11 additions and 11 deletions

View File

@ -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++;

View File

@ -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

View File

@ -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)