Drawing text into a drawing area with Pango
- From: Bryan Brown <bbrown saltmine radix net>
- To: gtk-app-devel-list gnome org
- Subject: Drawing text into a drawing area with Pango
- Date: Tue, 17 Feb 2004 09:46:01 -0500 (EST)
Hello,
One part of my gtk/gnome application draws a text string onto a drawing
area at the spot where the user releases the left mouse button. With gtk
1.2 I used gdk_draw_string, and in converting to gtk 2.x I understand that
I need to switch to using Pango.
Problem is, it's not clear to me what parts of the Pango context and
layout I need to initialize other than the text string. Here's a snippet
of the code that I've tried so far:
=== begin code snippet ===
PangoContext *context;
PangoLayout *layout;
gchar *text_buffer[] = "BLAH";
GdkEventButton *event;
GdkGC *gc;
gint x_start, y_start;
[snip]
context = (PangoContext *) pango_context_new ();
layout = pango_layout_new (context);
pango_layout_set_text (layout, text_buffer, -1);
[snip]
x_start = event->x;
y_start = event->y;
gdk_draw_layout (drawing_area->window,
gc,
x_start,
y_start,
layout);
=== end code snippet ===
This causes an abend in the call to gdk_draw_layout when run, presumably
because I've not initialized some items in the Pango context and/or
layout.
What other items do I need to initialize? I can't readily find some
"simple", sample code to illustrate the process, hence my appeal for help.
Sample code would be especially appreciated :-)
Thanks,
Bryan
*---------------------------------------------------------------
* Bryan Brown <*> bbrown radix net
* http://www.radix.net/~bbrown
*---------------------------------------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]