Re: [gtk-list] Re: japaneze support



Hi,

As Peter Linsley mentioned above, current gtk+ (both stable and development
serias) supports international string includes japanese.

If you use default gtk+, all widgets can draw japanese string, and entry
widget can be used to input japanese.
Text widget does not support to input japanese, although it can draw it.
There are some patches for text widget to support inputting international
string (links to some of these patches are introduced in my home page).

If your system (OS or X) supports japanese locale, to use japanese with gtk
is very easy. You must only call gtk_set_locale () before gtk_init () and
specify fontset. You can use japanese string as same as ascii string.

If your system does not support japanese locale, inputting japanese is
difficult, but you can still draw it. In this case, you must specify font
other than fontset. In X environment, japanese fonts are encoded in JIS code,
so you must also convert EUC code to JIS.

I hope following code helps you learn who to draw japanese with gtk.

Regards,


                                  -Takashi Matsuda
                                   matsu@arch.comp.kyutech.ac.jp


-- demo1.c ( system supports japanese locale ) ---

#include <gtk/gtk.h>

int main (int argc, char **argv)
{
  /* this is "hello" in japanese (EUC code) */
  static guchar message[]
    = {0xa4, 0xb3, 0xa4, 0xf3, 0xa4, 0xcb, 0xa4, 0xc1, 0xa4, 0xcf, 0};
  GtkWidget *window, *label;

  gtk_set_locale ();
  gtk_init (&argc, &argv);
  gtk_rc_parse ("./demo1rc");

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  label = gtk_label_new (message);
  gtk_container_add (GTK_CONTAINER(window), label);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}


-- rc file for demo1.c --

style "japanese"
{
  fontset = "*"
}

class "GtkLabel" style "japanese"



-- demo2.c ( system does not support japanese but there is japanese font ) --

#include <gtk/gtk.h>

int main (int argc, char **argv)
{
  /* this is "hello" in japanese (JIS code) */
  static guchar message[]
    = {0x24, 0x33, 0x24, 0x73, 0x24, 0x4b, 0x24, 0x41, 0x24, 0x4f, 0};
  GtkWidget *window, *label;

  gtk_init (&argc, &argv);
  gtk_rc_parse ("./demo2rc");

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  label = gtk_label_new (message);
  gtk_container_add (GTK_CONTAINER(window), label);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}


-- rc file for demo2.c --

style "japanese"
{
  font = "-*-jisx0208.1983-0"
}

class "GtkLabel" style "japanese"



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