[cairo] Bug in PDF output with independent path/pen transformations

Behdad Esfahbod behdad at behdad.org
Tue Oct 30 18:58:03 PDT 2007


On Tue, 2007-10-30 at 20:32 -0400, Carl Worth wrote:
> 
> Adrian, care to work some magic to diagnose this one? 

I did.  The bug is in how we print doubles out.  We use %f, because
scientific syntax is not ok in the output.  But then %f is not flexible
enough and is producing 0.000001 when it should be doing
0.000000707106781 or something more like that.  I really wish %g could
be used.  Anyway, I'll cook a patch that should also optimize the way we
write out numbers a bit.

In the mean time, this works:

diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index 5bce0e3..0e3720e 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -236,7 +236,7 @@ _cairo_dtostr (char *buffer, size_t size, double d)
     if (d == 0.0)
        d = 0.0;
 
-    snprintf (buffer, size, "%f", d);
+    snprintf (buffer, size, "%20.15f", d);
 
     locale_data = localeconv ();
     decimal_point = locale_data->decimal_point;


-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list