Skip to content

Instantly share code, notes, and snippets.

@khajavi
Last active December 16, 2015 08:48
Show Gist options
  • Save khajavi/5407952 to your computer and use it in GitHub Desktop.
Save khajavi/5407952 to your computer and use it in GitHub Desktop.
Hello World in Cairo
/*
* adopted from http://zetcode.com/gfx/cairo/cairobackends/
*/
#include <cairo.h>
int main() {
cairo_surface_t* surface;
cairo_t* cr;
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 390, 60);
cr = cairo_create( surface );
cairo_set_source_rgb( cr, 0, 0, 0 );
cairo_select_font_face( cr, "Iranian Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL );
cairo_set_font_size( cr, 40.0 );
cairo_move_to( cr, 10.0, 50.0 );
cairo_show_text( cr, "سلام جهان!" );
cairo_surface_write_to_png( surface, "hello.png" );
cairo_destroy( cr );
cairo_surface_destroy( surface );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment