Re: [gtk-list] Re: gtk_label and internationalisation question
- From: a-higuti math sci hokudai ac jp (Akira Higuchi)
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: gtk_label and internationalisation question
- Date: Fri, 18 Dec 1998 17:49:29 +0900 (JST)
In article <199812180352.MAA25499@galois.math.sci.hokudai.ac.jp>
I wrote:
> Shall I write a patch?
Please try to apply the following patch inside the gtk+-1.1.9/gdk
directory. This patch adds 2-byte font support into gdk_*_wc()
functions.
----------- x8 ----------- x8 ----------- x8 ----------- x8 -----------
--- gdkdraw.c.old Fri Dec 18 16:45:08 1998
+++ gdkdraw.c Fri Dec 18 16:47:52 1998
@@ -325,8 +325,16 @@
XSetFont(drawable_private->xdisplay, gc_private->xgc, xfont->fid);
text_8bit = g_new (gchar, text_length);
for (i=0; i<text_length; i++) text_8bit[i] = text[i];
- XDrawString (drawable_private->xdisplay, drawable_private->xwindow,
- gc_private->xgc, x, y, text_8bit, text_length);
+ if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
+ {
+ XDrawString (drawable_private->xdisplay, drawable_private->xwindow,
+ gc_private->xgc, x, y, text_8bit, text_length);
+ }
+ else
+ {
+ XDrawString16 (drawable_private->xdisplay, drawable_private->xwindow,
+ gc_private->xgc, x, y, (XChar2b *) text_8bit, text_length / 2);
+ }
g_free (text_8bit);
}
else if (font->type == GDK_FONT_FONTSET)
--- gdkfont.c.old Fri Dec 18 16:45:15 1998
+++ gdkfont.c Fri Dec 18 16:52:35 1998
@@ -277,9 +277,10 @@
gint text_length)
{
GdkFontPrivate *private;
- gint width;
+ gint width, i;
XFontStruct *xfont;
XFontSet fontset;
+ gchar *text_8bit;
g_return_val_if_fail (font != NULL, -1);
g_return_val_if_fail (text != NULL, -1);
@@ -290,19 +291,17 @@
{
case GDK_FONT_FONT:
xfont = (XFontStruct *) private->xfont;
+ text_8bit = g_new (gchar, text_length);
+ for (i=0; i<text_length; i++) text_8bit[i] = text[i];
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
{
- gchar *text_8bit;
- gint i;
- text_8bit = g_new (gchar, text_length);
- for (i=0; i<text_length; i++) text_8bit[i] = text[i];
width = XTextWidth (xfont, text_8bit, text_length);
- g_free (text_8bit);
}
else
{
- width = 0;
+ width = XTextWidth16 (xfont, (XChar2b *) text_8bit, text_length / 2);
}
+ g_free (text_8bit);
break;
case GDK_FONT_FONTSET:
if (sizeof(GdkWChar) == sizeof(wchar_t))
@@ -542,9 +541,18 @@
for (i=0; i<text_length; i++)
text_8bit[i] = text[i];
- XTextExtents (xfont, text_8bit, text_length,
- &direction, &font_ascent, &font_descent,
- &overall);
+ if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
+ {
+ XTextExtents (xfont, text_8bit, text_length,
+ &direction, &font_ascent, &font_descent,
+ &overall);
+ }
+ else
+ {
+ XTextExtents16 (xfont, (XChar2b *) text_8bit, text_length / 2,
+ &direction, &font_ascent, &font_descent,
+ &overall);
+ }
g_free (text_8bit);
if (lbearing)
----------- x8 ----------- x8 ----------- x8 ----------- x8 -----------
The following is an example:
----------- x8 ----------- x8 ----------- x8 ----------- x8 -----------
#include <gtk/gtk.h>
int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *button;
GtkStyle *jstyle;
GdkFont *jfont;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
jstyle = gtk_style_new ();
jfont = gdk_font_load ("-*-fixed-medium-r-*--16-*-jisx0208.1983-0");
gdk_font_unref (jstyle->font);
jstyle-> font = jfont;
button = gtk_button_new_with_label ("\x24\x22");
gtk_widget_set_style (GTK_BIN (button)->child, jstyle);
gtk_container_add (GTK_CONTAINER(window), button);
gtk_widget_show (button);
gtk_widget_show (window);
gtk_main ();
return 0;
}
----------- x8 ----------- x8 ----------- x8 ----------- x8 -----------
--------------------------------------
Akira Higuchi
Dept. of Mathematics, Hokkaido Univ.
Hokkaido, Japan
Email: a-higuti@math.sci.hokudai.ac.jp
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]