[cp-patches] FYI: Minimal fix for PR38473

Andrew John Hughes gnu_andrew at member.fsf.org
Wed Dec 10 22:18:39 UTC 2008


When attempting to obtain a GlyphVector for a font, our Gtk+
peer calls FT_Outline_Decompose on the outline of the font's glyph.
However, this fails, causing a segmentation fault, if the font
is a bitmap font.  This patch adds a check to ensure the outline
is valid before using it.  For a full fix, we should really return
some form of outline for a bitmapped font.

ChangeLog:

2008-12-09  Andrew John Hughes  <gnu_andrew at member.fsf.org>

	PR classpath/38473:
	* native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c:
	(Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphOutlineNative):
	Check that the glyph is an outline before calling
	FT_Outline_Decompose.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
-------------- next part --------------
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
===================================================================
RCS file: /sources/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c,v
retrieving revision 1.10
diff -u -u -r1.10 gnu_java_awt_peer_gtk_FreetypeGlyphVector.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c	6 Nov 2008 11:33:19 -0000	1.10
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c	10 Dec 2008 21:47:17 -0000
@@ -385,8 +385,22 @@
     }
 
   FT_Get_Glyph( ft_face->glyph, &glyph );
-  FT_Outline_Decompose (&(((FT_OutlineGlyph)glyph)->outline),
-			&ftCallbacks, path);
+  if (glyph->format == FT_GLYPH_FORMAT_OUTLINE)
+    {
+      FT_Outline_Decompose (&(((FT_OutlineGlyph)glyph)->outline),
+			    &ftCallbacks, path);
+    }
+  else
+    {
+      char format[4];
+
+      format[0] = (glyph->format & 0xFF000000) >> 24;
+      format[1] = (glyph->format & 0x00FF0000) >> 16;
+      format[2] = (glyph->format & 0x0000FF00) >> 8;
+      format[3] = (glyph->format & 0x000000FF);
+      printf("WARNING: Unable to create outline for font %s %s of format %s\n",
+	     ft_face->family_name, ft_face->style_name, format);
+    }
   FT_Done_Glyph( glyph );
   
   pango_fc_font_unlock_face( font );


More information about the Classpath-patches mailing list