[cairo] Userfont hinting

Peter Clifton pcjc2 at cam.ac.uk
Sat May 3 09:04:54 PDT 2008


Hi,

Still playing with userfont, and recently discovered where I was having
problems with getting hinting to work. (Rounding my glyph drawing to
device coordinates).

I was indeed doing my drawing to the centre of device pixels, which
produced "mostly" the correct results, however I was still seeing bad
alignment at some zoom levels.

This turned out to be because I wasn't filling in the glyph metrics,
instead allowing the userfont backend to do this for me with its
analysis surface.

I suspect it was the caps on non-horizontal, non-vertical lines which
were messing up my rendering, as the extents including those would not
be pixel aligned. This would shift my y_bearing off the pixel grid, and
my horizontals would end up off-grid.

I'm sure I've seen my code produce a non aligned vertical strike
"I" (just the strike, no horizontals were drawn) at certain zoom levels,
but I can't figure out how the x-bearing was misaligned. Still.. seems
to be working now I'm explicitly setting the metrics myself.


Why can't the origin of the coordinate space we're drawing in be taken
to be on the baseline, and aligned in device space? I'm probably failing
to understand how the glyph coordinate spaces are related, but it seems
rather counter-intuitive that the analysis surface doesn't appear to do
the "right thing" given that my glyph rendering function explicitly sets
up an identity matrix and is careful to draw "on grid" in device space.


Just thought I'd write this note in case it helps anyone else
experimenting.


Best wishes,

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)



More information about the cairo mailing list