diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh index 266270cc7..52fc1ee43 100644 --- a/src/hb-cff-interp-common.hh +++ b/src/hb-cff-interp-common.hh @@ -603,13 +603,13 @@ struct ArgStack : Stack inline void reverse_range (int i, int j) { - assert (i >= 0 && i < j); + assert (i >= 0 && i <= j); ARG tmp; while (i < j) { tmp = S::elements[i]; S::elements[i++] = S::elements[j]; - S::elements[j++] = tmp; + S::elements[j--] = tmp; } } diff --git a/test/api/fonts/cff1_legacyops.otf b/test/api/fonts/cff1_legacyops.otf new file mode 100644 index 000000000..ca50dab5a Binary files /dev/null and b/test/api/fonts/cff1_legacyops.otf differ diff --git a/test/api/test-ot-extents-cff.c b/test/api/test-ot-extents-cff.c index 607a4d303..244faa8f6 100644 --- a/test/api/test-ot-extents-cff.c +++ b/test/api/test-ot-extents-cff.c @@ -52,6 +52,28 @@ test_extents_cff1 (void) hb_font_destroy (font); } +static void +test_extents_cff1_legacyops (void) +{ + hb_face_t *face = hb_subset_test_open_font ("fonts/cff1_legacyops.otf"); + g_assert (face); + hb_font_t *font = hb_font_create (face); + hb_face_destroy (face); + g_assert (font); + hb_ot_font_set_funcs (font); + + hb_glyph_extents_t extents; + hb_bool_t result = hb_font_get_glyph_extents (font, 0, &extents); + g_assert (result); + + g_assert_cmpint (extents.x_bearing, ==, 20); + g_assert_cmpint (extents.y_bearing, ==, 800); + g_assert_cmpint (extents.width, ==, 160); + g_assert_cmpint (extents.height, ==, -810); + + hb_font_destroy (font); +} + static void test_extents_cff2 (void) { @@ -90,6 +112,7 @@ main (int argc, char **argv) hb_test_init (&argc, &argv); hb_test_add (test_extents_cff1); + hb_test_add (test_extents_cff1_legacyops); hb_test_add (test_extents_cff2); return hb_test_run ();