[cairo] Win + SVG + Text

Simon Flannery simon_flannery at yahoo.com.au
Wed Jan 10 19:57:07 PST 2007


Hi,

What is the status and level of text support in cario, and specifically SVG? I only ask 'cos I think I have found an issue (or dare I say the b word).

I am using cario to load and render a SVG containing text. Once successfully loaded and rendered, after about 45 seconds the application unexpectedly exits/quits and with no error message.

This only seems to be a problem when rendering SVG at high frame rates. For example (sorry non windows users):

...
/* Start the rsvg lib. */
   rsvg_init();
/* Main message loop. */
   while (msg.message != WM_QUIT)
   {
      bMsg = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
      if (bMsg != FALSE)
      {
         TranslateMessage(&msg);
         DispatchMessage(&msg);
      }
   /* Force a redraw. */
      InvalidateRect(hWnd, NULL, 0); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   }
   if (g_my_svg != NULL)
   {
      rsvg_handle_free(g_my_svg);
   }
   rsvg_term();
...
   GError* pError = NULL;
   if ((g_my_svg = rsvg_handle_new_from_file("tmp.svg", &pError)) == NULL)
   {
      MessageBox(NULL, pError->message, "Error", 0);
   }
...
void ApplyDecal(HDC hdc, long width, long height)
{
   cairo_surface_t* surface = cairo_win32_surface_create(hdc);
   cairo_t* cr = cairo_create(surface);
/* Push the matrix stack. */
   cairo_save(cr);
/* Scale up to full-window size. */
   cairo_scale(cr, ((double) width / (double) g_dimension.width), ((double) height / (double) g_dimension.height));
/* Paint the background context colort white. */
   cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
   cairo_paint(cr);
/* Apply our decal. */
   rsvg_handle_render_cairo(g_my_svg, cr);
/* Pop the matrix stack. */
   cairo_restore(cr);
/* Force pipeline out. */
   cairo_surface_flush(surface);
/* Clean up. */
   cairo_destroy(cr);
   cairo_surface_destroy(surface);
   return;
}

And the SVG file can be as simple as:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="10cm" height="3cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg" version="1.1">
  <text x="250" y="150" 
        font-family="Verdana" font-size="55" fill="blue" >Hello, out there</text>
</svg>


So what's the deal? Has it been raised before? If so, what is the status? If new, what can be done? Work around etc...?

Thanks all.

Send instant messages to your online friends http://au.messenger.yahoo.com 


More information about the cairo mailing list