Re: can't render text

Uli Schlachter <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Hi,

On 31.10.2012 17:17, Techie Help wrote:
[...]
> I am using following code:
> 
> Please let me know, what I am doing wrong.
> <code>
> cairo_select_font_face (cr, "monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAl);
> 
>     cairo_set_font_size (cr, 14);
> 
>     cairo_set_source_rgb (cr, 0, 0, 0);
> 
>     cairo_move_to (cr, 0, 50);
> 
>     cairo_show_text (cr, "Print Something");
> </code>

Let's turn this into a full, self-contained example (attached). When I compile
and run this code, I get a file called "out.png" which shows the text "Print
Something".

So you aren't doing anything wrong.

Uli
-- 
A learning experience is one of those things that say,
'You know that thing you just did? Don't do that.'
                     -- Douglas Adams

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
t.c (text/x-csrc, 631 B)
#include <cairo.h>

int main()
{
	cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 200, 200);
	cairo_t *cr = cairo_create(surface);
	cairo_surface_destroy(surface);

	/* Fill everything with white */
	cairo_set_source_rgb(cr, 1, 1, 1);
	cairo_paint(cr);

	/* Draw some text */
	cairo_select_font_face (cr, "monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size (cr, 14);
	cairo_set_source_rgb (cr, 0, 0, 0);
	cairo_move_to (cr, 0, 50);
	cairo_show_text (cr, "Print Something");

	cairo_surface_write_to_png(cairo_get_target(cr), "out.png");
	cairo_destroy(cr);
	return 0;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.