Apply rounding correctly when calculating glyph extents for CFF and CFF2; adjust expected test results

This commit is contained in:
justvanrossum 2021-02-17 10:21:58 +01:00 committed by Behdad Esfahbod
parent d01ebeae21
commit 79e4f436e7
3 changed files with 7 additions and 7 deletions

View File

@ -426,7 +426,7 @@ bool OT::cff1::accelerator_t::get_extents (hb_font_t *font, hb_codepoint_t glyph
else
{
extents->x_bearing = font->em_scalef_x (bounds.min.x.to_real ());
extents->width = font->em_scalef_x (bounds.max.x.to_real () - bounds.min.x.to_real ());
extents->width = font->em_scalef_x (bounds.max.x.to_real ()) - extents->x_bearing;
}
if (bounds.min.y >= bounds.max.y)
{
@ -436,7 +436,7 @@ bool OT::cff1::accelerator_t::get_extents (hb_font_t *font, hb_codepoint_t glyph
else
{
extents->y_bearing = font->em_scalef_y (bounds.max.y.to_real ());
extents->height = font->em_scalef_y (bounds.min.y.to_real () - bounds.max.y.to_real ());
extents->height = font->em_scalef_y (bounds.min.y.to_real ()) - extents->y_bearing;
}
return true;

View File

@ -127,7 +127,7 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
else
{
extents->x_bearing = font->em_scalef_x (param.min_x.to_real ());
extents->width = font->em_scalef_x (param.max_x.to_real () - param.min_x.to_real ());
extents->width = font->em_scalef_x (param.max_x.to_real ()) - extents->x_bearing;
}
if (param.min_y >= param.max_y)
{
@ -137,7 +137,7 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
else
{
extents->y_bearing = font->em_scalef_y (param.max_y.to_real ());
extents->height = font->em_scalef_y (param.min_y.to_real () - param.max_y.to_real ());
extents->height = font->em_scalef_y (param.min_y.to_real ()) - extents->y_bearing;
}
return true;

View File

@ -170,7 +170,7 @@ test_extents_cff2_vsindex (void)
g_assert_cmpint (extents.x_bearing, ==, 12);
g_assert_cmpint (extents.y_bearing, ==, 655);
g_assert_cmpint (extents.width, ==, 652);
g_assert_cmpint (extents.width, ==, 651);
g_assert_cmpint (extents.height, ==, -655);
result = hb_font_get_glyph_extents (font, 2, &extents);
@ -178,7 +178,7 @@ test_extents_cff2_vsindex (void)
g_assert_cmpint (extents.x_bearing, ==, 8);
g_assert_cmpint (extents.y_bearing, ==, 669);
g_assert_cmpint (extents.width, ==, 649);
g_assert_cmpint (extents.width, ==, 648);
g_assert_cmpint (extents.height, ==, -669);
hb_font_destroy (font);
@ -201,7 +201,7 @@ test_extents_cff2_vsindex_named_instance (void)
g_assert_cmpint (extents.x_bearing, ==, 13);
g_assert_cmpint (extents.y_bearing, ==, 652);
g_assert_cmpint (extents.width, ==, 653);
g_assert_cmpint (extents.width, ==, 652);
g_assert_cmpint (extents.height, ==, -652);
result = hb_font_get_glyph_extents (font, 2, &extents);