[cairo] windows metafile writing bug

Zoltán Turányi teknos at gmail.com
Fri Dec 11 04:16:45 PST 2009


Hi Mikhail,

I have ran into the same (or just a similar) problem. After some debugging I
have found that printing surfaces query the clip box on creation and later
drop all glyphs that are outside that clip region (plus some margin). This
mechanism is specific to fonts (and I think also for bitmap fallback, but I
am not sure) and is not done for e.g., paths.

Specifically, in cairo-win32-printing-surface.c the function
cairo_win32_printing_surface_create() calls the GetClipBox() windows GDI
call to set the surface.extent field of the surface under creation. This is
sometimes too small, so glyph dropping will happen.

The glyph dropping happens in _cairo_gstate_transform_glyphs_to_backend(),
which uses surface.extent to see which glyphs to drop. This function does
not any glyph if you call it with num_transformed_glyphs=NULL.

So what I did to avoid this problem is to change the call to this function
to set this parameter to NULL and recompiled cairo. Voila, it works.

I was about to file a bug, but I am 100% confident it is cairo's fault. I
wanted to see if there is a way to generate a metafile DC that has
bigger/correct initial clip. So far I was unable to create a metafile DC
that returns anything other than 1600 wide and 1200 high clip box
immediately after creation (on my Vista). I tried the following all to no
end.
- Call CreateEnhMetaFile with its third (RECT*) parameter set to non-null
- Call CreateEnhMetaFile, while providing a reference DC, with its viewport
and/or windowExt set to larger values
- Set the viewport and/or windowExt of the resulting metafileDC to a larger
value before creating the cairo surface
- Set the clipping region of the DC before creating the cairo surface

So I think I should file a bug. Even if the glyph dropping is a good idea,
having a different clipping behaviour for text and e.g., paths, does not
seem right. Any comments? (I have never filed a cairo bug before.)

BTW Try using  cairo_text_path - than one works for me.

Zoltan


2009/12/2 Kozhevnikov Mikhail <mikhailkozhevnikov at yandex.ru>

> Hi,
>
> I've been refactoring some Cairo-related code in my project and faced again
> the issue I've already told about ().
>
> If I render some text to a PNG, it works fine, but when using EMF, the text
> is gone (while graphics are displayed correctly in both cases) - see the
> code attached for a sample. I'd consider it a bug.
>
> Cheers,
> Mikhail.
>
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20091211/b1587fc5/attachment.html 


More information about the cairo mailing list