thodg
thodg

Reputation: 1777

cairo_show_text returns CAIRO_STATUS_INVALID_SURFACE

I call this function in my Cairo rendering function on MacOS :

void cairo_text_outline (cairo_t *cr, double x, double y,
                         const char *p)
{
  cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
  cairo_move_to(cr, x - 1.0, y - 1.0);
  printf("3 %s\n", cairo_status_to_string(cairo_status(cr)));
  if (cairo_status(cr))
    abort();
  cairo_show_text(cr, p);
  printf("4 %d %s\n", cairo_status(cr),
         cairo_status_to_string(cairo_status(cr)));
  if (cairo_status(cr))
    abort();
}

Here is where I call the function :

  [...]
  /* text */                                                               
  cairo_identity_matrix(cr);                                               
  cairo_set_font(cr, &g_font_courier_new);                                 
  cairo_set_font_size(cr, 20);                                             
  cairo_text_extents(cr, seq->title, &te);                                 
  cairo_text_outline(cr, 20.0, window->h - te.height - te.y_bearing - 20,  
              seq->title);                                                 
  [...]

How do I stop cairo_show_text from returning an error ? As it is it returns the following output :

3 no error has occurred
4 13 the surface type is not appropriate for the operation

That is cairo_show_text sets the Cairo error status to 13 : "the surface type is not appropriate for the operation".

I do not understand as the same code works on Linux and Windows.

Upvotes: 1

Views: 62

Answers (0)

Related Questions