[cairo] Custom UserFont sizing questions

Ian Britten britten at caris.com
Wed Dec 10 06:40:47 PST 2008


Hi all,
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.

First though, if my render function simply draws my FT_Face using
glyph_path(), then everything is sized ok.  :)  As such, I'm
pretty sure I've got everything set up correctly in my higher-level
code regarding the font matrix, context transformation, etc.

However, I now need to render my face using raw FT calls.  I've
got the code laid out and running, but with some some issues
getting it sized/scaled correctly.  (NB: All the other calling
code is the same - It's just a different 'render' implementation)

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();

Now, as to the hard-coded numbers:
   - 115.23887 is the mm size my glyph should be rendered on the
     PDF output, from the higher-level calling code.
   - 0.001158 is the user size of my glyph (as set into the font
     matrix of the context).  Again, from the calling code.
   - The 2.0 is unknown, and may not be exactly correct.  I've
     just been flailing with it to get generally-correct results.

Now,
- Can someone explain the 2.0?  I don't understand it...
- I'm reasonably sure I can get those other numbers properly
   passed into my render function if necessary, but can someone
   suggest an approach that maybe doesn't require them?  The
   'render' docs talk about 'font space' and a size of 1.0, giving
   the impression that I maybe shouldn't need them, but I just
   can't seem to get it to work otherwise.  :(
   Also, since I didn't need these numbers when just using
   glyph_path(), I'm inclined to think I shouldn't need them
   now either.  I tried to trace though the glyph_path() code,
   but couldn't really find/understand what I needed...

I know I'm in a pretty specialized piece of Cairo, and I'm
doing something even more specialized, but I'm hoping someone
out there might be familiar with the relevant pieces and can
help explain+simplify!
If anything is unclear, or if you need/want more detail, just
ask...

Many thanks for any help or suggestions!
Ian



More information about the cairo mailing list