[cairo] Re: Cairo font size should be in units
cworth at east.isi.edu
Wed Sep 29 12:46:40 PDT 2004
On Wed, 29 Sep 2004 15:16:43 -0400, Owen Taylor wrote:
> On Tue, 2004-09-28 at 18:49 -0700, Bill Spitzak wrote:
> > On Tuesday 28 September 2004 06:25 pm, graydon hoare wrote:
> > > well, no, actually that's not true; cairo builds its CTM in terms of
> > > physics. when you start up a cairo program, you have no reason to believe
> > > that 1 user unit == 1 pixel. if you want that to be true, the first thing
> > > you need to do is ask about DPI and reverse the physics-based
> > > transformation. cairo's supposed to support writing
> > > (semi)resolution-independent clients, after all.
> I consider this a misfeature of Cairo:
I should point out that Graydon's description of the default CTM in
cairo is missing one important aspect. For display-devices[*], the
default CTM is computed by computing 1 unit == 1/96 inch, and then
rounding that to the nearest pixel size.
> - Pixels matter at screen resolutions
Absolutely. That's why we did the rounding described above. This way, by
default, integer user-space units map to integer numbers of device-space
> - People who work in pixel coordinates should have an easily accessible
> "base length" - something other than reverse-engineering the
> CTM of the default transformation.
What do mean by "base length" exactly? And how easily accessible do you
want it? Is a single call to cairo_transform_point good enough? Or do
you really want a literal value for your code?
I'm not sure exactly what you're getting at here, but I am prepared to
argue that the CTM as currently constructed helps to reduce the
situations in which this base length would be needed.
> So, say I have a 100dpi screen that I sit 3 feet from and like 12-pixel
> fonts and 1-pixel lines. You sit at the same distance from your 150dpi
> monitor. and like 18-pixel fonts. Do you want 1.5 pixel lines?
Perhaps not, but how about 2 pixel lines? And the cairo CTM certainly
isn't the only way to adjust the scale. I anticipate that programs will
continue to allow the user to choose a preferred font size.
Similary, the rounding in the default CTM is not the only way to get
pixel-aligned graphics. I anticipate that interesting toolkits and
applications will perform snapping as appropriate at many different
> Of course, for a printer, pixels aren't relevant.
[*] Agreed. It may be that the current code in cairo does the rounding
for all device types, but that's a bug. The rounding is a feature that
only helps where pixels are relevant and where the precise length isn't
More information about the cairo