Re: widechar support




phil@bolthole.com (Philip Brown) writes:

> [ Owen Taylor writes ]
> > 
> > Hmmmmm, actually, GTK has fairly good support for CJK languages.
> > Most of it is formulated in terms of multi-byte characters,
> > not wide-characters, but it comes down in the end to the
> > same thing for the user.
> 
> I've been digging some more. It seems GtkButton uses GtkLabel.
> Which would SEEM to do the right thing, as far as the code is concerned.
> There is actually a font check, and a call to XDrawString16, in
> gdk_draw_string()
> 
> Some debug printfs say that is the function that gets called, when I set the
> font in a button to "fixed".
> 
> But when I set the font to "kanji24", a wide-char JIS font, suddenly...
> gdk_draw_string() doesn't even get CALLED?!!! 

As I indicated earlier, this just isn't going to work reliably.

The problem is that GTK+ labels convert the string to wide 
characters and all gdk_string_width_wc() on bits of the string to
figure out the allocation of the string, and all of this
is not going to be able to deal with a 16-bit string
masquerading as a 8 bit string.

The simple way to deal with this would be to simply use GDK calls to
draw on a GtkDrawingArea.

The complex way to do it would be to create a new widget that
handled drawing 16 bit labels. If you don't care about things
like justification, line-breaking, underlining and real locale-based
CJK text handling, it would be a pretty simple widget.
 
> (and yes, the button goes blank, even though I have a JIS string in there.
>  So, presumably NO draw routine is being called. And i have printfs in
>  the other gdk_draw functions)
> 
> Could some GTK internals guru give a hint as to what is happening here? 
> 
> (and incidentally, yes, I did try "export LANG=ja". I don't actually HAVE the
>   "ja" locale in my OS, though)

If you don't have the "ja" locale it isn't going to do
any good.

Regards,
                                        Owen



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