unicode, rendering, and a minor doc typeo patch



I've been playing with the Unicode support in the new GTK.
(My program actually will need it, because it has a lot of Russian users
and the website it interacts with is switching to UTF-8 Really Soon
Now.)

It's pretty neat-- antialiased fonts are pretty:
http://neugierig.org/pics/livejournal/2002/01-24.png

My current project is trying to write a simple font character set
browser using Gtk.  I want to render the glyphs from the font to a
GtkLayout (so it can scroll).

It seems the easy (and probably naive and slow) way to render fonts is
like this (in the expose event): 
	layout = gtk_widget_create_pango_layout(widget, text);
	gdk_draw_layout(window, 
		widget->style->fg_gc[widget->state],
		10, 10, 
		layout); 
	g_object_unref(G_OBJECT(layout));

When I try this with my sample file (sample.u8, displayed in the above
screenshot), my text displays correctly, but I get this warning:
	fb (pid:17955): ** WARNING **: pango_default_break(): the array
	of PangoLogAttr passed in must have at least N+1 elements, if
	there are N characters in the text being broken

Here's a backtrace (using --g-fatal-warnings):
#2  0x4044401e in pango_default_break () from /usr/lib/libpango-0.23.so
#3  0x404456b6 in pango_break () from /usr/lib/libpango-0.23.so
#4  0x404506ab in pango_layout_get_pixel_size () from /usr/lib/libpango-0.23.so
#5  0x404509c9 in pango_layout_get_pixel_size () from /usr/lib/libpango-0.23.so
#6  0x40451fa3 in pango_layout_get_iter () from /usr/lib/libpango-0.23.so
#7  0x4024400b in gdk_draw_layout_with_colors () from /usr/lib/libgdk-x11-1.3.so.12
#8  0x402442a0 in gdk_draw_layout () from /usr/lib/libgdk-x11-1.3.so.12
#9  0x080491e0 in expose_event ()


Am I going about this the wrong way?

The other option is to use gdk_draw_glyphs(), but I'm not sure of the
issues involved in that (the documentation warns against it).  For this
project, I do just want to display the individual glyphs in the font,
though...


I'm sorry if this is the wrong place to ask, but pango.org doesn't work
and mail.nl.linux.org (home of linux-utf8) wasn't working (though it
appears to work now?).


(While I'm at it, though:  is it correct that there is no way to input
Japanese kana via XIM while in a UTF-8 locale?  I saw something written
to the effect of "it's impossible" somewhere...)


Finally, there's a typeo in the documentation.  Patch attached (it
changes a "Gdk" to a "Gtk", if you can't see the difference).

-- 
      Evan Martin
martine cs washington edu
  http://neugierig.org
Index: docs/reference/gtk/tmpl/gtkdrawingarea.sgml
===================================================================
RCS file: /cvs/gnome/gtk+/docs/reference/gtk/tmpl/gtkdrawingarea.sgml,v
retrieving revision 1.10
diff -u -r1.10 gtkdrawingarea.sgml
--- docs/reference/gtk/tmpl/gtkdrawingarea.sgml	2002/01/19 18:51:46	1.10
+++ docs/reference/gtk/tmpl/gtkdrawingarea.sgml	2002/01/24 20:48:49
@@ -53,7 +53,7 @@
 <title>Simple <structname>GtkDrawingArea</structname> usage.</title>
 <programlisting>
 gboolean
-expose_event_callback (GdkWidget *widget, GdkEventExpose *event, gpointer data)
+expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
 {
   gdk_draw_arc (widget->window,
                 widget->style->fg_gc[GTK_WIDGET_STATE (widget)],


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]