[pango] [HB] Round instead of trunc
- From: Behdad Esfahbod <behdad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] [HB] Round instead of trunc
- Date: Tue, 20 Apr 2010 18:49:02 +0000 (UTC)
commit 0d0cbf451613c301ae358cc4dbe54fb63ae5fc9e
Author: Behdad Esfahbod <behdad behdad org>
Date: Mon Apr 19 02:34:10 2010 -0400
[HB] Round instead of trunc
pango/opentype/hb-ot-layout-gpos-private.hh | 20 ++++++++++----------
pango/opentype/hb-private.h | 2 +-
2 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/pango/opentype/hb-ot-layout-gpos-private.hh b/pango/opentype/hb-ot-layout-gpos-private.hh
index e4ec9fc..dcbbf0f 100644
--- a/pango/opentype/hb-ot-layout-gpos-private.hh
+++ b/pango/opentype/hb-ot-layout-gpos-private.hh
@@ -104,13 +104,13 @@ struct ValueRecord {
y_scale = context->font->y_scale;
/* design units -> fractional pixel */
if (format & xPlacement)
- glyph_pos->x_pos += _hb_16dot16_mul_trunc (x_scale, *(SHORT*)values++);
+ glyph_pos->x_pos += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++);
if (format & yPlacement)
- glyph_pos->y_pos += _hb_16dot16_mul_trunc (y_scale, *(SHORT*)values++);
+ glyph_pos->y_pos += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++);
if (format & xAdvance)
- glyph_pos->x_advance += _hb_16dot16_mul_trunc (x_scale, *(SHORT*)values++);
+ 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++);
+ glyph_pos->y_advance += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++);
x_ppem = context->font->x_ppem;
y_ppem = context->font->y_ppem;
@@ -152,8 +152,8 @@ struct AnchorFormat1
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
{
- *x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate);
+ *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
+ *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
}
inline bool sanitize (SANITIZE_ARG_DEF) {
@@ -177,8 +177,8 @@ struct AnchorFormat2
hb_position_t *x, hb_position_t *y) const
{
/* TODO Contour */
- *x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate);
+ *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
+ *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
}
inline bool sanitize (SANITIZE_ARG_DEF) {
@@ -202,8 +202,8 @@ struct AnchorFormat3
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
{
- *x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate);
+ *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
+ *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
/* pixel -> fractional pixel */
if (context->font->x_ppem)
diff --git a/pango/opentype/hb-private.h b/pango/opentype/hb-private.h
index b17b24a..92e514f 100644
--- a/pango/opentype/hb-private.h
+++ b/pango/opentype/hb-private.h
@@ -207,7 +207,7 @@ _hb_popcount32 (uint32_t mask)
/* 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"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]