[cairo] Problem with text rendering on Win32+ClearType, and possible fix

Owen Taylor otaylor at redhat.com
Thu Oct 5 11:45:09 PDT 2006


On Thu, 2006-10-05 at 20:36 +0300, Tor Lillqvist wrote:
>  > If someone (Tor?) sends a patch for 1.2.4, I'll include it in the
>  > upcoming 1.2.6 release.
> 
> I was going to answer that it would be this simple then, the "large
> hammer" approach that Owen said might be the right way:
> 
> --- ../1.2.4/src/cairo-win32-surface.c	Thu Aug 10 23:14:46 2006
> +++ src/cairo-win32-surface.c	Thu Oct  5 20:16:16 2006
> @@ -1116,7 +1116,7 @@ cairo_win32_surface_create (HDC hdc)
>      if (GetDeviceCaps(hdc, TECHNOLOGY) == DT_RASDISPLAY) {
>  	depth = GetDeviceCaps(hdc, BITSPIXEL);
>  	if (depth == 32)
> -	    format = CAIRO_FORMAT_ARGB32;
> +	    format = CAIRO_FORMAT_RGB24;
>  	else if (depth == 24)
>  	    format = CAIRO_FORMAT_RGB24;
>  	else if (depth == 16)
> 
> But then I thought, heck, I really should do at least a little
> regression testing to check that this doesn't have any unintended bad
> side-effects
> 
> And guess what... everything else seems to work fine, but with this
> simple change, "Rotated Text" in gtk-demo goes haywire... see
> http://www.saunalahti.fi/tlillqvi/rotated-text.png . I just noticed
> this and haven't looked for the cause yet.

I was unable to understand how this possibly could be happening, since
the same handling of transformation should be in place on both code
paths. Until I saw Stuart's commit of March 10 (59a45f), which 
introduced a _cairo_win32_surface_show_glyphs() that doesn't handle
rotated text.

You could probably hack around the breakage by adding some sort of
if (!_cairo_matrix_integer_transform(..)) return
CAIRO_INT_STATUS_UNSUPPORTED to that function, but I really think
reverting that patch is is more right.

While a stacktrace like:

 _cairo_win32_font_show_glyphs()
 _cairo_surface_old_show_glyphs_draw_func()
 _cairo_surface_fallback_show_glyphs()
 _cairo_surface_show_glyphs()

(what you get if you reverted that patch)

Might look like something slow is going on, I don't think that's
the case. The "fallback" and "old" just are simply indicative that 
the rewrite of the glyph handling code for X11 was inapplicable to
the Win32 font paths.

> So I don't know. Maybe after all the patch in my message that started
> this thread is better?

I don't think going through the intermediate-surface code path for all
text is acceptable for a shipping release of the Win32 code.

					- Owen




More information about the cairo mailing list