[cairo] Rounding bug in cairo_ft_font.c

Owen Taylor otaylor at redhat.com
Sat Jan 8 19:49:03 PST 2005


On Sat, 2005-01-08 at 17:15 -0800, Keith Packard wrote:
> Around 19 o'clock on Jan 8, Owen Taylor wrote:
> 
> > Spent time today getting basic Cairo/Pango integration working, and I
> > noticed that rotated text was falling off the baseline for longer
> > lines. The problem turned out to be accumulation of rounding error
> > in cairo_xlib_surface.c. Attached patch seems to fix.
> 
> This is a minor part of a larger patch that I have here which tries to
> resolve the metrics issue of transformed fonts.  I'm still not happy with
> the result.  I think PostScript's answer might be a better long-term plan.
> In that world, metrics are always returned in 'font space', that pre-scaled
> world before the affine font and ctm transforms are applied.  

Postscript can get away with device independent metrics because it's
only targeting the world of high resolution. And the very nature of
Postscript is that you've done your layout before generating the 
postscript file. I think we need metrics that take hinting into account.

But even given device-adjustment, the font space convention doesn't
sound very convenient. If I'm trying to align some text, I want to
know how big it is in user space.

The Pango convention is user space with device adjustment; of course, 
in Pango, you are frequently getting metrics of mixtures of different
fonts in different sizes, so font space isn't even meaningful.

> As FreeType applies only a scale factor to hinting computations, it's
> actually pretty easy to get back to 'font space' from FreeType pixel space.
> Whether that's useful is a different question -- right now, my patch 
> actually scales but doesn't otherwise transform the metrics to user space, 
> so "normal" text "just works", although any non-scaling transforms 
> aren't reflected in the reported metrics.

Presumably, by far the most common case of non-scaling font transforms
is artificial oblique. Especially if we allow transforms out of
fonts.conf, I  don't see how we can get away without not adjusting the
metrics.

(Transformations in fonts.conf have never really worked very
well in Pango, so I haven't worked out how to implement it. 
And font transformations not in fonts.conf aren't exposed in the 
Pango API. But I think there is a reasonably obvious interpretation 
for shears.)

> I don't know if the rotated text alignment is entirely separate in my code 
> from the other issues.

The patch I posted seems to help Pango quite a bit. Of course, what I
have currently mostly reimplements metrics computations instead of using
the Cairo functions. So, it's just rendering that needed fixing.

Regards,
					Owen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050108/7b55a143/attachment.pgp


More information about the cairo mailing list