00842 {
00843 short have_sfnt, have_lwfn = 0;
00844 ResID sfnt_id, fond_id;
00845 OSType fond_type;
00846 Str255 fond_name;
00847 Str255 lwfn_file_name;
00848 UInt8 path_lwfn[PATH_MAX];
00849 OSErr err;
00850 FT_Error error = FT_Err_Ok;
00851
00852
00853 GetResInfo( fond, &fond_id, &fond_type, fond_name );
00854 if ( ResError() != noErr || fond_type != TTAG_FOND )
00855 return FT_Err_Invalid_File_Format;
00856
00857 parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
00858
00859 if ( lwfn_file_name[0] )
00860 {
00861 ResFileRefNum res;
00862
00863
00864 res = HomeResFile( fond );
00865 if ( noErr != ResError() )
00866 goto found_no_lwfn_file;
00867
00868 {
00869 UInt8 path_fond[PATH_MAX];
00870 FSRef ref;
00871
00872
00873 err = FSGetForkCBInfo( res, kFSInvalidVolumeRefNum,
00874 NULL, NULL, NULL, &ref, NULL );
00875 if ( noErr != err )
00876 goto found_no_lwfn_file;
00877
00878 err = FSRefMakePath( &ref, path_fond, sizeof ( path_fond ) );
00879 if ( noErr != err )
00880 goto found_no_lwfn_file;
00881
00882 error = lookup_lwfn_by_fond( path_fond, lwfn_file_name,
00883 path_lwfn, sizeof ( path_lwfn ) );
00884 if ( FT_Err_Ok == error )
00885 have_lwfn = 1;
00886 }
00887 }
00888
00889 if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
00890 error = FT_New_Face_From_LWFN( library,
00891 path_lwfn,
00892 face_index,
00893 aface );
00894 else
00895 error = FT_Err_Unknown_File_Format;
00896
00897 found_no_lwfn_file:
00898 if ( have_sfnt && FT_Err_Ok != error )
00899 error = FT_New_Face_From_SFNT( library,
00900 sfnt_id,
00901 face_index,
00902 aface );
00903
00904 return error;
00905 }