shithub: freetype+ttf2subf

Download patch

ref: 07598339f7cd1dd830f99f63d60d7c174a9d0be4
parent: 9ae6c7c54d109cd1ed315ecdd9da82fbfe33f076
author: Just Fill Bugs <[email protected]>
date: Sat Jul 2 14:41:36 EDT 2011

Fix Savannah bug #33246.

* src/truetype/ttobjs.c (tt_check_single_notdef): New function.
(tt_face_init): Use it to test FT_FACE_FLAG_SCALABLE.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-07-02  Just Fill Bugs  <[email protected]>
+
+	Fix Savannah bug #33246.
+
+	* src/truetype/ttobjs.c (tt_check_single_notdef): New function.
+	(tt_face_init): Use it to test FT_FACE_FLAG_SCALABLE.
+
 2011-07-02  Werner Lemberg  <[email protected]>
 
 	* docs/CHANGES: Updated.
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -409,6 +409,54 @@
   }
 
 
+  /* Check whether `.notdef' is the only glyph in the `loca' table. */
+  static FT_Bool
+  tt_check_single_notdef( FT_Face  ttface )
+  {
+    FT_Bool   result = FALSE;
+
+    TT_Face   face = (TT_Face)ttface;
+    FT_UInt   asize;
+    FT_ULong  i;
+    FT_ULong  glyph_index = 0;
+    FT_UInt   count       = 0;
+
+
+    for( i = 0; i < face->num_locations; i++ )
+    {
+      tt_face_get_location( face, i, &asize );
+      if ( asize > 0 )
+      {
+        count += 1;
+        if ( count > 1 )
+          break;
+        glyph_index = i;
+      }
+    }
+
+    /* Only have a single outline. */
+    if ( count == 1 )
+    {
+      if ( glyph_index == 0 )
+        result = TRUE;
+      else
+      {
+        /* FIXME: Need to test glyphname == .notdef ? */
+        FT_Error error;
+        char buf[8];
+
+
+        error = FT_Get_Glyph_Name( ttface, glyph_index, buf, 8 );
+        if ( !error                                            &&
+             buf[0] == '.' && !ft_strncmp( buf, ".notdef", 8 ) )
+          result = TRUE;
+      }
+    }
+
+    return result;
+  }
+
+
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -504,6 +552,18 @@
       if ( !error )
         error = tt_face_load_prep( face, stream );
 
+      /* Check the scalable flag based on `loca'. */
+      if ( !ttface->internal->incremental_interface                  &&
+           face->glyph_locations && tt_check_single_notdef( ttface ) )
+      {
+        FT_TRACE5(( "tt_face_init:"
+                    " Only the `.notdef' glyph has an outline.\n"
+                    "             "
+                    " Resetting scalable flag to FALSE.\n" ));
+
+        ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE;
+      }
+
 #else
 
       if ( !error )
@@ -514,6 +574,17 @@
         error = tt_face_load_fpgm( face, stream );
       if ( !error )
         error = tt_face_load_prep( face, stream );
+
+      /* Check the scalable flag based on `loca'. */
+      if ( face->glyph_locations && tt_check_single_notdef( ttface ) )
+      {
+        FT_TRACE5(( "tt_face_init:"
+                    " Only the `.notdef' glyph has an outline.\n"
+                    "             "
+                    " Resetting scalable flag to FALSE.\n" ));
+
+        ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE;
+      }
 
 #endif