Commit 745ff2c29f4c56a26f39a2742ab45cb94b374c0c

Werner Lemberg 2006-09-19T05:48:02

* src/base/ftmac.c (FT_New_Face_From_FOND): Fall back to SFNT if LWFN fails and both are available.

diff --git a/ChangeLog b/ChangeLog
index 0a70b69..0651c50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-18  Garrick Meeker  <garrick@digitalanarchy.com>
+
+	* src/base/ftmac.c (FT_New_Face_From_FOND): Fall back to SFNT if
+	LWFN fails and both are available.
+
 2006-09-11  David Turner  <david@freetype.org>
 
 	* src/sfnt/sfobjs.c (tt_face_get_name): Support some fonts which
diff --git a/src/base/ftmac.c b/src/base/ftmac.c
index 3e23376..0d613f5 100644
--- a/src/base/ftmac.c
+++ b/src/base/ftmac.c
@@ -53,6 +53,12 @@
     - If there is a TrueType font (an `sfnt' resource), read it into memory,
       wrap it into a memory stream, load the TrueType driver and delegate
       the rest of the work to it, by calling FT_Open_Face().
+
+    - Some suitcase fonts (notably Onyx) might point the `LWFN' file to
+      itself, even though it doesn't contains `POST' resources.  To handle
+      this special case without opening the file an extra time, we just
+      ignore errors from the `LWFN' and fallback to the `sfnt' if both are
+      available.
   */
 
 
@@ -1242,19 +1248,21 @@
     }
 
     if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
-      return FT_New_Face_From_LWFN( library,
-                                    path_lwfn,
-                                    face_index,
-                                    aface );
+      error = FT_New_Face_From_LWFN( library,
+                                     path_lwfn,
+                                     face_index,
+                                     aface );
+    else
+      error = FT_Err_Unknown_File_Format;
 
   found_no_lwfn_file:
-    if ( have_sfnt )
-      return FT_New_Face_From_SFNT( library,
-                                    sfnt_id,
-                                    face_index,
-                                    aface );
+    if ( have_sfnt && FT_Err_Ok != error )
+      error = FT_New_Face_From_SFNT( library,
+                                     sfnt_id,
+                                     face_index,
+                                     aface );
 
-    return FT_Err_Unknown_File_Format;
+    return error;
   }