[cairo] Custom UserFont sizing questions [RESOLVED]

Ian Britten britten at caris.com
Fri Dec 12 06:13:10 PST 2008


Ian Britten wrote:

> I'm down inside the 'render' function for my custom UserFont, and
> am struggling with some size/scale issues.  I'm hoping someone can
> help explain what I'm seeing, and how to best address+simplify it.

Ok, I think I've found out what's going on - As I suspected, I was
the cause of my own problems...  :P

> Basically, my (cairomm) render code looks like:
>        FT_Set_Char_Size(face, 0, mmToPoint(115.238887) * 64,
>                         72, 72);
>        FT_Load_Glyph(face, glyph, load_flags);
>        inContext->save();
>        inContext->scale(0.001158/2.0, -0.001158/2.0);
>        FT_Outline_Decompose(face->glyph->outline, &funcs, &data);
>        inContext->restore()
>        inContext->stroke();

Changing the code to the simpler (and more intuitive):
        FT_Set_Char_Size(face, 0, 0, 72, 72);
        FT_Load_Glyph(face, glyph, load_flags);
        inContext->save();
        inContext->scale(1, -1);
        FT_Outline_Decompose(face->glyph->outline, &funcs, &data);
        inContext->restore()
        inContext->stroke();

[ Note the removal of all the size-specific numbers ]

wasn't initially working as I'd hoped/expected.  However, I finally
clued in that in my FT_Outline_Decompose moveto/lineto callbacks, I
needed to divide the 26.6 positions FT was giving me by 64 before
calling the corresponding move_to/line_to methods on my Cairo
Context.

Things are looking good now!  (Sorry for the noise...)
Ian



More information about the cairo mailing list