[cairo] Reimplementing cairo-win32-font.c
Daniel K. O.
danielosmari at yahoo.com.br
Mon Aug 22 14:05:16 PDT 2005
Owen Taylor wrote:
>To do what you were describing would really require an entirely new
>backend - cairo-ft-font.c is heavily dependent on fontconfig while,
>on the other hand, cairo-win32-font.c is really built around getting
>metrics from Windows and having Windows do the rendering.
>You might be able to export some of the functionality from
>cairo-ft-font.c to avoid duplicating it in your new file - all of
>the rasterization code in _cairo_ft_unscaled_font_create_glyph()
>and it's sub-functions would be the same.
I currently hacked my way through it by just replacing the win32 backend
object with FreeType's backend when the Win32 backend isn't supported on
Of course, the cairo_win32_font_face_create_for_logfontw() had to be
reimplemented to create an intermediate FT_Face from a HFONT, then call
I forgot to mention it in the previous e-mail, but I'm really newbie in
text/font handling, so... hey, it's a bad approach, but it did work. :P
With my current impl^H^H^H^Hhack I can finally render text in a Win32 HDC.
>One problem with this approach is that you may have trouble getting
>the cairo-win32.h font API to work right:
>is supposed to allow the caller to use the native Win32 font
>metrics APIs and have that match the rendering.
Why is that? I mean... why would anyone use Cairo to handle the font
(that came from a LOGFONT in the first place), then call Win32 API
functions to display the text?
e.g. Shouldn't Pango be able to handle everything using just the Cairo API?
In my current "work-around" I only implemented
cairo_win32_font_face_create_for_logfontw() (and an "ascii" version
too... I don't think that many people install fonts with names in
"non-iso-8859" encodings); obviously the lack of the other win32
functions make Pango to not work properly.
>My thoughts for how to support Windows 9x in cairo-win32-font.c were
>considerably different. The basic strategy would be to:
> - Avoid the use of SetWorldTransform for fonts that are simply scaled
> or rotated, and thus can be handled by Windows 9x.
> - For the rare case of transformations that contain a shear, use
> GetGlyphOutline and have Cairo do the rasterization.
Thanks for the hint, I'll see if I can make some progress with this info. :)
Daniel K. O.
Yahoo! Acesso Grátis - Internet rápida e grátis.
Instale o discador agora! http://br.acesso.yahoo.com/
More information about the cairo