* Add FT_GetFilePath_From_Mac_ATS_Name as replacement for FT_GetFile_From_Mac_ATS_Name

This commit is contained in:
Suzuki, Toshiya (鈴木俊哉) 2007-02-05 03:28:29 +00:00
Родитель 027357f1c8
Коммит 4827e9bd2c
4 изменённых файлов: 227 добавлений и 41 удалений

Просмотреть файл

@ -1,3 +1,12 @@
2007-02-05 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
* include/freetype/ftmac.h (FT_GetFilePath_From_Mac_ATS_Name):
Introduced as replacement of FT_GetFile_From_Mac_ATS_Name.
* src/base/ftmac.c (FT_GetFilePath_From_Mac_ATS_Name): Ditto.
(FT_GetFile_From_Mac_ATS_Name): Rewritten as wrapper of
FT_GetFilePath_From_Mac_ATS_Name.
* builds/mac/ftmac.c: Ditto.
2007-02-05 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
* include/freetype/ftmac.h: Fixed wrong comment, FSSpec of

Просмотреть файл

@ -243,22 +243,34 @@
#endif /* HAVE_QUICKDRAW_CARBON */
#if !HAVE_ATS
#if HAVE_ATS
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index )
/* Private function. */
/* The FSSpec type has been discouraged for a long time, */
/* but for some reason, there is no FSRef version of */
/* ATSFontGetFileSpecification(), so we made our own. */
/* Apple will provide one eventually. */
static OSStatus
FT_ATSFontGetFileReference( ATSFontRef ats_font_id,
FSRef* ats_font_ref )
{
return FT_Err_Unimplemented_Feature;
OSStatus err;
FSSpec spec;
err = ATSFontGetFileSpecification( ats_font_id, &spec );
if ( noErr == err )
{
err = FSpMakeFSRef( &spec, ats_font_ref );
}
return err;
}
#else
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index )
static FT_Error
FT_GetFileRef_From_Mac_ATS_Name( const char* fontName,
FSRef* ats_font_ref,
FT_Long* face_index )
{
CFStringRef cf_fontName;
ATSFontRef ats_font_id;
@ -274,36 +286,104 @@
if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
return FT_Err_Unknown_File_Format;
if ( 0 != ATSFontGetFileSpecification( ats_font_id, pathSpec ) )
if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) )
return FT_Err_Unknown_File_Format;
/* face_index calculation by searching preceding fontIDs */
/* with same FSRef */
{
int i;
FSSpec f;
ATSFontRef id2 = ats_font_id - 1;
FSRef ref2;
for ( i = 1; i < ats_font_id; i++ )
while ( id2 > 0 )
{
if ( 0 != ATSFontGetFileSpecification( ats_font_id - i,
&f ) ||
f.vRefNum != pathSpec->vRefNum ||
f.parID != pathSpec->parID ||
f.name[0] != pathSpec->name[0] ||
0 != ft_strncmp( (char *)f.name + 1,
(char *)pathSpec->name + 1,
f.name[0] ) )
if ( noErr != FT_ATSFontGetFileReference( id2, &ref2 ) )
break;
if ( noErr != FSCompareFSRefs( ats_font_ref, &ref2 ) )
break;
id2 --;
}
*face_index = ( i - 1 );
*face_index = ats_font_id - ( id2 + 1 );
}
return FT_Err_Ok;
}
#endif
#if !HAVE_ATS
FT_EXPORT_DEF( FT_Error )
FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
UInt8* path,
UInt32 maxPathSize,
FT_Long* face_index )
{
return FT_Err_Unimplemented_Feature;
}
#else
FT_EXPORT_DEF( FT_Error )
FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
UInt8* path,
UInt32 maxPathSize,
FT_Long* face_index )
{
FSRef ref;
FT_Error err;
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
if ( FT_Err_Ok != err )
return err;
if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) )
return FT_Err_Unknown_File_Format;
return FT_Err_Ok;
}
#endif /* HAVE_ATS */
#if !HAVE_FSSPEC
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index )
{
return FT_Err_Unimplemented_Feature;
}
#else
/* This function is deprecated because FSSpec is deprecated in Mac OS X */
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index )
{
FSRef ref;
FT_Error err;
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
if ( FT_Err_Ok != err )
return err;
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL,
pathSpec, NULL ) )
return FT_Err_Unknown_File_Format;
return FT_Err_Ok;
}
#endif
#if defined( __MWERKS__ ) && !TARGET_RT_MAC_MACHO
#define STREAM_FILE( stream ) ( (FT_FILE*)stream->descriptor.pointer )

Просмотреть файл

@ -147,6 +147,37 @@ FT_BEGIN_HEADER
FT_Long* face_index );
/*************************************************************************/
/* */
/* <Function> */
/* FT_GetFilePath_From_Mac_ATS_Name */
/* */
/* <Description> */
/* Return a pathname of the disk file and face index for given font */
/* name which is handled by ATS framework. */
/* */
/* <Input> */
/* fontName :: Mac OS name of the font in ATS framework. */
/* */
/* <Output> */
/* path :: Buffer to store pathname of the file. For passing */
/* to @FT_New_Face. The client must allocate this */
/* buffer before calling this function. */
/* */
/* maxPathSize :: Lengths of the buffer `path' that client allocated. */
/* */
/* face_index :: Index of the face. For passing to @FT_New_Face. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT( FT_Error )
FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
UInt8* path,
UInt32 maxPathSize,
FT_Long* face_index );
/*************************************************************************/
/* */
/* <Function> */

Просмотреть файл

@ -108,10 +108,32 @@
}
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index )
/* Private function. */
/* The FSSpec type has been discouraged for a long time, */
/* but for some reason, there is no FSRef version of */
/* ATSFontGetFileSpecification(), so we made our own. */
/* Apple will provide one eventually. */
static OSStatus
FT_ATSFontGetFileReference( ATSFontRef ats_font_id,
FSRef* ats_font_ref )
{
OSStatus err;
FSSpec spec;
err = ATSFontGetFileSpecification( ats_font_id, &spec );
if ( noErr == err )
{
err = FSpMakeFSRef( &spec, ats_font_ref );
}
return err;
}
static FT_Error
FT_GetFileRef_From_Mac_ATS_Name( const char* fontName,
FSRef* ats_font_ref,
FT_Long* face_index )
{
CFStringRef cf_fontName;
ATSFontRef ats_font_id;
@ -127,34 +149,78 @@
if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
return FT_Err_Unknown_File_Format;
if ( 0 != ATSFontGetFileSpecification( ats_font_id, pathSpec ) )
if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) )
return FT_Err_Unknown_File_Format;
/* face_index calculation by searching preceding fontIDs */
/* with same FSRef */
{
int i;
FSSpec f;
ATSFontRef id2 = ats_font_id - 1;
FSRef ref2;
for ( i = 1; i < ats_font_id; i++ )
while ( id2 > 0 )
{
if ( 0 != ATSFontGetFileSpecification( ats_font_id - i,
&f ) ||
f.vRefNum != pathSpec->vRefNum ||
f.parID != pathSpec->parID ||
f.name[0] != pathSpec->name[0] ||
0 != ft_strncmp( (char *)f.name + 1,
(char *)pathSpec->name + 1,
f.name[0] ) )
if ( noErr != FT_ATSFontGetFileReference( id2, &ref2 ) )
break;
if ( noErr != FSCompareFSRefs( ats_font_ref, &ref2 ) )
break;
id2 --;
}
*face_index = ( i - 1 );
*face_index = ats_font_id - ( id2 + 1 );
}
return FT_Err_Ok;
}
FT_EXPORT_DEF( FT_Error )
FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
UInt8* path,
UInt32 maxPathSize,
FT_Long* face_index )
{
FSRef ref;
FT_Error err;
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
if ( FT_Err_Ok != err )
return err;
if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) )
return FT_Err_Unknown_File_Format;
return FT_Err_Ok;
}
/* This function is deprecated because FSSpec is deprecated in Mac OS X */
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index )
{
#if __LP64__
return FT_Err_Unimplemented_Feature;
#else
FSRef ref;
FT_Error err;
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
if ( FT_Err_Ok != err )
return err;
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL,
pathSpec, NULL ) )
return FT_Err_Unknown_File_Format;
return FT_Err_Ok;
#endif
}
static OSErr
FT_FSPathMakeRes( const UInt8* pathname,
short* res )