提交 06558d2a 编写于 作者: B Behdad Esfahbod

Round instead of trunc

上级 0e206de9
...@@ -103,10 +103,10 @@ struct ValueRecord { ...@@ -103,10 +103,10 @@ struct ValueRecord {
x_scale = context->font->x_scale; x_scale = context->font->x_scale;
y_scale = context->font->y_scale; y_scale = context->font->y_scale;
/* design units -> fractional pixel */ /* design units -> fractional pixel */
if (format & xPlacement) glyph_pos->x_offset += _hb_16dot16_mul_trunc (x_scale, *(SHORT*)values++); if (format & xPlacement) glyph_pos->x_offset += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++);
if (format & yPlacement) glyph_pos->y_offset += _hb_16dot16_mul_trunc (y_scale, *(SHORT*)values++); if (format & yPlacement) glyph_pos->y_offset += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++);
if (format & xAdvance) glyph_pos->x_advance += _hb_16dot16_mul_trunc (x_scale, *(SHORT*)values++); if (format & xAdvance) glyph_pos->x_advance += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++);
if (format & yAdvance) glyph_pos->y_advance += _hb_16dot16_mul_trunc (y_scale, *(SHORT*)values++); if (format & yAdvance) glyph_pos->y_advance += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++);
x_ppem = context->font->x_ppem; x_ppem = context->font->x_ppem;
y_ppem = context->font->y_ppem; y_ppem = context->font->y_ppem;
...@@ -136,8 +136,8 @@ struct AnchorFormat1 ...@@ -136,8 +136,8 @@ struct AnchorFormat1
inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED, inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED,
hb_position_t *x, hb_position_t *y) const hb_position_t *x, hb_position_t *y) const
{ {
*x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate); *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
*y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate); *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
} }
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
...@@ -162,8 +162,8 @@ struct AnchorFormat2 ...@@ -162,8 +162,8 @@ struct AnchorFormat2
{ {
/* TODO Contour /* TODO Contour
* NOTE only adjust directions with nonzero ppem */ * NOTE only adjust directions with nonzero ppem */
*x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate); *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
*y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate); *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
} }
inline bool sanitize (SANITIZE_ARG_DEF) { inline bool sanitize (SANITIZE_ARG_DEF) {
...@@ -187,8 +187,8 @@ struct AnchorFormat3 ...@@ -187,8 +187,8 @@ struct AnchorFormat3
inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED, inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED,
hb_position_t *x, hb_position_t *y) const hb_position_t *x, hb_position_t *y) const
{ {
*x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate); *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
*y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate); *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
/* pixel -> fractional pixel */ /* pixel -> fractional pixel */
if (context->font->x_ppem) if (context->font->x_ppem)
......
...@@ -235,7 +235,7 @@ _hb_popcount32 (uint32_t mask) ...@@ -235,7 +235,7 @@ _hb_popcount32 (uint32_t mask)
/* Multiplies a 16dot16 value by another value, then truncates the result */ /* Multiplies a 16dot16 value by another value, then truncates the result */
#define _hb_16dot16_mul_trunc(A,B) ((int64_t) (A) * (B) / 0x10000) #define _hb_16dot16_mul_round(A,B) (((int64_t) (A) * (B) + 0x8000) / 0x10000)
#include "hb-object-private.h" #include "hb-object-private.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册