-1

I am reading the Cairo tutorial, but I want to use Python instead of C. How do I translate this snippet?

cairo_text_extents_t te;
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_select_font_face (cr, "Georgia",
    CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 1.2);
cairo_text_extents (cr, "a", &te);
cairo_move_to (cr, 0.5 - te.width / 2 - te.x_bearing,
    0.5 - te.height / 2 - te.y_bearing);
cairo_show_text (cr, "a");
john mangual
  • 7,718
  • 13
  • 56
  • 95

1 Answers1

0

Note that the statements all seem to be calls to cairo functions. Calls to functions are the same in C and Python except for the final semicolon. I do not see that this even needs to be asked, assuming that the Cairo library is available in Python. The only point would be the import and use of 'import as" with the class reference.

sabbahillel
  • 4,357
  • 1
  • 19
  • 36