ISO 10646 fonts in GTK+



On Mon, 16 Aug 1999, Markus Kuhn wrote:

> Adding the Helvetica font to XFree86 is problematic at the moment,
> because GTK+ still has two bugs that cause it to break horribly when
> helvetica-*-iso10646-1 is only present in the server ... :-(   (bug
> report already submitted last week, but no reply yet.)

If it's not too much trouble, can somebody try the attached patch against
GTK+? I think that it will break support for CJK, but it might otherwise
work. (It ought to just pretend that the iso10646-1 font is an iso8859-1
font).

If it does work, probably a medium-term hack would involve forcing 
*-iso10646-1 fonts to have their ranges set to 0x0000 to 0x00ff in GDK 
somewhere. Would this be an acceptable solution for 1.2?

This is a pressing need, as XFree86 4.0 will ship with assorted 
iso10646-1 fonts, which GTK+ 1.2 is currently unable to deal with.

-- 
Robert
Index: gdk/gdkfont.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkfont.c,v
retrieving revision 1.16
diff -u -u -r1.16 gdkfont.c
--- gdk/gdkfont.c	1999/03/10 01:15:01	1.16
+++ gdk/gdkfont.c	1999/08/16 18:49:48
@@ -231,14 +231,7 @@
     {
     case GDK_FONT_FONT:
       xfont = (XFontStruct *) font_private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-	{
-	  width = XTextWidth (xfont, string, strlen (string));
-	}
-      else
-	{
-	  width = XTextWidth16 (xfont, (XChar2b *) string, strlen (string) / 2);
-	}
+      width = XTextWidth (xfont, string, strlen (string));
       break;
     case GDK_FONT_FONTSET:
       fontset = (XFontSet) font_private->xfont;
@@ -270,14 +263,7 @@
     {
     case GDK_FONT_FONT:
       xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-	{
-	  width = XTextWidth (xfont, text, text_length);
-	}
-      else
-	{
-	  width = XTextWidth16 (xfont, (XChar2b *) text, text_length / 2);
-	}
+      width = XTextWidth (xfont, text, text_length);
       break;
     case GDK_FONT_FONTSET:
       fontset = (XFontSet) private->xfont;
@@ -306,21 +292,14 @@
 
   switch (font->type)
     {
+    gchar *text_8bit;
+    gint i;
     case GDK_FONT_FONT:
       xfont = (XFontStruct *) private->xfont;
-      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;
-        }
+      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);
       break;
     case GDK_FONT_FONTSET:
       if (sizeof(GdkWChar) == sizeof(wchar_t))
@@ -366,21 +345,11 @@
     case GDK_FONT_FONT:
       /* only 8 bits characters are considered here */
       xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) &&
-	  (xfont->max_byte1 == 0) &&
-	  (ch >= xfont->min_char_or_byte2) &&
-	  (ch <= xfont->max_char_or_byte2))
-	{
-	  chars = xfont->per_char;
-	  if (chars)
-	    width = chars[ch - xfont->min_char_or_byte2].width;
-	  else
-	    width = xfont->min_bounds.width;
-	}
+      chars = xfont->per_char;
+      if (chars)
+        width = chars[ch - xfont->min_char_or_byte2].width;
       else
-	{
-	  width = XTextWidth (xfont, &character, 1);
-	}
+	width = xfont->min_bounds.width;
       break;
     case GDK_FONT_FONTSET:
       fontset = (XFontSet) private->xfont;
@@ -412,22 +381,11 @@
     case GDK_FONT_FONT:
       /* only 8 bits characters are considered here */
       xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) &&
-          (xfont->max_byte1 == 0) &&
-          (ch >= xfont->min_char_or_byte2) &&
-          (ch <= xfont->max_char_or_byte2))
-        {
-          chars = xfont->per_char;
-          if (chars)
-            width = chars[ch - xfont->min_char_or_byte2].width;
-          else
-            width = xfont->min_bounds.width;
-        }
+      chars = xfont->per_char;
+      if (chars)
+        width = chars[ch - xfont->min_char_or_byte2].width;
       else
-        {
-          char ch2 = character;
-          width = XTextWidth (xfont, &ch2, 1);
-        }
+        width = xfont->min_bounds.width;
       break;
     case GDK_FONT_FONTSET:
       fontset = (XFontSet) private->xfont;
@@ -480,18 +438,9 @@
     {
     case GDK_FONT_FONT:
       xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-	{
-	  XTextExtents (xfont, text, text_length,
-			&direction, &font_ascent, &font_descent,
-			&overall);
-	}
-      else
-	{
-	  XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
-			  &direction, &font_ascent, &font_descent,
-			  &overall);
-	}
+      XTextExtents (xfont, text, text_length,
+	   	    &direction, &font_ascent, &font_descent,
+		    &overall);
       if (lbearing)
 	*lbearing = overall.lbearing;
       if (rbearing)
@@ -553,7 +502,7 @@
 	gint i;
 
 	xfont = (XFontStruct *) private->xfont;
-	g_return_if_fail ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0));
+	//	g_return_if_fail ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0));
 
 	text_8bit = g_new (gchar, text_length);
 	for (i=0; i<text_length; i++) 
@@ -635,18 +584,9 @@
     {
     case GDK_FONT_FONT:
       xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-	{
-	  XTextExtents (xfont, text, text_length,
-			&direction, &font_ascent, &font_descent,
-			&overall);
-	}
-      else
-	{
-	  XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
-			  &direction, &font_ascent, &font_descent,
-			  &overall);
-	}
+      XTextExtents (xfont, text, text_length,
+   	   	    &direction, &font_ascent, &font_descent,
+		    &overall);
       width = overall.rbearing;
       break;
     case GDK_FONT_FONTSET:
@@ -703,18 +643,9 @@
     {
     case GDK_FONT_FONT:
       xfont = (XFontStruct *) private->xfont;
-      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
-	{
-	  XTextExtents (xfont, text, text_length,
-			&direction, &font_ascent, &font_descent,
-			&overall);
-	}
-      else
-	{
-	  XTextExtents16 (xfont, (XChar2b *) text, text_length / 2,
-			  &direction, &font_ascent, &font_descent,
-			  &overall);
-	}
+      XTextExtents (xfont, text, text_length,
+	            &direction, &font_ascent, &font_descent,
+		    &overall);
       height = overall.ascent + overall.descent;
       break;
     case GDK_FONT_FONTSET:


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