[cairo] unable to render text
Mehmet Kovacioglu
mkovacioglu at gmail.com
Wed Mar 19 06:09:02 PDT 2008
thanks for the quick reply,
here's the code:
#include <cairo.h>
#include <math.h>
#include <stdio.h>
int
main (int argc, char *argv[])
{
cairo_surface_t *surface;
cairo_t *cr;
cairo_text_extents_t te;
/* Prepare drawing area */
//surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 240);
//cr = cairo_create (surface);
surface = cairo_image_surface_create_from_png("someimage.png");
cr = cairo_create (surface);
/* Examples are in 1.0 x 1.0 coordinate space */
cairo_set_line_width(cr, 5);
/* Drawing code goes here */
cairo_set_source_rgb (cr, 0.6, 0.9, 1.0);
cairo_rectangle(cr, 25, 25, 100, 100);
cairo_fill(cr);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0 );
cairo_arc(cr, 75, 75, 50, 0, 2*M_PI);
cairo_stroke(cr);
cairo_move_to(cr, 50, 75);
cairo_line_to(cr, 100, 75);
cairo_stroke(cr);
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
cairo_move_to(cr, 70, 75);
cairo_line_to(cr, 80, 75);
cairo_stroke(cr);
------------------
up till here everything works fine
------------------
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
cairo_select_font_face (cr, "sansserif",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 22);
cairo_text_extents (cr, "ABC", &te);
cairo_show_text (cr, "ABC");
--------------------
the part above isnt shown in the resulting png file
--------------------
/* Write output and clean up */
cairo_surface_write_to_png (surface, "showtext.png");
cairo_destroy (cr);
cairo_surface_destroy (surface);
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20080319/6690d540/attachment.htm
More information about the cairo
mailing list