Index: freetype2/builds/unix/configure =================================================================== RCS file: /cvs/freetype/freetype2/builds/unix/configure,v retrieving revision 1.30 diff -c -u -r1.30 configure --- configure 2004/02/08 22:45:47 1.30 +++ configure 2004/02/27 12:14:56 @@ -5232,7 +5232,7 @@ fi; if test x$with_old_mac_fonts = xyes; then - CFLAGS="$CFLAGS -DTARGET_API_MAC_CARBON" + XX_ANSIFLAGS="-pedantic" LDFLAGS="$LDFLAGS -Xlinker -framework -Xlinker CoreServices \ -Xlinker -framework -Xlinker ApplicationServices" else Index: freetype2/builds/unix/configure.ac =================================================================== RCS file: /cvs/freetype/freetype2/builds/unix/configure.ac,v retrieving revision 1.23 diff -c -u -r1.23 configure.ac --- configure.ac 2004/02/08 22:45:47 1.23 +++ configure.ac 2004/02/27 12:14:56 @@ -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_ANSIFLAGS="-pedantic" LDFLAGS="$LDFLAGS -Xlinker -framework -Xlinker CoreServices \ -Xlinker -framework -Xlinker ApplicationServices" else Index: freetype2/src/base/ftmac.c =================================================================== RCS file: /cvs/freetype/freetype2/src/base/ftmac.c,v retrieving revision 1.31 diff -c -u -r1.31 ftmac.c --- ftmac.c 2004/02/26 21:56:27 1.31 +++ ftmac.c 2004/02/27 12:14:59 @@ -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,44 @@ 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; + } + /*************************************************************************/ /* */ /* */ @@ -922,9 +959,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,28 +969,9 @@ 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 */ - - 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 ); - } + error = FT_New_Face_From_Resource( library, &spec, face_index, aface ); + if ( error != 0 || *aface != NULL ) + return error; /* let it fall through to normal loader (.ttf, .otf, etc.) */ args.flags = FT_OPEN_PATHNAME; @@ -974,14 +990,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; @@ -991,36 +1005,18 @@ /* test for valid `library' and `aface' delayed to FT_Open_Face() */ 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 */ - - 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 ); - } + error = FT_New_Face_From_Resource( library, spec, face_index, aface ); + if ( error != 0 || *aface != NULL ) + return error; /* 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 + /* but we must compile with FSp_fopen.c in addition to */ + /* runtime libraries. */ memory = library->memory;