Re: Why can not draw Chinese string on pixbap?
- From: Peter Zelezny <pzel dodo com au>
- To: gtk-app-devel-list gnome org
- Subject: Re: Why can not draw Chinese string on pixbap?
- Date: Thu, 10 Oct 2002 17:52:50 +1000
On Thu, 10 Oct 2002 15:31:31 +0800
"chen.shengqi" <chen shengqi connet com tw> wrote:
Dear sir:
I'm using gnome 2.0 on solaris 8 for x86, the gnome system can show
Chinese menu ok, but in my application, I use gdk_draw_text can not draw
out chinese string(in GB2312), if I use gdk_mbstowcs convert it to wchar
and use gdk_draw_text_wc to draw it, it still failed,just show some
unkown characters. How to draw it ? thanks.
gdk_draw_text is deprecated in GTK 2.0.
I would suggest drawing it with Pango, because it can handle utf8/unicode.
For example:
void my_draw_string (GtkWidget *widget, char *text, GdkGC *gc, int x, int y)
{
layout = gtk_widget_create_pango_layout (widget, text);
fontd = pango_font_description_from_string ("Sans 11");
pango_layout_set_font_description (layout, fontd);
gdk_draw_layout (widget->window, gc, x, y, layout);
g_object_unref (layout);
pango_font_description_free (fontd);
}
It this case, "text" would need to be utf8. You can convert GB2312 to utf8, using
g_convert().
--
Peter Zelezny.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]