[cairo] Userfont hinting

Behdad Esfahbod behdad at behdad.org
Mon May 5 18:53:33 PDT 2008


Before I dive into this, given that you have already updated my
user-font branch to master, mind sharing that tree?

Thanks,

behdad

On Mon, 2008-05-05 at 11:42 +0100, Peter Clifton wrote:
> On Mon, 2008-05-05 at 03:29 -0400, Behdad Esfahbod wrote:
> > On Sat, 2008-05-03 at 18:23 +0100, Peter Clifton wrote:
> > > 
> > >   x3 = 21.5;
> > >   y3 = 0;
> > >   cairo_device_to_user (cr, &x3, &y3);
> > >   metrics->x_advance = x3;
> > >   metrics->y_advance = y3;
> > 
> > This is very wrong and breaks badly for rotated text.  But anyway, you
> > *are* setting to a half integer.
> 
> Yes.. I did find it was broken for rotated text.. I guess I need to
> figure out the projected distance in the direction of the baseline and
> perpendicular to it?
> 
> > Lemme back up a bit.  Can you please succinctly summarize what you are
> > trying to achieve, and what doesn't work?
> 
> I'm trying to replace text drawing in gEDA/gschem with cairo (as part of
> a general attempt to replace the non anti-aliased GDK drawing). gschem
> previously drew its own fonts with little line segments, but with Cario
> this becomes too slow.
>  
> I started writing replacement, cairo based rendering code for gschem:
> 
> http://repo.or.cz/w/geda-gaf/pcjc2.git?a=shortlog;h=refs/heads/cairo_experiment
> 
> The userfont code is the last patch I have applied in my stgit series before pushing:
> 
> http://repo.or.cz/w/geda-gaf/pcjc2.git?a=commitdiff;h=46406c411b4016078c5cee89131a81a353dfeded
> 
> And the specific files:
> 
> http://repo.or.cz/w/geda-gaf/pcjc2.git?a=blob;f=gschem/src/gschem_cairo.c;h=f016b6e9a7f85809e51a16d07ea31e089ff69cb6
> http://repo.or.cz/w/geda-gaf/pcjc2.git?a=blob;f=gschem/src/o_text.c;h=5bbb9c639f47e85a72f6cf3ba3205b3c364ca897
> 
> (Yes, I realise the {x,y}_advance metrics will be wrong there too).
> 
> 
> 
> For the simple test-case I posted, there should be two lines of glyphs
> drawn. One shows sharp, and correctly pixel aligned. The second (where I
> requested a larger size), does not end up pixel aligned.
> 
> Does the test-case show this for you? (If not there could be some bug
> in the way I rebased the userfont branch on top of cairo's git HEAD.
> 
> 
> This kind of effect manifests in the gschem rendering code at at some
> zoom levels. The gschem code picks the text size it wants with
> cairo_set_font_size (), passing a desired height in user-space, which in
> this case is pixels. (SCREENabs converts mili-inches to pixels at the
> current zoom level).
> 
> 
> Thanks for looking - I'm guessing there is a good chance I've just
> misunderstood something about how to use the fonts, but if we look at
> the test case for a moment, why does the size requested with
> cairo_set_font_size () affect the pixel alignment in the way it seems
> to?
> 
> Best regards,
> 
-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list