diff --git a/ChangeLog b/ChangeLog index 149f9f246..b0a125420 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-10-04 suzuki toshiya + + * 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 * src/base/ftobjs.c (ft_lookup_PS_in_sfnt_stream): Remove wrong diff --git a/builds/mac/ftmac.c b/builds/mac/ftmac.c index b2d56b884..9fc1caf3e 100644 --- a/builds/mac/ftmac.c +++ b/builds/mac/ftmac.c @@ -981,8 +981,7 @@ typedef short ResourceIndex; for (;;) { - post_data = Get1Resource( FT_MAKE_TAG( 'P', 'O', 'S', 'T' ), - res_id++ ); + post_data = Get1Resource( TTAG_POST, res_id++ ); if ( post_data == NULL ) break; /* we are done */ @@ -1021,8 +1020,7 @@ typedef short ResourceIndex; for (;;) { - post_data = Get1Resource( FT_MAKE_TAG( 'P', 'O', 'S', 'T' ), - res_id++ ); + post_data = Get1Resource( TTAG_POST, res_id++ ); if ( post_data == NULL ) break; /* we are done */ @@ -1121,7 +1119,7 @@ typedef short ResourceIndex; 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 ) return FT_Err_Invalid_Handle; @@ -1199,8 +1197,7 @@ typedef short ResourceIndex; num_faces_in_res = 0; for ( res_index = 1; ; ++res_index ) { - fond = Get1IndResource( FT_MAKE_TAG( 'F', 'O', 'N', 'D' ), - res_index ); + fond = Get1IndResource( TTAG_FOND, res_index ); if ( ResError() ) break; @@ -1239,8 +1236,7 @@ typedef short ResourceIndex; 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; HLock( fond ); @@ -1350,7 +1346,7 @@ typedef short ResourceIndex; /* LWFN is a (very) specific file format, check for it explicitly */ 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 ); /* Otherwise the file type doesn't matter (there are more than */ diff --git a/include/freetype/tttags.h b/include/freetype/tttags.h index 5a7900820..1c6fe1d5e 100644 --- a/include/freetype/tttags.h +++ b/include/freetype/tttags.h @@ -41,6 +41,7 @@ FT_BEGIN_HEADER #define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) #define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' ) #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_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) #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_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) #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_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) #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_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) #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_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) #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_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) #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_prep FT_MAKE_TAG( 'p', 'r', 'e', '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_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' ) #define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) #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', '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_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) #define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) diff --git a/src/base/ftmac.c b/src/base/ftmac.c index b9d11ae53..995f788de 100644 --- a/src/base/ftmac.c +++ b/src/base/ftmac.c @@ -602,8 +602,7 @@ for (;;) { - post_data = Get1Resource( FT_MAKE_TAG( 'P', 'O', 'S', 'T' ), - res_id++ ); + post_data = Get1Resource( TTAG_POST, res_id++ ); if ( post_data == NULL ) break; /* we are done */ @@ -642,8 +641,7 @@ for (;;) { - post_data = Get1Resource( FT_MAKE_TAG( 'P', 'O', 'S', 'T' ), - res_id++ ); + post_data = Get1Resource( TTAG_POST, res_id++ ); if ( post_data == NULL ) break; /* we are done */ @@ -742,7 +740,7 @@ 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 ) return FT_Err_Invalid_Handle; @@ -818,8 +816,7 @@ num_faces_in_res = 0; for ( res_index = 1; ; ++res_index ) { - fond = Get1IndResource( FT_MAKE_TAG( 'F', 'O', 'N', 'D' ), - res_index ); + fond = Get1IndResource( TTAG_FOND, res_index ); if ( ResError() ) break; @@ -858,7 +855,7 @@ 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; 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 */ 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 ); /* Otherwise the file type doesn't matter (there are more than */ diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 15afd99d0..5ae3b2b2d 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -1346,7 +1346,7 @@ /* version check for 'typ1' (should be ignored?) */ if ( FT_READ_ULONG( tag ) ) return error; - if ( tag != FT_MAKE_TAG( 't', 'y', 'p', '1' ) ) + if ( tag != TTAG_typ1 ) return FT_Err_Unknown_File_Format; if ( FT_READ_USHORT( numTables ) ) @@ -1363,7 +1363,7 @@ FT_READ_ULONG( *offset ) || FT_READ_ULONG( *length ) ) return error; - if ( tag == FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) ) + if ( tag == TTAG_CID ) { pstable_index++; *offset += 22; @@ -1372,7 +1372,7 @@ if ( face_index < 0 ) return FT_Err_Ok; } - else if ( tag == FT_MAKE_TAG( 'T', 'Y', 'P', '1' ) ) + else if ( tag == TTAG_TYP1 ) { pstable_index++; *offset += 24; @@ -1648,7 +1648,7 @@ error = FT_Raccess_Get_DataOffsets( library, stream, map_offset, rdara_pos, - FT_MAKE_TAG( 'P', 'O', 'S', 'T' ), + TTAG_POST, &data_offsets, &count ); if ( !error ) { @@ -1663,7 +1663,7 @@ error = FT_Raccess_Get_DataOffsets( library, stream, map_offset, rdara_pos, - FT_MAKE_TAG( 's', 'f', 'n', 't' ), + TTAG_sfnt, &data_offsets, &count ); if ( !error ) {