Re: widechar support



[ otaylor@redhat.com writes ]
> 
> phil@bolthole.com (Philip Brown) writes:
> ...
> > 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.

I think there has been some code drift, and noone knows what it "really" does
any more :-)

I just did some more experimentation.
"unfortunately"(?) I seem to have lost my example that shows where things
REALLY screw up. That was done with buttons. I have now simplified my
test code further. Here's an example that will hopefully interest you.

The code below WORKS!! It creates a regular label, sets the font
to a 16bit font, and prints out the expected chars properly, if you call it
with any kind of argument. (eg "prog doit")
This is WITHOUT screwing around with locales, and almost exactly what
I wanted in the first place.

Unfortunately, the centering calculations are screwed up.
[even when I make the string "pure" 16bit chars]
But anyways...

This shows that the 16-bit-font detection is in place, and will display
the string, IFF it gets called.
Unfortunately, it seems your button widgets are rather screwy. They should
have an interface consistant with labels, IMO. But apparently, they do not.

If you switch the object creation type below, from label, to button, suddenly,
the code does not work any more, and only prints out the string in
ascii mode.

I consider this a bug. How about you?


############################################################

#include <gtk/gtk.h>

int main (int argc, char *argv[]){
  GdkFont *kanji_font;
  GtkStyle *style;
  char labelstring[100],fontname[100];
  GtkWidget *window, *label;

  sprintf(labelstring,"%c%c%c%c doubletest",0x31,0x2b,0x31,0x26);

  if (argc > 1) {
      puts ("using kanji24 as font");
      sprintf (fontname, "%s", "kanji24");
    }  else   {
      sprintf (fontname, "%s", "fixed");
    }
  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_container_set_border_width (GTK_CONTAINER (window), 10);
  label = gtk_label_new (labelstring);
  /* change to label = gtk_button_new_with_label (labelstring); */

  kanji_font = gdk_font_load (fontname);
  style = gtk_style_copy (gtk_widget_get_style (window));
  gdk_font_unref (style->font);
  style->font = kanji_font;
  gdk_font_ref (style->font);
  gtk_widget_set_style (label, style);

  gtk_container_add (GTK_CONTAINER (window), label);
  gtk_widget_show (label);
  gtk_widget_show (window);
  gtk_main ();

  return (0);
}




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