提交 4b8de1ea 编写于 作者: B Behdad Esfahbod

Round, not truncate, when scaling values

Fixes https://github.com/behdad/harfbuzz/issues/255
上级 a93078a0
......@@ -505,7 +505,13 @@ struct hb_font_t {
}
private:
inline hb_position_t em_scale (int16_t v, int scale) { return (hb_position_t) (v * (int64_t) scale / face->get_upem ()); }
inline hb_position_t em_scale (int16_t v, int scale)
{
int upem = face->get_upem ();
int64_t scaled = v * (int64_t) scale;
scaled += scaled >= 0 ? upem/2 : -upem/2; /* Round. */
return (hb_position_t) (scaled / upem);
}
};
#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册