[cairo] Re: Cairo font size should be in units
graydon hoare
graydon at redhat.com
Tue Sep 28 18:25:03 PDT 2004
On Tue, 28 Sep 2004 16:09:02 -0700, Bill Spitzak <spitzak at d2.com> wrote:
> If this was true then shapes and line thicknesses and dash lengths would also
> be specified in points. Obviously they are not, and nobody is suggesting they
> be.
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.
a cairo user unit is 1/96 of an inch. that's a unit not unlike a point. the
only real issue I'm discussing is whether we look at points or user units,
and since both are physical units, and both will be scaled by the CTM, really
the *only* difference implied by this distinction is:
whether, when you first start up cairo and are looking at an un-scaled
surface, you use "cairo_scale_font(ct, 10)" to get at the "10 point" font
program stored in your truetype font, or "cairo_scale_font(ct, 13.3333)"
that's it. in all other respects you're faced with the same set of issues: you
can't count on line height being a particular height without measuring; metrics
will always be returned to you in user units (because it's assuming you want to
do layout with the metrics); the font is still rendered and hinted in device
space, and is therefore subject to the DPI thereof (whether explicit or arrived
at by the CTM); the CTM still affects the unit chosen; there is really no other
difference.
> People "think in points" because of GUI's that present "points" and they have
> learned that "12" is "about the right size".
that's exactly the intuition I meant to capitalize on. cairo client authors
(such as fontconfig, pango, java2d, etc.) will be more likely to request fonts
-- not measure, not layout, not anything other than the initial ballpark
request -- in terms of points, not "points times 4/3".
-graydon
More information about the cairo
mailing list