[cairo] EMF: text clipping

Zoltán Turányi teknos at gmail.com
Thu Dec 17 23:57:59 PST 2009


Hi Mikhail,

I think my previous mail did not reach you and the list, so here is its
contents again.

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). The
dropping 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 -as you say
coming from device metrics-, so glyph dropping will happen. I found no way
yet to create a metafile context which did not have this limitation. I also
think this is the reason why one cannot draw on a device context created
from an old format Windows metafile (wmf) - such contexts cannot return a
clip box, so surface creation fails.

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 drop 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 am new to cairo and don't really know whom to report such bugs (which may
not be bugs in reality), so any help here is appreciated. Maybe these should
be discussed on this list.

Zoltán


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

> Hello,
>
> Anybody knows the way to prevent text clipping when drawing to windows
> metafile?
>
> Cairo (or GDI?) seems to use the current device metrics (i.e. 1600x900 for
> my monitor) to clip the text in a metafile. That is, I can not create a
> metafile of, say, 2000x2000 - the text will be clipped out.
>
> I've tried cairo_reset_clip() and some WinAPI calls, e.g. SetViewportExtEx,
> SetWindowsExtEx, SelectClipRgn, but they make no difference.
>
> Thanks in advance,
> (and sorry for bothering everybody with windows metafiles)
> 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/20091218/d8db6b95/attachment.html 


More information about the cairo mailing list