[color] Round extents when scaling

This commit is contained in:
Behdad Esfahbod 2018-10-28 22:45:53 -07:00
parent c929ccfcea
commit e998fb9fbf
2 changed files with 13 additions and 11 deletions

View File

@ -443,11 +443,13 @@ struct CBDT
} }
} }
/* Convert to the font units. */ /* Convert to font units. */
extents->x_bearing *= upem / (float) x_ppem; double x_scale = upem / (double) x_ppem;
extents->y_bearing *= upem / (float) y_ppem; double y_scale = upem / (double) y_ppem;
extents->width *= upem / (float) x_ppem; extents->x_bearing = round (extents->x_bearing * x_scale);
extents->height *= upem / (float) y_ppem; extents->y_bearing = round (extents->y_bearing * y_scale);
extents->width = round (extents->width * x_scale);
extents->height = round (extents->height * y_scale);
return true; return true;
} }

View File

@ -252,14 +252,14 @@ struct sbix
extents->width = png.IHDR.width; extents->width = png.IHDR.width;
extents->height = png.IHDR.height; extents->height = png.IHDR.height;
/* Convert to the font units. */ /* Convert to font units. */
if (strike_ppem) if (strike_ppem)
{ {
unsigned int upem = font->face->upem; double scale = font->face->upem / (double) strike_ppem;
extents->x_bearing *= upem / (float) strike_ppem; extents->x_bearing = round (extents->x_bearing * scale);
extents->y_bearing *= upem / (float) strike_ppem; extents->y_bearing = round (extents->y_bearing * scale);
extents->width *= upem / (float) strike_ppem; extents->width = round (extents->width * scale);
extents->height *= upem / (float) strike_ppem; extents->height = round (extents->height * scale);
} }
hb_blob_destroy (blob); hb_blob_destroy (blob);