/* Create a new FT_Face from a file path to an LWFN file. */ static FT_Error FT_New_Face_From_LWFN( FT_Library library, const UInt8* pathname, FT_Long face_index, FT_Face* aface ) { FT_Byte* pfb_data; FT_ULong pfb_size; FT_Error error; ResFileRefNum res; if ( noErr != FT_FSPathMakeRes( pathname, &res ) ) return FT_Err_Cannot_Open_Resource; pfb_data = NULL; pfb_size = 0; error = read_lwfn( library->memory, res, &pfb_data, &pfb_size ); CloseResFile( res ); /* PFB is already loaded, useless anymore */ if ( error ) return error; return open_face_from_buffer( library, pfb_data, pfb_size, face_index, "type1", aface ); }
/* Create a new FT_Face from a file spec to a suitcase file. */ static FT_Error FT_New_Face_From_Suitcase( FT_Library library, const UInt8* pathname, FT_Long face_index, FT_Face* aface ) { FT_Error error = FT_ERR( Cannot_Open_Resource ); ResFileRefNum res_ref; ResourceIndex res_index; Handle fond; short num_faces_in_res; if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) ) return FT_THROW( Cannot_Open_Resource ); UseResFile( res_ref ); if ( ResError() ) return FT_THROW( Cannot_Open_Resource ); num_faces_in_res = 0; for ( res_index = 1; ; ++res_index ) { short num_faces_in_fond; fond = Get1IndResource( TTAG_FOND, res_index ); if ( ResError() ) break; num_faces_in_fond = count_faces( fond, pathname ); num_faces_in_res += num_faces_in_fond; if ( 0 <= face_index && face_index < num_faces_in_fond && error ) error = FT_New_Face_From_FOND( library, fond, face_index, aface ); face_index -= num_faces_in_fond; } CloseResFile( res_ref ); if ( !error && aface ) (*aface)->num_faces = num_faces_in_res; return error; }
/* Create a new FT_Face from a file spec to a suitcase file. */ static FT_Error FT_New_Face_From_Suitcase( FT_Library library, const UInt8* pathname, FT_Long face_index, FT_Face* aface ) { FT_Error error = FT_Err_Cannot_Open_Resource; short res_ref, res_index; Handle fond; short num_faces_in_res, num_faces_in_fond; if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) ) return FT_Err_Cannot_Open_Resource; UseResFile( res_ref ); if ( ResError() ) return FT_Err_Cannot_Open_Resource; num_faces_in_res = 0; for ( res_index = 1; ; ++res_index ) { fond = Get1IndResource( 'FOND', res_index ); if ( ResError() ) break; num_faces_in_fond = count_faces( fond, pathname ); num_faces_in_res += num_faces_in_fond; if ( 0 <= face_index && face_index < num_faces_in_fond && error ) error = FT_New_Face_From_FOND( library, fond, face_index, aface ); face_index -= num_faces_in_fond; } CloseResFile( res_ref ); if ( FT_Err_Ok == error && NULL != aface ) (*aface)->num_faces = num_faces_in_res; return error; }