[cairo] Text in Windows Metafiles (EMF)

Kozhevnikov Mikhail mikhailkozhevnikov at yandex.ru
Mon Mar 2 05:13:05 PST 2009


The following code attempts to write some text to windows metafile using Cairo:
   HDC hdc = 0;
   hdc = CreateEnhMetaFile(NULL, "test.emf", NULL, NULL);
   cairo_surface_t *surface = cairo_win32_printing_surface_create(hdc);   
   cairo_t *cr = cairo_create(surface);

   cairo_rectangle(cr, 0, 0, 100, 100);
   cairo_set_source_rgb(cr, 0.5, 1, 0.5);
   cairo_move_to(cr, 0, 80);
   cairo_set_source_rgb(cr, 0, 0, 0);
   cairo_show_text(cr, "hello world");



Attached are results of the above code execution and the output of the same code when using PNG surface. On the first one the text is missing.

Any ideas why it might not work?

1) It looks like some drawing code for text is executed - if we use much larger font, the size of the image will be increased, as it is determined automatically.
2) I tried setting up font size and face, it doesn't fix the thing.

Considerations are appreciated!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.emf
Type: application/octet-stream
Size: 936 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20090302/0681b732/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.png
Type: image/png
Size: 452 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20090302/0681b732/attachment.png 

More information about the cairo mailing list