shithub: freetype+ttf2subf

Download patch

ref: ca7ef5ee0695e7d5d9adebf8577a2fa607846006
parent: 4387e43029f191baef997e68949e9bf6764d3f67
author: Werner Lemberg <[email protected]>
date: Sat Feb 28 14:12:01 EST 2004

* builds/unix/configure.ac: Fix compiler flags for
`--with-old-mac-fonts'.
* builds/unix/configure: Regenerated.

* src/base/ftmac.c: s/TARGET_API_MAC_CARBON/!TARGET_API_MAC_OS8/.
(FT_New_Face_From_Resource): New function.
(FT_New_Face): Use FT_New_Face_From_Resource.
(FT_New_Face_From_FSSpec): Use FT_New_Face_From_Resource.
[__MWERKS__]: Don't include FSp_fopen.h.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-02-27  Garrick Meeker  <[email protected]>
+
+	* builds/unix/configure.ac: Fix compiler flags for
+	`--with-old-mac-fonts'.
+	* builds/unix/configure: Regenerated.
+
+	* src/base/ftmac.c: s/TARGET_API_MAC_CARBON/!TARGET_API_MAC_OS8/.
+	(FT_New_Face_From_Resource): New function.
+	(FT_New_Face): Use FT_New_Face_From_Resource.
+	(FT_New_Face_From_FSSpec): Use FT_New_Face_From_Resource.
+	[__MWERKS__]: Don't include FSp_fopen.h.
+
 2004-02-26  Werner Lemberg  <[email protected]>
 
 	* src/pshinter/pshglob.c (psh_globals_new): Fix value of
--- a/builds/unix/configure
+++ b/builds/unix/configure
@@ -5232,7 +5232,7 @@
 
 fi;
 if test x$with_old_mac_fonts = xyes; then
-  CFLAGS="$CFLAGS -DTARGET_API_MAC_CARBON"
+  XX_ANSICFLAGS="-pedantic"
   LDFLAGS="$LDFLAGS -Xlinker -framework -Xlinker CoreServices \
                     -Xlinker -framework -Xlinker ApplicationServices"
 else
--- a/builds/unix/configure.ac
+++ b/builds/unix/configure.ac
@@ -131,7 +131,7 @@
   AS_HELP_STRING([--with-old-mac-fonts],
                  [allow Mac resource-based fonts to be used]))
 if test x$with_old_mac_fonts = xyes; then
-  CFLAGS="$CFLAGS -DTARGET_API_MAC_CARBON"
+  XX_ANSICFLAGS="-pedantic"
   LDFLAGS="$LDFLAGS -Xlinker -framework -Xlinker CoreServices \
                     -Xlinker -framework -Xlinker ApplicationServices"
 else
--- a/src/base/ftmac.c
+++ b/src/base/ftmac.c
@@ -133,7 +133,7 @@
                        FSSpec*      spec )
   {
 
-#if TARGET_API_MAC_CARBON && \
+#if !TARGET_API_MAC_OS8 && \
     !( defined( __MWERKS__ ) && !TARGET_RT_MAC_MACHO )
 
     OSErr  e;
@@ -625,7 +625,7 @@
   {
     FT_Error  error;
 
-#if TARGET_API_MAC_CARBON
+#if !TARGET_API_MAC_OS8
 
     FSRef     hostContainerRef;
 
@@ -643,7 +643,7 @@
 
     if ( error != noErr )
 
-#endif  /* TARGET_API_MAC_CARBON */
+#endif  /* !TARGET_API_MAC_OS8 */
 
     {
       *p_res_ref = FSpOpenResFile( spec, fsRdPerm );
@@ -883,7 +883,7 @@
               the_font = font;
             }
             else
-               ++(*face_index);
+              ++(*face_index);
           }
         }
 
@@ -902,7 +902,49 @@
       return FT_Err_Unknown_File_Format;
   }
 
+  /* Common function to load a new FT_Face from a resource file. */
 
+  static FT_Error
+  FT_New_Face_From_Resource( FT_Library     library,
+                             const FSSpec  *spec,
+                             FT_Long        face_index,
+                             FT_Face       *aface )
+  {
+    OSType    file_type;
+    short     res_ref;
+    FT_Error  error;
+
+
+    if ( OpenFileAsResource( spec, &res_ref ) == FT_Err_Ok )
+    {
+      /* LWFN is a (very) specific file format, check for it explicitly */
+
+      file_type = get_file_type( spec );
+      if ( file_type == 'LWFN' )
+        return FT_New_Face_From_LWFN( library, spec, face_index, aface );
+    
+      /* Otherwise the file type doesn't matter (there are more than  */
+      /* `FFIL' and `tfil').  Just try opening it as a font suitcase; */
+      /* if it works, fine.                                           */
+
+      error = FT_New_Face_From_Suitcase( library, res_ref,
+                                         face_index, aface );
+      if ( error == 0 )
+        return error;
+
+      /* else forget about the resource fork and fall through to */
+      /* data fork formats                                       */
+
+      CloseResFile( res_ref );
+    }
+
+    /* let it fall through to normal loader (.ttf, .otf, etc.); */
+    /* we signal this by returning no error and no FT_Face      */
+    *aface = NULL;
+    return 0;
+  }
+
+
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -922,9 +964,7 @@
   {
     FT_Open_Args  args;
     FSSpec        spec;
-    OSType        file_type;
-    short         res_ref;
-    FT_Error      result;
+    FT_Error      error;
 
 
     /* test for valid `library' and `aface' delayed to FT_Open_Face() */
@@ -934,29 +974,10 @@
     if ( file_spec_from_path( pathname, &spec ) )
       return FT_Err_Invalid_Argument;
 
-    if ( OpenFileAsResource( &spec, &res_ref ) == FT_Err_Ok )
-    {
-      /* LWFN is a (very) specific file format, check for it explicitly */
+    error = FT_New_Face_From_Resource( library, &spec, face_index, aface );
+    if ( error != 0 || *aface != NULL )
+      return error;
 
-      file_type = get_file_type( &spec );
-      if ( file_type == 'LWFN' )
-        return FT_New_Face_From_LWFN( library, &spec, face_index, aface );
-
-      /* Otherwise the file type doesn't matter (there are more than   */
-      /* `FFIL' and `tfil') -- just try opening it as a font suitcase; */
-      /* if it works, fine.                                            */
-
-      result = FT_New_Face_From_Suitcase( library, res_ref,
-                                          face_index, aface );
-      if ( result == 0 )
-        return result;
-
-      /* else forget about the resource fork and fall through to */
-      /* data fork formats                                       */
-
-      CloseResFile( res_ref );
-    }
-
     /* let it fall through to normal loader (.ttf, .otf, etc.) */
     args.flags    = FT_OPEN_PATHNAME;
     args.pathname = (char*)pathname;
@@ -974,14 +995,12 @@
   /*    accepts an FSSpec instead of a path.                               */
   /*                                                                       */
   FT_EXPORT_DEF( FT_Error )
-  FT_New_Face_From_FSSpec( FT_Library     library,
-                           const FSSpec  *spec,
-                           FT_Long        face_index,
-                           FT_Face       *aface )
+  FT_New_Face_From_FSSpec( FT_Library    library,
+                           const FSSpec *spec,
+                           FT_Long       face_index,
+                           FT_Face      *aface )
   {
     FT_Open_Args  args;
-    OSType        file_type;
-    short         res_ref;
     FT_Error      error;
     FT_Stream     stream;
     FILE*         file;
@@ -992,35 +1011,17 @@
     if ( !spec )
       return FT_Err_Invalid_Argument;
 
-    if ( OpenFileAsResource( spec, &res_ref ) == FT_Err_Ok )
-    {
-      /* LWFN is a (very) specific file format, check for it explicitly */
+    error = FT_New_Face_From_Resource( library, spec, face_index, aface );
+    if ( error != 0 || *aface != NULL )
+      return error;
 
-      file_type = get_file_type( spec );
-      if ( file_type == 'LWFN' )
-        return FT_New_Face_From_LWFN( library, spec, face_index, aface );
-    
-      /* Otherwise the file type doesn't matter (there are more than   */
-      /* `FFIL' and `tfil') -- just try opening it as a font suitcase; */
-      /* if it works, fine.                                            */
-
-      error = FT_New_Face_From_Suitcase( library, res_ref,
-                                         face_index, aface );
-      if ( error == 0 )
-        return error;
-
-      /* else forget about the resource fork and fall through to */
-      /* data fork formats                                       */
-
-      CloseResFile( res_ref );
-    }
-
     /* let it fall through to normal loader (.ttf, .otf, etc.) */
 
 #if defined( __MWERKS__ ) && !TARGET_RT_MAC_MACHO
 
     /* Codewarrior's C library can open a FILE from a FSSpec */
-#include <FSp_fopen.h>
+    /* but we must compile with FSp_fopen.c in addition to   */
+    /* runtime libraries.                                    */
 
     memory = library->memory;