[cairo] Rendering to Windows Metafile with Cairo

Kozhevnikov Mikhail mikhailkozhevnikov at yandex.ru
Tue Nov 25 08:47:00 PST 2008


Hi All,

I tried rendering smth to enhanced windows metafile. The result looks strange.
Two files attached are results of rendering the code:

void TestCairoEMF (bool emf)
{
   HDC hdc;

   cairo_surface_t *surface;
   cairo_t *cr;

   if (emf) 
   {
      hdc = CreateEnhMetaFile(NULL, "test.emf", NULL, NULL);
      surface = cairo_win32_surface_create(hdc);
   }
   else
      surface = cairo_pdf_surface_create("test.pdf", 100, 30);
   cr = cairo_create (surface);
   cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
   
   cairo_move_to(cr, 5, 5);
   cairo_line_to(cr, 30, 25);
   cairo_line_to(cr, 50, 10);
   cairo_line_to(cr, 80, 20);
   cairo_set_source_rgb(cr, 0, 0, 1);
   cairo_stroke(cr);
   
   cairo_move_to(cr, 15, 15);
   cairo_set_font_size(cr, 15);
   cairo_set_source_rgb(cr, 0, 0, 0);
   cairo_show_text(cr, "hello world");
   if (emf)
      CloseEnhMetaFile(hdc);
   cairo_destroy (cr);
   cairo_surface_destroy (surface);
}                                     


However, if I use regular win32 DC, it works fine.

Am I doing smth wrong?
Or Windows metafile rendering is not supported at all?

Thanks in advance,
Mikhail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.emf
Type: application/octet-stream
Size: 7868 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20081125/423754fc/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.pdf
Type: application/pdf
Size: 9310 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20081125/423754fc/attachment-0001.pdf 


More information about the cairo mailing list