diff --git a/src/OT/glyf/glyf.hh b/src/OT/glyf/glyf.hh index 75155b0ca..ce563977a 100644 --- a/src/OT/glyf/glyf.hh +++ b/src/OT/glyf/glyf.hh @@ -357,8 +357,8 @@ struct glyf_accelerator_t return; } { - double x_bearing = roundf (min_x); - double y_bearing = roundf (max_y); + double x_bearing = (double) roundf (min_x); + double y_bearing = (double) roundf (max_y); extents->x_bearing = hb_clamp_to (x_bearing); extents->width = hb_clamp_to ((double) roundf (max_x) - x_bearing); extents->y_bearing = hb_clamp_to (y_bearing); diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 319b65cc1..31361d8b3 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -958,6 +958,15 @@ hb_clamp_to (double v) (double) hb_int_max (T)); } +template +static HB_ALWAYS_INLINE T +hb_clamp_to (float v) +{ + /* Widen explicitly: float cannot represent all integer bounds exactly, + * so the clamp itself is done in double. */ + return hb_clamp_to ((double) v); +} + template static HB_ALWAYS_INLINE T hb_clamp_to (int64_t v)