Aric Stewart : usp10: Correct rounding of negative offsets in GPOS.

Alexandre Julliard julliard at winehq.org
Wed Aug 15 14:08:34 CDT 2012


Module: wine
Branch: master
Commit: cd8c1b28ad32ec115a304377b277f96a0e5a671e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cd8c1b28ad32ec115a304377b277f96a0e5a671e

Author: Aric Stewart <aric at codeweavers.com>
Date:   Tue Aug 14 09:32:08 2012 -0500

usp10: Correct rounding of negative offsets in GPOS.

---

 dlls/usp10/opentype.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/dlls/usp10/opentype.c b/dlls/usp10/opentype.c
index a21e0f1..05ac53f 100644
--- a/dlls/usp10/opentype.c
+++ b/dlls/usp10/opentype.c
@@ -43,6 +43,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(uniscribe);
 #define GET_BE_DWORD(x) RtlUlongByteSwap(x)
 #endif
 
+#define round(x) (((x) < 0) ? (int)((x) - 0.5) : (int)((x) + 0.5))
+
 /* These are all structures needed for the cmap format 12 table */
 #define CMAP_TAG MS_MAKE_TAG('c', 'm', 'a', 'p')
 
@@ -1403,13 +1405,13 @@ static INT GPOS_apply_lookup(LPOUTLINETEXTMETRICW lpotm, LPLOGFONTW lplogfont, I
             if (adjust.x || adjust.y)
             {
                 GPOS_convert_design_units_to_device(lpotm, lplogfont, adjust.x, adjust.y, &devX, &devY);
-                pGoffset[glyph_index].du += (int)(devX+0.5);
-                pGoffset[glyph_index].dv += (int)(devY+0.5);
+                pGoffset[glyph_index].du += round(devX);
+                pGoffset[glyph_index].dv += round(devY);
             }
             if (advance.x || advance.y)
             {
                 GPOS_convert_design_units_to_device(lpotm, lplogfont, advance.x, advance.y, &devX, &devY);
-                piAdvance[glyph_index] += (int)(devX+0.5);
+                piAdvance[glyph_index] += round(devX);
                 if (advance.y)
                     FIXME("Unhandled adjustment to Y advancement\n");
             }
@@ -1424,24 +1426,24 @@ static INT GPOS_apply_lookup(LPOUTLINETEXTMETRICW lpotm, LPLOGFONTW lplogfont, I
             if (adjust[0].x || adjust[0].y)
             {
                 GPOS_convert_design_units_to_device(lpotm, lplogfont, adjust[0].x, adjust[0].y, &devX, &devY);
-                pGoffset[glyph_index].du += (int)(devX+0.5);
-                pGoffset[glyph_index].dv += (int)(devY+0.5);
+                pGoffset[glyph_index].du += round(devX);
+                pGoffset[glyph_index].dv += round(devY);
             }
             if (advance[0].x || advance[0].y)
             {
                 GPOS_convert_design_units_to_device(lpotm, lplogfont, advance[0].x, advance[0].y, &devX, &devY);
-                piAdvance[glyph_index] += (int)(devX+0.5);
+                piAdvance[glyph_index] += round(devX);
             }
             if (adjust[1].x || adjust[1].y)
             {
                 GPOS_convert_design_units_to_device(lpotm, lplogfont, adjust[1].x, adjust[1].y, &devX, &devY);
-                pGoffset[glyph_index + write_dir].du += (int)(devX+0.5);
-                pGoffset[glyph_index + write_dir].dv += (int)(devY+0.5);
+                pGoffset[glyph_index + write_dir].du += round(devX);
+                pGoffset[glyph_index + write_dir].dv += round(devY);
             }
             if (advance[1].x || advance[1].y)
             {
                 GPOS_convert_design_units_to_device(lpotm, lplogfont, advance[1].x, advance[1].y, &devX, &devY);
-                piAdvance[glyph_index + write_dir] += (int)(devX+0.5);
+                piAdvance[glyph_index + write_dir] += round(devX);
             }
             return index;
         }
@@ -1453,8 +1455,8 @@ static INT GPOS_apply_lookup(LPOUTLINETEXTMETRICW lpotm, LPLOGFONTW lplogfont, I
             if (desU.x || desU.y)
             {
                 GPOS_convert_design_units_to_device(lpotm, lplogfont, desU.x, desU.y, &devX, &devY);
-                pGoffset[glyph_index].du += ((int)(devX+0.5) - piAdvance[glyph_index-1]);
-                pGoffset[glyph_index].dv += (int)(devY+0.5);
+                pGoffset[glyph_index].du += (round(devX) - piAdvance[glyph_index-1]);
+                pGoffset[glyph_index].dv += round(devY);
             }
             break;
         }




More information about the wine-cvs mailing list