Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cairo.h"
- #include "cairo-svg.h"
- int main(int argc, char* argv[])
- {
- double font_size = 25.0,
- height = 200.0,
- left = 15.0,
- top = 15.0,
- width = 200.0;
- char filename[8]= "temp.svg",
- *text = "This is a Test";
- cairo_surface_t *surface = cairo_svg_surface_create(filename,
- width,
- height);
- //cairo_svg_surface_restrict_to_version (surface, CAIRO_SVG_VERSION_1_1);
- cairo_t* cr = cairo_create (surface);
- int size = height * width;
- int data[size];
- cairo_surface_t *text_surface = cairo_image_surface_create_for_data(data,
- width,
- height,
- 512*4);
- cairo_set_source_surface(cr, text_surface, 0, 0);
- cairo_paint(cr);
- cairo_move_to (cr, left, top);
- cairo_text_extents_t te;
- cairo_select_font_face (cr,
- "Georgia",
- CAIRO_FONT_SLANT_NORMAL,
- CAIRO_FONT_WEIGHT_BOLD);
- cairo_set_font_size (cr, (double)font_size);
- cairo_text_extents (cr, text, &te);
- cairo_show_text (cr, text);
- cairo_fill(cr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement