Introduce macros for some MacOS-specific resource tags

This commit is contained in:
Suzuki, Toshiya (鈴木俊哉) 2008-10-04 18:10:28 +00:00
parent 72eb270ac7
commit 21bd516592
5 changed files with 33 additions and 24 deletions

View File

@ -1,3 +1,12 @@
2008-10-04 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
* include/freetype/tttags.h: Add TTAG_CID, TTAG_FOND, TTAG_LWFN,
TTAG_POST, TTAG_sfnt, TTAG_TYP1, TTAG_typ1 to simplify the
repeated calculations of these values in ftobjs.c and ftmac.c.
* src/base/ftobjs.c: Replace all FT_MAKE_TAG by new tags.
* src/base/ftmac.c: Ditto.
* builds/mac/ftmac.c: Ditto.
2008-10-04 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> 2008-10-04 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
* src/base/ftobjs.c (ft_lookup_PS_in_sfnt_stream): Remove wrong * src/base/ftobjs.c (ft_lookup_PS_in_sfnt_stream): Remove wrong

View File

@ -981,8 +981,7 @@ typedef short ResourceIndex;
for (;;) for (;;)
{ {
post_data = Get1Resource( FT_MAKE_TAG( 'P', 'O', 'S', 'T' ), post_data = Get1Resource( TTAG_POST, res_id++ );
res_id++ );
if ( post_data == NULL ) if ( post_data == NULL )
break; /* we are done */ break; /* we are done */
@ -1021,8 +1020,7 @@ typedef short ResourceIndex;
for (;;) for (;;)
{ {
post_data = Get1Resource( FT_MAKE_TAG( 'P', 'O', 'S', 'T' ), post_data = Get1Resource( TTAG_POST, res_id++ );
res_id++ );
if ( post_data == NULL ) if ( post_data == NULL )
break; /* we are done */ break; /* we are done */
@ -1121,7 +1119,7 @@ typedef short ResourceIndex;
int is_cff, is_sfnt_ps; int is_cff, is_sfnt_ps;
sfnt = GetResource( FT_MAKE_TAG( 's', 'f', 'n', 't' ), sfnt_id ); sfnt = GetResource( TTAG_sfnt, sfnt_id );
if ( sfnt == NULL ) if ( sfnt == NULL )
return FT_Err_Invalid_Handle; return FT_Err_Invalid_Handle;
@ -1199,8 +1197,7 @@ typedef short ResourceIndex;
num_faces_in_res = 0; num_faces_in_res = 0;
for ( res_index = 1; ; ++res_index ) for ( res_index = 1; ; ++res_index )
{ {
fond = Get1IndResource( FT_MAKE_TAG( 'F', 'O', 'N', 'D' ), fond = Get1IndResource( TTAG_FOND, res_index );
res_index );
if ( ResError() ) if ( ResError() )
break; break;
@ -1239,8 +1236,7 @@ typedef short ResourceIndex;
GetResInfo( fond, &fond_id, &fond_type, fond_name ); GetResInfo( fond, &fond_id, &fond_type, fond_name );
if ( ResError() != noErr || if ( ResError() != noErr || fond_type != TTAG_FOND )
fond_type != FT_MAKE_TAG( 'F', 'O', 'N', 'D' ) )
return FT_Err_Invalid_File_Format; return FT_Err_Invalid_File_Format;
HLock( fond ); HLock( fond );
@ -1350,7 +1346,7 @@ typedef short ResourceIndex;
/* LWFN is a (very) specific file format, check for it explicitly */ /* LWFN is a (very) specific file format, check for it explicitly */
file_type = get_file_type_from_path( pathname ); file_type = get_file_type_from_path( pathname );
if ( file_type == FT_MAKE_TAG( 'L', 'W', 'F', 'N' ) ) if ( file_type == TTAG_LWFN )
return FT_New_Face_From_LWFN( library, pathname, face_index, aface ); return FT_New_Face_From_LWFN( library, pathname, face_index, aface );
/* Otherwise the file type doesn't matter (there are more than */ /* Otherwise the file type doesn't matter (there are more than */

View File

@ -41,6 +41,7 @@ FT_BEGIN_HEADER
#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) #define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' )
#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' ) #define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' )
#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) #define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' )
#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' )
#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) #define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' )
#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) #define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' )
#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) #define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' )
@ -49,6 +50,7 @@ FT_BEGIN_HEADER
#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' ) #define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' )
#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) #define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' )
#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' ) #define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' )
#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' )
#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' ) #define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' )
#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) #define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' )
#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' ) #define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' )
@ -67,6 +69,7 @@ FT_BEGIN_HEADER
#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' ) #define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' )
#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) #define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' )
#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' ) #define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' )
#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' )
#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' ) #define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' )
#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) #define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' )
#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' ) #define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' )
@ -79,14 +82,18 @@ FT_BEGIN_HEADER
#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) #define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' )
#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) #define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' )
#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' ) #define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' )
#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' )
#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' ) #define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' )
#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' ) #define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' )
#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' ) #define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' )
#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' )
#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' ) #define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' )
#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' ) #define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' )
#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) #define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' )
#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' ) #define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' )
#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' ) #define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' )
#define TTAG_ttcf FT_MAKE_TAG( 'T', 'Y', 'P', '1' )
#define TTAG_ttcf FT_MAKE_TAG( 't', 'y', 'p', '1' )
#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' ) #define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' )
#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) #define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' )
#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) #define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' )

View File

@ -602,8 +602,7 @@
for (;;) for (;;)
{ {
post_data = Get1Resource( FT_MAKE_TAG( 'P', 'O', 'S', 'T' ), post_data = Get1Resource( TTAG_POST, res_id++ );
res_id++ );
if ( post_data == NULL ) if ( post_data == NULL )
break; /* we are done */ break; /* we are done */
@ -642,8 +641,7 @@
for (;;) for (;;)
{ {
post_data = Get1Resource( FT_MAKE_TAG( 'P', 'O', 'S', 'T' ), post_data = Get1Resource( TTAG_POST, res_id++ );
res_id++ );
if ( post_data == NULL ) if ( post_data == NULL )
break; /* we are done */ break; /* we are done */
@ -742,7 +740,7 @@
int is_cff, is_sfnt_ps; int is_cff, is_sfnt_ps;
sfnt = GetResource( FT_MAKE_TAG( 's', 'f', 'n', 't' ), sfnt_id ); sfnt = GetResource( TTAG_sfnt, sfnt_id );
if ( sfnt == NULL ) if ( sfnt == NULL )
return FT_Err_Invalid_Handle; return FT_Err_Invalid_Handle;
@ -818,8 +816,7 @@
num_faces_in_res = 0; num_faces_in_res = 0;
for ( res_index = 1; ; ++res_index ) for ( res_index = 1; ; ++res_index )
{ {
fond = Get1IndResource( FT_MAKE_TAG( 'F', 'O', 'N', 'D' ), fond = Get1IndResource( TTAG_FOND, res_index );
res_index );
if ( ResError() ) if ( ResError() )
break; break;
@ -858,7 +855,7 @@
GetResInfo( fond, &fond_id, &fond_type, fond_name ); GetResInfo( fond, &fond_id, &fond_type, fond_name );
if ( ResError() != noErr || fond_type != FT_MAKE_TAG( 'F', 'O', 'N', 'D' ) ) if ( ResError() != noErr || fond_type != TTAG_FOND )
return FT_Err_Invalid_File_Format; return FT_Err_Invalid_File_Format;
parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index ); parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
@ -925,7 +922,7 @@
/* LWFN is a (very) specific file format, check for it explicitly */ /* LWFN is a (very) specific file format, check for it explicitly */
file_type = get_file_type_from_path( pathname ); file_type = get_file_type_from_path( pathname );
if ( file_type == FT_MAKE_TAG( 'L', 'W', 'F', 'N' ) ) if ( file_type == TTAG_LWFN )
return FT_New_Face_From_LWFN( library, pathname, face_index, aface ); return FT_New_Face_From_LWFN( library, pathname, face_index, aface );
/* Otherwise the file type doesn't matter (there are more than */ /* Otherwise the file type doesn't matter (there are more than */

View File

@ -1346,7 +1346,7 @@
/* version check for 'typ1' (should be ignored?) */ /* version check for 'typ1' (should be ignored?) */
if ( FT_READ_ULONG( tag ) ) if ( FT_READ_ULONG( tag ) )
return error; return error;
if ( tag != FT_MAKE_TAG( 't', 'y', 'p', '1' ) ) if ( tag != TTAG_typ1 )
return FT_Err_Unknown_File_Format; return FT_Err_Unknown_File_Format;
if ( FT_READ_USHORT( numTables ) ) if ( FT_READ_USHORT( numTables ) )
@ -1363,7 +1363,7 @@
FT_READ_ULONG( *offset ) || FT_READ_ULONG( *length ) ) FT_READ_ULONG( *offset ) || FT_READ_ULONG( *length ) )
return error; return error;
if ( tag == FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) ) if ( tag == TTAG_CID )
{ {
pstable_index++; pstable_index++;
*offset += 22; *offset += 22;
@ -1372,7 +1372,7 @@
if ( face_index < 0 ) if ( face_index < 0 )
return FT_Err_Ok; return FT_Err_Ok;
} }
else if ( tag == FT_MAKE_TAG( 'T', 'Y', 'P', '1' ) ) else if ( tag == TTAG_TYP1 )
{ {
pstable_index++; pstable_index++;
*offset += 24; *offset += 24;
@ -1648,7 +1648,7 @@
error = FT_Raccess_Get_DataOffsets( library, stream, error = FT_Raccess_Get_DataOffsets( library, stream,
map_offset, rdara_pos, map_offset, rdara_pos,
FT_MAKE_TAG( 'P', 'O', 'S', 'T' ), TTAG_POST,
&data_offsets, &count ); &data_offsets, &count );
if ( !error ) if ( !error )
{ {
@ -1663,7 +1663,7 @@
error = FT_Raccess_Get_DataOffsets( library, stream, error = FT_Raccess_Get_DataOffsets( library, stream,
map_offset, rdara_pos, map_offset, rdara_pos,
FT_MAKE_TAG( 's', 'f', 'n', 't' ), TTAG_sfnt,
&data_offsets, &count ); &data_offsets, &count );
if ( !error ) if ( !error )
{ {