[cairo] Custom UserFont sizing questions

Behdad Esfahbod behdad at behdad.org
Thu Dec 11 15:21:27 PST 2008

Ian Britten wrote:
> Behdad Esfahbod 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.
>>> However, I now need to render my face using raw FT calls.
>> Why exactly?
> Ya, I figured I probably should have explained that, but the message
> was getting pretty long...  :P
> It came down to cap-styles.  I need to be able dynamically specify
> whether the strokes are round or square for each font, and that is
> not possible using my 'double-the-stroke-path-to-make-it-closed'
> trick, since the ends actually become interior points of the path,
> whose appearance is controlled by the join style (Always round),
> not the cap style.

You don't need the 'double-the-stroke-path-to-make-it-closed' anymore.
Toss it out.


> So, I'm back to an approach similar to our non-Cairo rendering,
> where I use open paths for the font strokes, and some custom
> callbacks to FT_Outline_Decompose() which handle dropping the last
> closing point (Which was automatically added by FT).  With this, I
> can correctly control the cap styles.

It makes no difference who you get your path from: FreeType or cairo.  Use
cairo_copy_path if needed.  You're making things too complex unnecessarily.

> I know it's not necessarily 'right', but I'm kindof between a rock
> and a hard place.  We're _legally_ required to produce correct
> output (Both according to international Standards, and customer
> contracts), and if I can't get everything drawn correctly with
> Cairo, then we may not be able to use it (I'm still in a research
> and evaluation phase).
> [ Obviously, I'm open to suggestions/alternatives, but based on
> discussions to date, this is the approach I've ended up with. ]
>>> 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);
>    [ snip ]
>>> Now,
>>> - Can someone explain the 2.0?  I don't understand it...
> Just a bit of an update:
> Last night I found a stray '10' in my code from some earlier flailing
> I was doing.  As such the '2.0' I mentioned seems to actually be
> closer to '24.0' or so (Still flailing).  Everything else is unchanged.
> I'm still looking into this, but am no closer to understanding where
> that fudge-factor is coming from.  I'm guessing it's my code somehow,
> but if anyone can describe/clarify what I _should_ be doing, or if
> anyone sees anything suspect, I'd certainly appreciate it!
> Many thanks for any help.
> Ian
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo

More information about the cairo mailing list