[cairo] UserFont size issue (ImageSurface)
britten at caris.com
Wed Feb 4 09:29:20 PST 2009
Ian Britten wrote:
> I'm investigating a sizing problem with my custom [FreeType based]
> UserFont that seems to only occur when using an ImageSurface, and was
> wondering if anyone knew of any apparent reason for the discrepancy
> I'm seeing?
[ snip ]
> The code for MyFont doesn't do anything other than implement the
> required 'render' functionality, which just draws the strokes of my
> glyph. I'm not doing anything with any of the 'extent' stuff, but
> maybe I should be?
Can anyone describe what is required to be done within the 'render'
callback of a UserFont, specifically regarding sizing? Currently,
I'm not doing anything for sizing - Just drawing stuff. The docs
allude to several possible things that could (should?) be done, but
it isn't really clear (to me) what is required, and what is optional.
In my testing, I gutted my current/custom 'render' implementation,
and simply did a show_glyphs() using the input Context and the input
glyph. Surprisingly, this seems to work [ Using the 'toy' font, I
guess? ]. The actual glyphs are wrong (Presumably the wrong glyph
mapping, but I'm not concerned about that), but they seemed to
be the correct size, both for PDF and PNG output.
Going back to my minimal 'render' implementation, if I simply do this:
inContext->show_glyphs(glyphs); // Draw 1 glyph at (0,0)
to use my FT_Face rather than the default face, then I get the
correct face, but I'm back to my size problem - It seems right for
PDF, but is too small for PNG.
As such, I'm getting the impression I need to do something more, but
I'm just not sure what.
- Do I do use the input scaled_font somehow? Currently I'm ignoring
- Do I modify the input text_extents somehow? The docs indicate the
defaults should usually be suitable.
- Do I change the matrix (Or the font_matrix?) on the input context?
The docs say it's already been set though, and things are in
Many thanks for any clarification/help!
More information about the cairo