70#include FT_TRUETYPE_TAGS_H
71#include FT_INTERNAL_STREAM_H
80#if !HAVE_ANSI_OS_INLINE
82#define OS_INLINE static __inline__
89#ifndef HAVE_TYPE_RESOURCE_INDEX
90#if !defined( MAC_OS_X_VERSION_10_5 ) || \
91 ( MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 )
92#define HAVE_TYPE_RESOURCE_INDEX 0
94#define HAVE_TYPE_RESOURCE_INDEX 1
98#if ( HAVE_TYPE_RESOURCE_INDEX == 0 )
99 typedef short ResourceIndex;
102#include <CoreServices/CoreServices.h>
103#include <ApplicationServices/ApplicationServices.h>
104#include <sys/syslimits.h>
107#define FT_DEPRECATED_ATTRIBUTE
111#ifndef kATSOptionFlagsUnRestrictedScope
112#define kATSOptionFlagsUnRestrictedScope kATSOptionFlagsDefault
134 return FT_THROW( Unimplemented_Feature );
144 FT_ATSFontGetFileReference( ATSFontRef ats_font_id,
145 FSRef* ats_font_ref )
147#if defined( MAC_OS_X_VERSION_10_5 ) && \
148 ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
152 err = ATSFontGetFileReference( ats_font_id, ats_font_ref );
166 err = ATSFontGetFileSpecification( ats_font_id, &spec );
168 err = FSpMakeFSRef( &spec, ats_font_ref );
176 FT_GetFileRef_From_Mac_ATS_Name(
const char*
fontName,
180 CFStringRef cf_fontName;
181 ATSFontRef ats_font_id;
186 cf_fontName = CFStringCreateWithCString(
NULL,
fontName,
187 kCFStringEncodingMacRoman );
188 ats_font_id = ATSFontFindFromName( cf_fontName,
189 kATSOptionFlagsUnRestrictedScope );
190 CFRelease( cf_fontName );
192 if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
193 return FT_THROW( Unknown_File_Format );
195 if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) )
196 return FT_THROW( Unknown_File_Format );
201 ATSFontRef id2 = ats_font_id - 1;
207 if ( noErr != FT_ATSFontGetFileReference( id2, &ref2 ) )
209 if ( noErr != FSCompareFSRefs( ats_font_ref, &ref2 ) )
214 *face_index = ats_font_id - ( id2 + 1 );
234 err = FT_GetFileRef_From_Mac_ATS_Name(
fontName, &
ref, face_index );
238 if ( noErr != FSRefMakePath( &
ref,
path, maxPathSize ) )
239 return FT_THROW( Unknown_File_Format );
251#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
252 ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
257 return FT_THROW( Unimplemented_Feature );
264 return FT_THROW( Invalid_Argument );
266 err = FT_GetFileRef_From_Mac_ATS_Name(
fontName, &
ref, face_index );
270 if ( noErr != FSGetCatalogInfo( &
ref, kFSCatInfoNone,
NULL,
NULL,
272 return FT_THROW( Unknown_File_Format );
288 return FT_THROW( Cannot_Open_Resource );
296 *
res = FSOpenResFile( &
ref, fsRdPerm );
314 if ( noErr != FSGetCatalogInfo( &
ref, kFSCatInfoFinderInfo, &
info,
318 return ((FInfo *)(
info.finderInfo))->fdType;
324 create_lwfn_name(
char* ps_name,
325 Str255 lwfn_file_name )
332 lwfn_file_name[0] = 0;
354 count_faces_sfnt(
char* fond_data )
359 return EndianS16_BtoN( *( (
short*)( fond_data +
360 sizeof ( FamRec ) ) ) ) + 1;
365 count_faces_scalable(
char* fond_data )
368 short i,
face, face_all;
371 face_all = EndianS16_BtoN( *( (
short *)( fond_data +
372 sizeof ( FamRec ) ) ) ) + 1;
373 assoc = (AsscEntry*)( fond_data +
sizeof ( FamRec ) + 2 );
376 for (
i = 0;
i < face_all;
i++ )
378 if ( 0 == EndianS16_BtoN( assoc[
i].fontSize ) )
394 parse_fond(
char* fond_data,
397 Str255 lwfn_file_name,
401 AsscEntry* base_assoc;
407 lwfn_file_name[0] = 0;
409 fond = (FamRec*)fond_data;
410 assoc = (AsscEntry*)( fond_data +
sizeof ( FamRec ) + 2 );
414 if ( 47 < face_index )
418 if ( face_index < count_faces_sfnt( fond_data ) )
424 if ( EndianS16_BtoN( assoc->fontSize ) == 0 )
427 *sfnt_id = EndianS16_BtoN( assoc->fontID );
429 else if ( base_assoc->fontSize == 0 )
432 *sfnt_id = EndianS16_BtoN( base_assoc->fontID );
436 if ( EndianS32_BtoN( fond->ffStylOff ) )
438 unsigned char*
p = (
unsigned char*)fond_data;
440 unsigned short string_count;
442 unsigned char*
names[64];
446 p += EndianS32_BtoN( fond->ffStylOff );
448 p +=
sizeof ( StyleTable );
449 string_count = EndianS16_BtoN( *(
short*)(
p) );
450 string_count =
FT_MIN( 64, string_count );
453 for (
i = 0;
i < string_count;
i++ )
464 if ( ps_name_len != 0 )
467 ps_name[ps_name_len] = 0;
469 if (
style->indexes[face_index] > 1 &&
470 style->indexes[face_index] <= string_count )
472 unsigned char* suffixes =
names[
style->indexes[face_index] - 1];
475 for (
i = 1;
i <= suffixes[0];
i++ )
478 size_t j = suffixes[
i] - 1;
486 if ( s_len != 0 && ps_name_len + s_len <
sizeof ( ps_name ) )
488 ft_memcpy( ps_name + ps_name_len,
s + 1, s_len );
489 ps_name_len += s_len;
490 ps_name[ps_name_len] = 0;
497 create_lwfn_name( ps_name, lwfn_file_name );
503 lookup_lwfn_by_fond(
const UInt8* path_fond,
504 ConstStr255Param base_lwfn,
515 if ( noErr != FSPathMakeRef( path_fond, &
ref,
FALSE ) )
516 return FT_THROW( Invalid_Argument );
518 if ( noErr != FSGetCatalogInfo( &
ref, kFSCatInfoNone,
520 return FT_THROW( Invalid_Argument );
522 if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) )
523 return FT_THROW( Invalid_Argument );
525 if (
ft_strlen( (
char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
526 return FT_THROW( Invalid_Argument );
530 dirname_len =
ft_strlen( (
char *)path_lwfn );
531 ft_strcat( (
char *)path_lwfn, (
char *)base_lwfn + 1 );
532 path_lwfn[dirname_len + base_lwfn[0]] =
'\0';
534 if ( noErr != FSPathMakeRef( path_lwfn, &
ref,
FALSE ) )
535 return FT_THROW( Cannot_Open_Resource );
537 if ( noErr != FSGetCatalogInfo( &
ref, kFSCatInfoNone,
539 return FT_THROW( Cannot_Open_Resource );
550 short have_sfnt, have_lwfn;
551 Str255 lwfn_file_name;
557 have_sfnt = have_lwfn = 0;
559 parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, 0 );
561 if ( lwfn_file_name[0] )
563 err = lookup_lwfn_by_fond(
pathname, lwfn_file_name,
569 if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
572 num_faces = count_faces_scalable( *fond );
596 char code, last_code;
612 code = (*post_data)[0];
614 if (
code != last_code )
626 if ( FT_MAC_RFORK_MAX_LEN < total_size )
632 old_total_size = total_size;
652 code = (*post_data)[0];
654 if (
code != last_code )
656 if ( last_code != -1 )
672 else if (
code == 2 )
685 pfb_chunk_size += post_size;
713 return FT_THROW( Cannot_Open_Resource );
722 return open_face_from_buffer(
library,
743 int is_cff, is_sfnt_ps;
753 if ( FT_MAC_RFORK_MAX_LEN < sfnt_size )
758 ReleaseResource(
sfnt );
763 ReleaseResource(
sfnt );
765 is_cff = sfnt_size > 4 && !
ft_memcmp( sfnt_data,
"OTTO", 4 );
766 is_sfnt_ps = sfnt_size > 4 && !
ft_memcmp( sfnt_data,
"typ1", 4 );
777 if ( !open_face_PS_from_sfnt_stream(
library,
796 is_cff ?
"cff" :
"truetype",
811 ResFileRefNum res_ref;
812 ResourceIndex res_index;
814 short num_faces_in_res;
817 if ( noErr != FT_FSPathMakeRes(
pathname, &res_ref ) )
818 return FT_THROW( Cannot_Open_Resource );
820 UseResFile( res_ref );
822 return FT_THROW( Cannot_Open_Resource );
824 num_faces_in_res = 0;
825 for ( res_index = 1; ; res_index++ )
827 short num_faces_in_fond;
830 fond = Get1IndResource(
TTAG_FOND, res_index );
834 num_faces_in_fond = count_faces( fond,
pathname );
835 num_faces_in_res += num_faces_in_fond;
837 if ( 0 <= face_index && face_index < num_faces_in_fond &&
error )
840 face_index -= num_faces_in_fond;
843 CloseResFile( res_ref );
844 if ( !
error && aface && *aface )
845 (*aface)->num_faces = num_faces_in_res;
858 short have_sfnt, have_lwfn = 0;
859 ResID sfnt_id, fond_id;
862 Str255 lwfn_file_name;
870 GetResInfo( fond, &fond_id, &fond_type, fond_name );
871 if ( ResError() != noErr || fond_type !=
TTAG_FOND )
872 return FT_THROW( Invalid_File_Format );
874 parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
876 if ( lwfn_file_name[0] )
881 res = HomeResFile( fond );
882 if ( noErr != ResError() )
883 goto found_no_lwfn_file;
890 err = FSGetForkCBInfo(
res, kFSInvalidVolumeRefNum,
893 goto found_no_lwfn_file;
895 err = FSRefMakePath( &
ref, path_fond,
sizeof ( path_fond ) );
897 goto found_no_lwfn_file;
899 error = lookup_lwfn_by_fond( path_fond, lwfn_file_name,
900 path_lwfn,
sizeof ( path_lwfn ) );
906 if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
915 if ( have_sfnt &&
error )
980 return FT_THROW( Invalid_Argument );
987 if (
error || *aface )
1026 return FT_THROW( Invalid_Argument );
1033 if (
error || *aface )
1059#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
1060 ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
1066 return FT_THROW( Unimplemented_Feature );
1073 if ( !spec || FSpMakeFSRef( spec, &
ref ) != noErr )
1074 return FT_THROW( Invalid_Argument );
static LPVOID GetResource(LPCWSTR FontName, LPDWORD Size)
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
static unsigned char buff[32768]
FT_New_Face(FT_Library library, const char *filepathname, FT_Long face_index, FT_Face *aface)
FT_Open_Face(FT_Library library, const FT_Open_Args *args, FT_Long face_index, FT_Face *aface)
FT_GetFile_From_Mac_ATS_Name(const char *fontName, FSSpec *pathSpec, FT_Long *face_index) FT_DEPRECATED_ATTRIBUTE
FT_GetFile_From_Mac_Name(const char *fontName, FSSpec *pathSpec, FT_Long *face_index) FT_DEPRECATED_ATTRIBUTE
FT_GetFilePath_From_Mac_ATS_Name(const char *fontName, UInt8 *path, UInt32 maxPathSize, FT_Long *face_index) FT_DEPRECATED_ATTRIBUTE
FT_New_Face_From_FSSpec(FT_Library library, const FSSpec *spec, FT_Long face_index, FT_Face *aface) FT_DEPRECATED_ATTRIBUTE
FT_New_Face_From_FSRef(FT_Library library, const FSRef *ref, FT_Long face_index, FT_Face *aface) FT_DEPRECATED_ATTRIBUTE
FT_New_Face_From_FOND(FT_Library library, Handle fond, FT_Long face_index, FT_Face *aface) FT_DEPRECATED_ATTRIBUTE
#define FT_ALLOC(ptr, size)
FT_Stream_Close(FT_Stream stream)
FT_Stream_OpenMemory(FT_Stream stream, const FT_Byte *base, FT_ULong size)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
GLuint GLuint GLsizei count
GLdouble GLdouble GLdouble GLdouble q
GLenum GLuint GLint GLenum face
GLenum const GLvoid * fontName
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
static char memory[1024 *256]
static const CHAR post_data[]
FD_TYPE file_type(FDSC **curr, char *fixed)