[ot-metrics] Don't use mixed scaled and not scaled for generating extents

This commit is contained in:
Ebrahim Byagowi 2019-10-08 23:27:37 +03:30
parent b068e25f8f
commit dc45f22521
5 changed files with 17 additions and 10 deletions

View File

@ -326,7 +326,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 () - extents->x_bearing);
extents->width = font->em_scalef_x (bounds.max.x.to_real () - bounds.min.x.to_real ());
}
if (bounds.min.y >= bounds.max.y)
{
@ -336,7 +336,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_x (bounds.min.y.to_real () - extents->y_bearing);
extents->height = font->em_scalef_x (bounds.min.y.to_real () - bounds.max.y.to_real ());
}
return true;

View File

@ -126,7 +126,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 () - extents->x_bearing);
extents->width = font->em_scalef_x (param.max_x.to_real () - param.min_x.to_real ());
}
if (param.min_y >= param.max_y)
{
@ -136,7 +136,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 () - extents->y_bearing);
extents->height = font->em_scalef_y (param.min_y.to_real () - param.max_y.to_real ());
}
return true;

View File

@ -248,6 +248,13 @@ struct sbix
extents->width = font->em_scalef_x (extents->width * scale);
extents->height = font->em_scalef_y (extents->height * scale);
}
else
{
extents->x_bearing = font->em_scale_x (extents->x_bearing);
extents->y_bearing = font->em_scale_y (extents->y_bearing);
extents->width = font->em_scale_x (extents->width);
extents->height = font->em_scale_y (extents->height);
}
hb_blob_destroy (blob);

View File

@ -888,7 +888,7 @@ struct glyf
else
{
extents->x_bearing = font->em_scalef_x (bounds.min.x);
extents->width = font->em_scalef_x (bounds.max.x) - extents->x_bearing;
extents->width = font->em_scalef_x (bounds.max.x - bounds.min.x);
}
if (bounds.min.y > bounds.max.y)
{
@ -898,7 +898,7 @@ struct glyf
else
{
extents->y_bearing = font->em_scalef_y (bounds.max.y);
extents->height = font->em_scalef_y (bounds.min.y) - extents->y_bearing;
extents->height = font->em_scalef_y (bounds.min.y - bounds.max.y);
}
}
if (phantoms)
@ -970,7 +970,7 @@ struct glyf
extents->x_bearing = font->em_scale_x (face->table.hmtx->get_side_bearing (glyph));
extents->y_bearing = font->em_scale_y (hb_max (glyph_header.yMin, glyph_header.yMax));
extents->width = font->em_scale_x (hb_max (glyph_header.xMin, glyph_header.xMax) - hb_min (glyph_header.xMin, glyph_header.xMax));
extents->height = font->em_scale_y (hb_min (glyph_header.yMin, glyph_header.yMax) - extents->y_bearing);
extents->height = font->em_scale_y (hb_min (glyph_header.yMin, glyph_header.yMax) - hb_max (glyph_header.yMin, glyph_header.yMax));
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, ==, 651);
g_assert_cmpint (extents.width, ==, 652);
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, ==, 648);
g_assert_cmpint (extents.width, ==, 649);
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, ==, 652);
g_assert_cmpint (extents.width, ==, 653);
g_assert_cmpint (extents.height, ==, -652);
result = hb_font_get_glyph_extents (font, 2, &extents);