cairo.cc
| 1 | #include <cairo.h> |
|---|---|
| 2 | #include <cairo-pdf.h> |
| 3 | #include <pango/pangocairo.h> |
| 4 | |
| 5 | // gcc cairo.cc `pkg-config --cflags --libs cairo pangocairo`
|
| 6 | |
| 7 | int main() {
|
| 8 | cairo_surface_t *surface; |
| 9 | cairo_t *cr; |
| 10 | cairo_matrix_t matrix; |
| 11 | PangoFontDescription *font_description; |
| 12 | PangoLayout *layout; |
| 13 | |
| 14 | surface = cairo_pdf_surface_create ("cairo.pdf", 150, 120); |
| 15 | cr = cairo_create (surface); |
| 16 | layout = pango_cairo_create_layout(cr); |
| 17 | |
| 18 | font_description = pango_font_description_from_string("Linux Libertine O 12");
|
| 19 | if(font_description == NULL) { |
| 20 | printf("! ERROR : font description creation\n");
|
| 21 | return(1); |
| 22 | } |
| 23 | pango_layout_set_font_description(layout, font_description); |
| 24 | |
| 25 | cairo_matrix_init(&matrix, 1.5, 0.1, 0.1, 1.0, 0.0, 0.0); |
| 26 | cairo_set_matrix(cr, &matrix); |
| 27 | |
| 28 | pango_layout_set_text(layout, "Texte", -1); |
| 29 | cairo_move_to (cr, 50, 50); |
| 30 | pango_cairo_show_layout (cr, layout); |
| 31 | |
| 32 | cairo_surface_finish(surface); |
| 33 | cairo_surface_destroy(surface); |
| 34 | |
| 35 | return(0); |
| 36 | } |