[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.
This commit is contained in:
Robert O'Callahan 2007-04-06 00:00:33 +01:00 committed by Brian Ewins
parent 106f859045
commit d801aa59f8

View file

@ -1314,8 +1314,8 @@ _cairo_quartz_surface_show_glyphs (void *abstract_surface,
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 *abstract_surface,
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