Bug 12031

Summary: Negated values in the matrices generated by the PostScript backend are badly rounded
Product: cairo Reporter: James Cloos <cloos>
Component: postscript backendAssignee: Carl Worth <cworth>
Status: RESOLVED NOTOURBUG QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium CC: ajohnson
Version: 1.5.1   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Fix negation rounding in generated PostScript.

Description James Cloos 2007-08-16 12:04:49 UTC
When cairo outputs PostScript it currently creates matrices which are
slightly off due to rounding during negation.

As an example, this was found in output from evince:

   /CairoFont-1-0 findfont
   [ 9.9585 0 0 -9.958399 0 0 ] makefont
   setfont

This patch moves the negation from the C into the PostScript, so the
above will become:

   /CairoFont-1-0 findfont
   [ 9.9585 0 0 -9.9585 0 0 ] makefont
   setfont

In PostScript, -0 is the same as 0, so (compliant) PostScript
interpreters will Do The Right Thing should cairo emit a -0.

I’ll attach a patch; it can also be pulled from:

git://people.freedesktop.org/~cloos/cairo.git


(Incidently, the value 9.9585 above comes from a system that believes there are 72.3 points per inch, as compared to the 72.27 ΤεΧ uses, or the 72.0 PostScript and PDF use.  I also saw an instance — though I can’t seem to find it — where an integer turned into a float value:  something like 9 and -8.9975 or so.)
Comment 1 James Cloos 2007-08-16 12:08:18 UTC
Created attachment 11154 [details] [review]
Fix negation rounding in generated PostScript.

Can also be pulled from:

git://people.freedesktop.org/~cloos/cairo.git
Comment 2 James Cloos 2007-08-16 21:52:38 UTC
I was looking into this a bit more while offline and noticed that the args are doubles.  Because ‖-foo‖ ≠ foo I presumed the args were fixed point, but I see from looking at the _cairo_matrix and _cairo_scaled_font structs that they are in fact doubles.

Since ‖-double‖ ≡ double, that means there is a rounding bug in whatever code is setting the matrix, since it is taking a single value and storing differently-rounded versions of it in scaled_font->scale.xx and scaled_font->scale.yy.

So, I'll delete the patch and will try to determine where the bad rounding occurs.
Comment 3 James Cloos 2007-08-16 21:53:44 UTC
Comment on attachment 11154 [details] [review]
Fix negation rounding in generated PostScript.

invalid patch, bug is elsewhere.
Comment 4 Adrian Johnson 2008-01-11 20:31:48 UTC
As was pointed out comment #2, doubles are used for matrices from the API through to the PostScript backend so the rounding is not caused by cairo.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.