| 1 | --- texk/xdvipdfmx/src/fontmap.c.orig 2011-08-13 20:22:21.000000000 -0400 |
| 2 | +++ texk/xdvipdfmx/src/fontmap.c 2011-08-13 20:26:16.000000000 -0400 |
| 3 | @@ -50,6 +50,99 @@ |
| 4 | #endif |
| 5 | #endif |
| 6 | |
| 7 | +#ifdef XETEX_MAC |
| 8 | +/* |
| 9 | + * These functions are from freetype2's ftmac.c. They are built as |
| 10 | + * part of the --with-old-mac-fonts option, which MacPorts does not |
| 11 | + * use because it causes problems for other ports. We need just a |
| 12 | + * couple functions, so build them here. |
| 13 | + */ |
| 14 | + OSStatus |
| 15 | + FT_ATSFontGetFileReference( ATSFontRef ats_font_id, |
| 16 | + FSRef* ats_font_ref ) |
| 17 | + { |
| 18 | + OSStatus err; |
| 19 | + |
| 20 | +#if !defined( MAC_OS_X_VERSION_10_5 ) || \ |
| 21 | + MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 |
| 22 | + FSSpec spec; |
| 23 | + |
| 24 | + |
| 25 | + err = ATSFontGetFileSpecification( ats_font_id, &spec ); |
| 26 | + if ( noErr == err ) |
| 27 | + err = FSpMakeFSRef( &spec, ats_font_ref ); |
| 28 | +#else |
| 29 | + err = ATSFontGetFileReference( ats_font_id, ats_font_ref ); |
| 30 | +#endif |
| 31 | + |
| 32 | + return err; |
| 33 | + } |
| 34 | + |
| 35 | + FT_Error |
| 36 | + FT_GetFileRef_From_Mac_ATS_Name( const char* fontName, |
| 37 | + FSRef* ats_font_ref, |
| 38 | + FT_Long* face_index ) |
| 39 | + { |
| 40 | + CFStringRef cf_fontName; |
| 41 | + ATSFontRef ats_font_id; |
| 42 | + |
| 43 | + *face_index = 0; |
| 44 | + |
| 45 | + cf_fontName = CFStringCreateWithCString( NULL, fontName, |
| 46 | + kCFStringEncodingMacRoman ); |
| 47 | + ats_font_id = ATSFontFindFromName( cf_fontName, |
| 48 | + kATSOptionFlagsUnRestrictedScope ); |
| 49 | + CFRelease( cf_fontName ); |
| 50 | + |
| 51 | + if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL ) |
| 52 | + return FT_Err_Unknown_File_Format; |
| 53 | + |
| 54 | + if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) ) |
| 55 | + return FT_Err_Unknown_File_Format; |
| 56 | + |
| 57 | + /* face_index calculation by searching preceding fontIDs */ |
| 58 | + /* with same FSRef */ |
| 59 | + { |
| 60 | + ATSFontRef id2 = ats_font_id - 1; |
| 61 | + FSRef ref2; |
| 62 | + |
| 63 | + |
| 64 | + while ( id2 > 0 ) |
| 65 | + { |
| 66 | + if ( noErr != FT_ATSFontGetFileReference( id2, &ref2 ) ) |
| 67 | + break; |
| 68 | + if ( noErr != FSCompareFSRefs( ats_font_ref, &ref2 ) ) |
| 69 | + break; |
| 70 | + |
| 71 | + id2--; |
| 72 | + } |
| 73 | + *face_index = ats_font_id - ( id2 + 1 ); |
| 74 | + } |
| 75 | + |
| 76 | + return FT_Err_Ok; |
| 77 | + } |
| 78 | + |
| 79 | + FT_Error |
| 80 | + FT_GetFilePath_From_Mac_ATS_Name( const char* fontName, |
| 81 | + UInt8* path, |
| 82 | + UInt32 maxPathSize, |
| 83 | + FT_Long* face_index ) |
| 84 | + { |
| 85 | + FSRef ref; |
| 86 | + FT_Error err; |
| 87 | + |
| 88 | + |
| 89 | + err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index ); |
| 90 | + if ( FT_Err_Ok != err ) |
| 91 | + return err; |
| 92 | + |
| 93 | + if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) ) |
| 94 | + return FT_Err_Unknown_File_Format; |
| 95 | + |
| 96 | + return FT_Err_Ok; |
| 97 | + } |
| 98 | +#endif |
| 99 | + |
| 100 | /* CIDFont */ |
| 101 | static char *strip_options (const char *map_name, fontmap_opt *opt); |
| 102 | |