[cairo] Reimplementing cairo-win32-font.c

Owen Taylor otaylor at redhat.com
Mon Aug 22 08:28:41 PDT 2005


On Thu, 2005-08-11 at 02:34 -0300, Daniel K. O. wrote:
> Hello.
> 
> I'm currently trying to reimplement cairo-win32-font.c, as the current 
> code doesn't work at all with Win9x.
> My intention is to use FreeType to generate the glyphs and then use 
> Win32 API AlphaBlend() (or even BitBlt() as a backup for Win95).
> 
> I was looking at cairo-win32-font.c for a few hours, and my impression 
> is that I could use some of the code I wrote for one of my SDL apps some 
> weeks ago, that load FT_Faces from Windows' HFONTs (using GetFontData()) 
> and render them; but it seems that there's already some code at 
> cairo-ft-font.c to handle FreeType fonts, so maybe most of the work is 
> already done (and optimized?).
> 
> I would like to ask:
> 
>    1. Can anyone give me some hints on what functions are need to
>       replace/implement the current win32 backend? Only the ones in the
>       cairo_win32_scaled_font_backend structure? A brief description of
>       each _cairo_scaled_font_backend member's purpose would help me a lot.
>    2. Is there any part of cairo-ft-font.c that could be useful for this
>       task?

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.

One problem with this approach is that you may have trouble getting
the cairo-win32.h font API to work right:

 cairo_win32_scaled_font_select_font()

is supposed to allow the caller to use the native Win32 font 
metrics APIs and have that match the rendering.

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 reasons of metrics accuracy, you'd probably still want to
   use SetWorldTransform on more recent Windows even in this case,
   but you'd have to see how the code fell out.)

 - For the rare case of transformations that contain a shear, use
   GetGlyphOutline and have Cairo do the rasterization.

I think getting this "more or less" working is pretty easy. Getting
the details of the metrics right is harder. I spent a couple of 
days doing experimentation with XP to figure out how to write the
current code.

(http://lists.freedesktop.org/archives/cairo/2005-January/002901.html)

Regards,
						Owen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050822/0d39a0b1/attachment-0001.pgp


More information about the cairo mailing list