[cairo-commit] src/cairo-quartz-surface.c

Brian Ewins brianewins at kemper.freedesktop.org
Thu Apr 5 16:06:27 PDT 2007


 src/cairo-quartz-surface.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

New commits:
diff-tree d801aa59f84d95568e36d02a0ecf3544b9914187 (from 106f8590457a7ebb5335d67f16277e8d5a6b04a8)
Author: Robert O'Callahan <roc at ocallahan.org>
Date:   Fri Apr 6 00:00:33 2007 +0100

    [quartz] fix floating point precision issue (#10531)
        
    This ensures that error due to double-to-float conversion
    does not accumulate; the position of any glyph will be off by
    at most one double-to-float conversion error.

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 2754666..5469e40 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -1314,8 +1314,8 @@ _cairo_quartz_surface_show_glyphs (void 
 	cg_advances = (CGSize*) malloc(sizeof(CGSize) * num_glyphs);
     }
 
-    double xprev = glyphs[0].x;
-    double yprev = glyphs[0].y;
+    float xprev = glyphs[0].x;
+    float yprev = glyphs[0].y;
 
     cg_glyphs[0] = glyphs[0].index;
     cg_advances[0].width = 0;
@@ -1323,10 +1323,12 @@ _cairo_quartz_surface_show_glyphs (void 
 
     for (i = 1; i < num_glyphs; i++) {
 	cg_glyphs[i] = glyphs[i].index;
-	cg_advances[i-1].width = glyphs[i].x - xprev;
-	cg_advances[i-1].height = glyphs[i].y - yprev;
-	xprev = glyphs[i].x;
-	yprev = glyphs[i].y;
+	float xf = glyphs[i].x;
+	float yf = glyphs[i].y;
+	cg_advances[i-1].width = xf - xprev;
+	cg_advances[i-1].height = yf - yprev;
+	xprev = xf;
+	yprev = yf;
     }
 
 #if 0


More information about the cairo-commit mailing list