diff --git a/src/OT/glyf/glyf.hh b/src/OT/glyf/glyf.hh index e6e985c38..e0c92f0c9 100644 --- a/src/OT/glyf/glyf.hh +++ b/src/OT/glyf/glyf.hh @@ -247,19 +247,14 @@ struct glyf_accelerator_t extents->y_bearing = 0; return; } - if (scaled) - { - extents->x_bearing = font->em_scalef_x (min_x); - extents->width = font->em_scalef_x (max_x) - extents->x_bearing; - extents->y_bearing = font->em_scalef_y (max_y); - extents->height = font->em_scalef_y (min_y) - extents->y_bearing; - } - else { extents->x_bearing = roundf (min_x); extents->width = roundf (max_x - extents->x_bearing); extents->y_bearing = roundf (max_y); extents->height = roundf (min_y - extents->y_bearing); + + if (scaled) + font->scale_glyph_extents (extents); } } diff --git a/src/hb-font.hh b/src/hb-font.hh index 6942d99c7..4e4a98766 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -179,6 +179,14 @@ struct hb_font_t *y = parent_scale_y_position (*y); } + void scale_glyph_extents (hb_glyph_extents_t *extents) + { + extents->x_bearing = em_scale_x (extents->x_bearing); + extents->y_bearing = em_scale_x (extents->y_bearing); + extents->width = em_scale_x (extents->width); + extents->height = em_scale_x (extents->height); + } + /* Public getters */ diff --git a/src/hb-ot-cff1-table.cc b/src/hb-ot-cff1-table.cc index bd9fe5d6d..49c330f09 100644 --- a/src/hb-ot-cff1-table.cc +++ b/src/hb-ot-cff1-table.cc @@ -422,8 +422,8 @@ 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->x_bearing = bounds.min.x.to_int (); + extents->width = bounds.max.x.to_int () - extents->x_bearing; } if (bounds.min.y >= bounds.max.y) { @@ -432,10 +432,12 @@ 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 ()) - extents->y_bearing; + extents->y_bearing = bounds.max.y.to_int (); + extents->height = bounds.min.y.to_int () - extents->y_bearing; } + font->scale_glyph_extents (extents); + return true; } diff --git a/src/hb-ot-cff2-table.cc b/src/hb-ot-cff2-table.cc index 50c76daf9..4d2dcd03f 100644 --- a/src/hb-ot-cff2-table.cc +++ b/src/hb-ot-cff2-table.cc @@ -124,8 +124,8 @@ 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->x_bearing = param.min_x.to_int (); + extents->width = param.max_x.to_int () - extents->x_bearing; } if (param.min_y >= param.max_y) { @@ -134,10 +134,12 @@ 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->y_bearing = param.max_y.to_int (); + extents->height = param.min_y.to_int () - extents->y_bearing; } + font->scale_glyph_extents (extents); + return true; } diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh index 3246894d3..4f8fa0123 100644 --- a/src/hb-ot-color-cbdt-table.hh +++ b/src/hb-ot-color-cbdt-table.hh @@ -82,10 +82,12 @@ struct SmallGlyphMetrics void get_extents (hb_font_t *font, hb_glyph_extents_t *extents) const { - extents->x_bearing = font->em_scale_x (bearingX); - extents->y_bearing = font->em_scale_y (bearingY); - extents->width = font->em_scale_x (width); - extents->height = font->em_scale_y (-static_cast(height)); + extents->x_bearing = bearingX; + extents->y_bearing = bearingY; + extents->width = width; + extents->height = -static_cast (height); + + font->scale_glyph_extents (extents); } HBUINT8 height; diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 70ed0a324..79b0b476c 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -1603,10 +1603,7 @@ struct COLR extents, instancer)) { - extents->x_bearing = font->em_scale_x (extents->x_bearing); - extents->y_bearing = font->em_scale_x (extents->y_bearing); - extents->width = font->em_scale_x (extents->width); - extents->height = font->em_scale_x (extents->height); + font->scale_glyph_extents (extents); return true; } diff --git a/src/hb-ot-color-sbix-table.hh b/src/hb-ot-color-sbix-table.hh index d0e2235fb..1d1d2e89d 100644 --- a/src/hb-ot-color-sbix-table.hh +++ b/src/hb-ot-color-sbix-table.hh @@ -313,19 +313,21 @@ struct sbix if (strike_ppem) { float scale = font->face->get_upem () / (float) strike_ppem; - extents->x_bearing = font->em_scalef_x (extents->x_bearing * scale); - extents->y_bearing = font->em_scalef_y (extents->y_bearing * scale); - extents->width = font->em_scalef_x (extents->width * scale); - extents->height = font->em_scalef_y (extents->height * scale); + extents->x_bearing = roundf (extents->x_bearing * scale); + extents->y_bearing = roundf (extents->y_bearing * scale); + extents->width = roundf (extents->width * scale); + extents->height = roundf (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); + extents->x_bearing = extents->x_bearing; + extents->y_bearing = extents->y_bearing; + extents->width = extents->width; + extents->height = extents->height; } + font->scale_glyph_extents (extents); + hb_blob_destroy (blob); return strike_ppem;