#include /* gcc -o cairo_font_quartz cairo_font_quartz.c `pkg-config --cflags --libs cairo` */ int main (int argc, char **argv) { cairo_t *cr; cairo_surface_t *surface; cairo_pattern_t *pattern = cairo_pattern_create_linear (0, 0, 400, 0); #ifndef NOT_QUARTZ #define FONT "Lucida Grande" surface = cairo_quartz_surface_create (CAIRO_FORMAT_RGB24, 400, 200); #else #define FONT "Sans" surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 400, 200); #endif cr = cairo_create (surface); cairo_select_font_face (cr, FONT, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (cr, 14.0); cairo_set_source_rgb (cr, 1,1,1); cairo_move_to (cr, 10, 30); cairo_show_text (cr, "this is rendered with a source color"); cairo_pattern_add_color_stop_rgb (pattern, 0, 1, 1, 1); cairo_set_source (cr, pattern); cairo_move_to (cr, 10, 70); cairo_show_text (cr, "and this is rendered with a pattern as a source"); cairo_set_source_rgb (cr, 1,1,1); cairo_rectangle (cr, 0, 100, 400, 200); cairo_fill (cr); cairo_set_source_rgb (cr, 0,0,0); cairo_move_to (cr, 10, 130); cairo_show_text (cr, "this is rendered with a source color"); cairo_pattern_add_color_stop_rgb (pattern, 0, 0, 0, 0); cairo_set_source (cr, pattern); cairo_move_to (cr, 10, 170); cairo_show_text (cr, "and this is rendered with a pattern as a source"); cairo_surface_write_to_png (surface, "cairo_font_quartz.png"); cairo_pattern_destroy (pattern); cairo_destroy (cr); return 0; }