|
|
|
@ -74,7 +74,6 @@ |
|
|
|
|
#include FT_MAC_H |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over
|
|
|
|
|
TrueType in case *both* are available (this is not common, |
|
|
|
|
but it *is* possible). */ |
|
|
|
@ -83,7 +82,6 @@ |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Quick'n'dirty Pascal string to C string converter.
|
|
|
|
|
Warning: this call is not thread safe! Use with caution. */ |
|
|
|
|
static char* |
|
|
|
@ -134,22 +132,25 @@ |
|
|
|
|
return finfo.fdType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* is this a Mac OS X .dfont file */ |
|
|
|
|
static Boolean is_dfont( FSSpec* spec ) |
|
|
|
|
{ |
|
|
|
|
int nameLen = spec->name[0]; |
|
|
|
|
|
|
|
|
|
if ( spec->name[nameLen-5] == '.' &&
|
|
|
|
|
spec->name[nameLen-4] == 'd' &&
|
|
|
|
|
spec->name[nameLen-3] == 'f' &&
|
|
|
|
|
spec->name[nameLen-2] == 'o' &&
|
|
|
|
|
spec->name[nameLen-1] == 'n' &&
|
|
|
|
|
spec->name[nameLen] == 't') |
|
|
|
|
return true; |
|
|
|
|
else |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* is this a Mac OS X .dfont file */ |
|
|
|
|
static Boolean |
|
|
|
|
is_dfont( FSSpec* spec ) |
|
|
|
|
{ |
|
|
|
|
int nameLen = spec->name[0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( spec->name[nameLen - 5] == '.' && |
|
|
|
|
spec->name[nameLen - 4] == 'd' && |
|
|
|
|
spec->name[nameLen - 3] == 'f' && |
|
|
|
|
spec->name[nameLen - 2] == 'o' && |
|
|
|
|
spec->name[nameLen - 1] == 'n' && |
|
|
|
|
spec->name[nameLen ] == 't' ) |
|
|
|
|
return true; |
|
|
|
|
else |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Given a PostScript font name, create the Macintosh LWFN file name. */ |
|
|
|
|
static void |
|
|
|
@ -236,9 +237,9 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Look inside the FOND data, answer whether there should be an SFNT
|
|
|
|
|
resource, and answer the name of a possible LWFN Type 1 file.
|
|
|
|
|
|
|
|
|
|
Thanks to Paul Miller (paulm@profoundeffects.com) for the fix
|
|
|
|
|
resource, and answer the name of a possible LWFN Type 1 file. |
|
|
|
|
|
|
|
|
|
Thanks to Paul Miller (paulm@profoundeffects.com) for the fix |
|
|
|
|
to load a face OTHER than the first one in the FOND! |
|
|
|
|
*/ |
|
|
|
|
static void |
|
|
|
@ -305,8 +306,8 @@ |
|
|
|
|
unsigned char* suffixes = names[style->indexes[0] - 1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( i=1; i<=suffixes[0]; i++ ) |
|
|
|
|
strcat( ps_name, p2c_str( names[suffixes[i] - 1 ] ) ); |
|
|
|
|
for ( i = 1; i <= suffixes[0]; i++ ) |
|
|
|
|
strcat( ps_name, p2c_str( names[suffixes[i] - 1] ) ); |
|
|
|
|
} |
|
|
|
|
create_lwfn_name( ps_name, lwfn_file_name ); |
|
|
|
|
} |
|
|
|
@ -384,7 +385,6 @@ |
|
|
|
|
|
|
|
|
|
if ( code != last_code ) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if ( last_code != -1 ) |
|
|
|
|
{ |
|
|
|
|
/* we're done adding a chunk, fill in the size field */ |
|
|
|
@ -648,48 +648,51 @@ |
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Create a new FT_Face from a file spec to a suitcase file. */ |
|
|
|
|
static FT_Error |
|
|
|
|
FT_New_Face_From_dfont( FT_Library library, |
|
|
|
|
FSSpec* spec, |
|
|
|
|
FT_Long face_index, |
|
|
|
|
FT_Face* aface ) |
|
|
|
|
FSSpec* spec, |
|
|
|
|
FT_Long face_index, |
|
|
|
|
FT_Face* aface ) |
|
|
|
|
{ |
|
|
|
|
FT_Error error = FT_Err_Ok; |
|
|
|
|
short res_ref, res_index; |
|
|
|
|
Handle fond; |
|
|
|
|
FSRef hostContainerRef; |
|
|
|
|
|
|
|
|
|
error = FSpMakeFSRef( spec, &hostContainerRef ); |
|
|
|
|
if ( error == noErr ) |
|
|
|
|
error = FSOpenResourceFile( &hostContainerRef, 0, NULL, fsRdPerm, &res_ref ); |
|
|
|
|
|
|
|
|
|
if ( error != noErr ) |
|
|
|
|
return FT_Err_Cannot_Open_Resource; |
|
|
|
|
|
|
|
|
|
UseResFile( res_ref ); |
|
|
|
|
|
|
|
|
|
/* face_index may be -1, in which case we
|
|
|
|
|
just need to do a sanity check */ |
|
|
|
|
if ( face_index < 0 ) |
|
|
|
|
res_index = 1; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
res_index = (short)( face_index + 1 ); |
|
|
|
|
face_index = 0; |
|
|
|
|
} |
|
|
|
|
fond = Get1IndResource( 'FOND', res_index ); |
|
|
|
|
if ( ResError() ) |
|
|
|
|
{ |
|
|
|
|
error = FT_Err_Cannot_Open_Resource; |
|
|
|
|
goto Error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
error = FT_New_Face_From_FOND( library, fond, face_index, aface ); |
|
|
|
|
|
|
|
|
|
Error: |
|
|
|
|
CloseResFile( res_ref ); |
|
|
|
|
return error; |
|
|
|
|
FT_Error error = FT_Err_Ok; |
|
|
|
|
short res_ref, res_index; |
|
|
|
|
Handle fond; |
|
|
|
|
FSRef hostContainerRef; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error = FSpMakeFSRef( spec, &hostContainerRef ); |
|
|
|
|
if ( error == noErr ) |
|
|
|
|
error = FSOpenResourceFile( &hostContainerRef, |
|
|
|
|
0, NULL, fsRdPerm, &res_ref ); |
|
|
|
|
|
|
|
|
|
if ( error != noErr ) |
|
|
|
|
return FT_Err_Cannot_Open_Resource; |
|
|
|
|
|
|
|
|
|
UseResFile( res_ref ); |
|
|
|
|
|
|
|
|
|
/* face_index may be -1, in which case we
|
|
|
|
|
just need to do a sanity check */ |
|
|
|
|
if ( face_index < 0 ) |
|
|
|
|
res_index = 1; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
res_index = (short)( face_index + 1 ); |
|
|
|
|
face_index = 0; |
|
|
|
|
} |
|
|
|
|
fond = Get1IndResource( 'FOND', res_index ); |
|
|
|
|
if ( ResError() ) |
|
|
|
|
{ |
|
|
|
|
error = FT_Err_Cannot_Open_Resource; |
|
|
|
|
goto Error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
error = FT_New_Face_From_FOND( library, fond, face_index, aface ); |
|
|
|
|
|
|
|
|
|
Error: |
|
|
|
|
CloseResFile( res_ref ); |
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -740,72 +743,92 @@ Error: |
|
|
|
|
return FT_Err_Unknown_File_Format; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* documentation in ftmac.h */ |
|
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error ) |
|
|
|
|
FT_GetFile_From_Mac_Name( char* fontName, FSSpec* pathSpec, FT_Long* face_index ) |
|
|
|
|
{ |
|
|
|
|
OptionBits options = kFMUseGlobalScopeOption; |
|
|
|
|
FMFontFamilyIterator famIter; |
|
|
|
|
OSStatus status = FMCreateFontFamilyIterator(NULL, NULL, options, &famIter); |
|
|
|
|
FMFont the_font = NULL; |
|
|
|
|
FMFontFamily family = NULL; |
|
|
|
|
FT_GetFile_From_Mac_Name( char* fontName, |
|
|
|
|
FSSpec* pathSpec, |
|
|
|
|
FT_Long* face_index ) |
|
|
|
|
{ |
|
|
|
|
OptionBits options = kFMUseGlobalScopeOption; |
|
|
|
|
|
|
|
|
|
FMFontFamilyIterator famIter; |
|
|
|
|
OSStatus status = FMCreateFontFamilyIterator( NULL, NULL, |
|
|
|
|
options, |
|
|
|
|
&famIter ); |
|
|
|
|
FMFont the_font = NULL; |
|
|
|
|
FMFontFamily family = NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*face_index = 0; |
|
|
|
|
while (status == 0 && !the_font) |
|
|
|
|
while ( status == 0 && !the_font ) |
|
|
|
|
{ |
|
|
|
|
status = FMGetNextFontFamily(&famIter, &family); |
|
|
|
|
if (status == 0) |
|
|
|
|
status = FMGetNextFontFamily( &famIter, &family ); |
|
|
|
|
if ( status == 0 ) |
|
|
|
|
{ |
|
|
|
|
int stat2; |
|
|
|
|
FMFontFamilyInstanceIterator instIter; |
|
|
|
|
Str255 famNameStr; |
|
|
|
|
char famName[256]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* get the family name */ |
|
|
|
|
FMGetFontFamilyName( family, famNameStr ); |
|
|
|
|
CopyPascalStringToC( famNameStr, famName ); |
|
|
|
|
|
|
|
|
|
/* iterate through the styles */ |
|
|
|
|
FMCreateFontFamilyInstanceIterator( family, &instIter ); |
|
|
|
|
|
|
|
|
|
*face_index = 0; |
|
|
|
|
stat2 = 0; |
|
|
|
|
while ( stat2 == 0 && !the_font ) |
|
|
|
|
{ |
|
|
|
|
FMFontStyle style; |
|
|
|
|
FMFontSize size; |
|
|
|
|
FMFont font; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stat2 = FMGetNextFontFamilyInstance( &instIter, &font, |
|
|
|
|
&style, &size ); |
|
|
|
|
if ( stat2 == 0 && size == 0 ) |
|
|
|
|
{ |
|
|
|
|
char fullName[256]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* build up a complete face name */ |
|
|
|
|
strcpy( fullName, famName ); |
|
|
|
|
if ( style & bold ) |
|
|
|
|
strcat( fullName, " Bold" ); |
|
|
|
|
if ( style & italic ) |
|
|
|
|
strcat( fullName, " Italic" ); |
|
|
|
|
|
|
|
|
|
/* compare with the name we are looking for */ |
|
|
|
|
if ( strcmp( fullName, fontName ) == 0 ) |
|
|
|
|
{ |
|
|
|
|
int stat2; |
|
|
|
|
FMFontFamilyInstanceIterator instIter; |
|
|
|
|
|
|
|
|
|
/* get the family name */ |
|
|
|
|
Str255 famNameStr; |
|
|
|
|
char famName[256]; |
|
|
|
|
FMGetFontFamilyName(family, famNameStr); |
|
|
|
|
CopyPascalStringToC(famNameStr, famName); |
|
|
|
|
|
|
|
|
|
/* iterate through the styles */ |
|
|
|
|
FMCreateFontFamilyInstanceIterator(family, &instIter); |
|
|
|
|
*face_index = 0; |
|
|
|
|
stat2 = 0; |
|
|
|
|
while (stat2 == 0 && !the_font) |
|
|
|
|
{ |
|
|
|
|
FMFontStyle style; |
|
|
|
|
FMFontSize size; |
|
|
|
|
FMFont font; |
|
|
|
|
stat2 = FMGetNextFontFamilyInstance(&instIter, &font, &style, &size); |
|
|
|
|
if (stat2 == 0 && size == 0) |
|
|
|
|
{ |
|
|
|
|
/* build up a complete face name */ |
|
|
|
|
char fullName[256]; |
|
|
|
|
strcpy( fullName, famName ); |
|
|
|
|
if (style & bold) |
|
|
|
|
strcat( fullName, " Bold" ); |
|
|
|
|
if (style & italic) |
|
|
|
|
strcat( fullName, " Italic" ); |
|
|
|
|
|
|
|
|
|
/* compare with the name we are looking for */ |
|
|
|
|
if (strcmp( fullName, fontName ) == 0 ) |
|
|
|
|
{ |
|
|
|
|
/* found it! */ |
|
|
|
|
the_font = font; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
++(*face_index); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
FMDisposeFontFamilyInstanceIterator(&instIter); |
|
|
|
|
/* found it! */ |
|
|
|
|
the_font = font; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
++(*face_index); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FMDisposeFontFamilyInstanceIterator( &instIter ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
FMDisposeFontFamilyIterator( &famIter ); |
|
|
|
|
|
|
|
|
|
if ( the_font ) |
|
|
|
|
{ |
|
|
|
|
FMGetFontContainer( the_font, pathSpec ); |
|
|
|
|
return FT_Err_Ok; |
|
|
|
|
} |
|
|
|
|
FMDisposeFontFamilyIterator(&famIter); |
|
|
|
|
|
|
|
|
|
if ( the_font ) { |
|
|
|
|
FMGetFontContainer(the_font, pathSpec); |
|
|
|
|
return FT_Err_Ok; |
|
|
|
|
} else |
|
|
|
|
return FT_Err_Unknown_File_Format; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
return FT_Err_Unknown_File_Format; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/* */ |
|
|
|
@ -843,7 +866,7 @@ Error: |
|
|
|
|
return FT_New_Face_From_LWFN( library, &spec, face_index, aface ); |
|
|
|
|
else if ( is_dfont( &spec ) ) |
|
|
|
|
return FT_New_Face_From_dfont( library, &spec, face_index, aface ); |
|
|
|
|
else /* let it fall through to normal loader (.ttf, .otf, etc.) */ |
|
|
|
|
else /* let it fall through to normal loader (.ttf, .otf, etc.) */ |
|
|
|
|
{ |
|
|
|
|
args.flags = ft_open_pathname; |
|
|
|
|
args.pathname = (char*)pathname; |
|
|
|
|