From 01ca4da20375cf64f7e6b8c22c038042cf849502 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 3 Mar 2009 13:28:59 +0000 Subject: [PATCH] Remove ABI-breaking field in public PS_InfoFontRec definition. Instead, we define a new internal PS_FontExtraRec structure to hold the additionnal field, then place it in various internal positions of the corresponding FT_Face derived objects. --- ChangeLog | 24 +++++++++++++++ include/freetype/internal/psaux.h | 1 + include/freetype/internal/services/svpsinfo.h | 5 ++++ include/freetype/internal/t1types.h | 13 +++++++++ include/freetype/t1tables.h | 4 --- src/base/ftfstype.c | 29 +++++++++++++++---- src/cff/cffdrivr.c | 1 + src/cid/cidload.c | 4 +++ src/cid/cidriver.c | 8 +++++ src/cid/cidtoken.h | 6 ++++ src/type1/t1driver.c | 8 +++++ src/type1/t1load.c | 6 ++++ src/type1/t1tokens.h | 6 ++++ src/type42/t42drivr.c | 8 +++++ src/type42/t42parse.c | 6 ++++ 15 files changed, 119 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4efb2e48..b14357b14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2009-03-03 David Turner + + Remove ABI-breaking field in public PS_InfoFontRec definition. + Instead, we define a new internal PS_FontExtraRec structure to + hold the additionnal field, then place it in various internal + positions of the corresponding FT_Face derived objects. + + * include/freetype/t1tables.h (PS_FontInfoRec): Remove the + `fs_type' field from the public structure. + + * include/freetype/internal/psaux.h (T1_FieldLocation), + include/freetype/internal/t1types.h (T1_FontRec, CID_FaceRec), + src/type1/t1load.c, src/type1/t1tokens.h, + src/cid/cidload.c, src/cid/cidtoken.h, + src/type42/t42parse.c: modify the various font parsers to store + the `fs_type' field in a different places, instead of the public + PS_FontInfoRec. + + * include/freetype/internal/services/svpsinfo.h (PsInfo service), + src/base/ftfstype.c (FT_Get_FSType_Flags), src/cff/cffdrivr.c, + src/cid/cidriver.c, src/type1/t1driver.c, src/type42/t42drivr.c: + Modify the PsInfo service to add a GetExtra function, use it in + FT_Get_FSType_Flags() and modify the drivers accordingly. + 2009-03-02 Alexey Kryukov Fix handling of EBDT formats 8 and 9. diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h index 832d63df3..7fb4c9916 100644 --- a/include/freetype/internal/psaux.h +++ b/include/freetype/internal/psaux.h @@ -197,6 +197,7 @@ FT_BEGIN_HEADER { T1_FIELD_LOCATION_CID_INFO, T1_FIELD_LOCATION_FONT_DICT, + T1_FIELD_LOCATION_FONT_EXTRA, T1_FIELD_LOCATION_FONT_INFO, T1_FIELD_LOCATION_PRIVATE, T1_FIELD_LOCATION_BBOX, diff --git a/include/freetype/internal/services/svpsinfo.h b/include/freetype/internal/services/svpsinfo.h index 63f5db9c1..821776989 100644 --- a/include/freetype/internal/services/svpsinfo.h +++ b/include/freetype/internal/services/svpsinfo.h @@ -33,6 +33,10 @@ FT_BEGIN_HEADER (*PS_GetFontInfoFunc)( FT_Face face, PS_FontInfoRec* afont_info ); + typedef FT_Error + (*PS_GetFontExtraFunc)( FT_Face face, + PS_FontExtraRec* afont_extra ); + typedef FT_Int (*PS_HasGlyphNamesFunc)( FT_Face face ); @@ -44,6 +48,7 @@ FT_BEGIN_HEADER FT_DEFINE_SERVICE( PsInfo ) { PS_GetFontInfoFunc ps_get_font_info; + PS_GetFontExtraFunc ps_get_font_extra; PS_HasGlyphNamesFunc ps_has_glyph_names; PS_GetFontPrivateFunc ps_get_font_private; }; diff --git a/include/freetype/internal/t1types.h b/include/freetype/internal/t1types.h index 4b05fa32c..fdf766dec 100644 --- a/include/freetype/internal/t1types.h +++ b/include/freetype/internal/t1types.h @@ -87,9 +87,21 @@ FT_BEGIN_HEADER } T1_EncodingType; + /* used to hold extra data of PS_FontInfoRec that + * cannot be stored in the publicly defined structure. + * + * Note these can't be blended with multiple-masters. + */ + typedef struct PS_FontExtraRec_ + { + FT_UShort fs_type; + + } PS_FontExtraRec; + typedef struct T1_FontRec_ { PS_FontInfoRec font_info; /* font info dictionary */ + PS_FontExtraRec font_extra; /* font info extra fields */ PS_PrivateRec private_dict; /* private dictionary */ FT_String* font_name; /* top-level dictionary */ @@ -231,6 +243,7 @@ FT_BEGIN_HEADER void* psnames; void* psaux; CID_FaceInfoRec cid; + PS_FontExtraRec font_extra; #if 0 void* afm_data; #endif diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h index 12832e716..5e2a3934c 100644 --- a/include/freetype/t1tables.h +++ b/include/freetype/t1tables.h @@ -78,10 +78,6 @@ FT_BEGIN_HEADER FT_Short underline_position; FT_UShort underline_thickness; - /* since 2.3.8 */ - - FT_UShort fs_type; - } PS_FontInfoRec; diff --git a/src/base/ftfstype.c b/src/base/ftfstype.c index 0d4e53307..7060ac914 100644 --- a/src/base/ftfstype.c +++ b/src/base/ftfstype.c @@ -18,6 +18,8 @@ #include #include FT_TYPE1_TABLES_H #include FT_TRUETYPE_TABLES_H +#include FT_INTERNAL_SERVICE_H +#include FT_SERVICE_POSTSCRIPT_INFO_H /* documentation is in freetype.h */ @@ -25,16 +27,31 @@ FT_EXPORT_DEF( FT_UShort ) FT_Get_FSType_Flags( FT_Face face ) { - PS_FontInfoRec font_info; - TT_OS2* os2; + TT_OS2* os2; + /* first, try to get the fs_type directly from the font */ + if ( face ) + { + FT_Service_PsInfo service = NULL; + + + FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO ); + + if ( service && service->ps_get_font_extra ) + { + PS_FontExtraRec extra; + + if ( !service->ps_get_font_extra( face, &extra ) && + extra.fs_type != 0 ) + { + return extra.fs_type; + } + } + } + /* look at FSType before fsType for Type42 */ - if ( !FT_Get_PS_Font_Info( face, &font_info ) && - font_info.fs_type != 0 ) - return font_info.fs_type; - if ( ( os2 = (TT_OS2*)FT_Get_Sfnt_Table( face, ft_sfnt_os2 ) ) != NULL && os2->version != 0xFFFFU ) return os2->fsType; diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c index a7f433acd..286c0b332 100644 --- a/src/cff/cffdrivr.c +++ b/src/cff/cffdrivr.c @@ -380,6 +380,7 @@ static const FT_Service_PsInfoRec cff_service_ps_info = { (PS_GetFontInfoFunc) cff_ps_get_font_info, + (PS_GetFontExtraFunc) NULL, (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names, (PS_GetFontPrivateFunc)NULL /* unsupported with CFF fonts */ }; diff --git a/src/cid/cidload.c b/src/cid/cidload.c index ec24710d5..8541d06a6 100644 --- a/src/cid/cidload.c +++ b/src/cid/cidload.c @@ -97,6 +97,10 @@ object = (FT_Byte*)&cid->font_info; break; + case T1_FIELD_LOCATION_FONT_EXTRA: + object = (FT_Byte*)&face->font_extra; + break; + case T1_FIELD_LOCATION_BBOX: object = (FT_Byte*)&cid->font_bbox; break; diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c index 85ee6cf19..42bd298db 100644 --- a/src/cid/cidriver.c +++ b/src/cid/cidriver.c @@ -77,10 +77,18 @@ return 0; } + static FT_Error + cid_ps_get_font_extra( FT_Face face, + PS_FontExtraRec* afont_extra ) + { + *afont_extra = ((CID_Face)face)->font_extra; + return 0; + } static const FT_Service_PsInfoRec cid_service_ps_info = { (PS_GetFontInfoFunc) cid_ps_get_font_info, + (PS_GetFontExtraFunc) cid_ps_get_font_extra, (PS_HasGlyphNamesFunc) NULL, /* unsupported with CID fonts */ (PS_GetFontPrivateFunc)NULL /* unsupported */ }; diff --git a/src/cid/cidtoken.h b/src/cid/cidtoken.h index 0795f0509..f73432252 100644 --- a/src/cid/cidtoken.h +++ b/src/cid/cidtoken.h @@ -48,6 +48,12 @@ T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch, 0 ) T1_FIELD_NUM ( "UnderlinePosition", underline_position, 0 ) T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, 0 ) + +#undef FT_STRUCTURE +#define FT_STRUCTURE PS_FontExtraRec +#undef T1CODE +#define T1CODE T1_FIELD_LOCATION_FONT_EXTRA + T1_FIELD_NUM ( "FSType", fs_type, 0 ) diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c index 42302e578..c22d8df84 100644 --- a/src/type1/t1driver.c +++ b/src/type1/t1driver.c @@ -138,6 +138,13 @@ return 0; } + static FT_Error + t1_ps_get_font_extra( FT_Face face, + PS_FontExtraRec* afont_extra ) + { + *afont_extra = ((T1_Face)face)->type1.font_extra; + return 0; + } static FT_Int t1_ps_has_glyph_names( FT_Face face ) @@ -159,6 +166,7 @@ static const FT_Service_PsInfoRec t1_service_ps_info = { (PS_GetFontInfoFunc) t1_ps_get_font_info, + (PS_GetFontExtraFunc) t1_ps_get_font_extra, (PS_HasGlyphNamesFunc) t1_ps_has_glyph_names, (PS_GetFontPrivateFunc)t1_ps_get_font_private, }; diff --git a/src/type1/t1load.c b/src/type1/t1load.c index 3afbeb844..50a0b2d6d 100644 --- a/src/type1/t1load.c +++ b/src/type1/t1load.c @@ -948,6 +948,12 @@ } break; + case T1_FIELD_LOCATION_FONT_EXTRA: + dummy_object = &face->type1.font_extra; + objects = &dummy_object; + max_objects = 0; + break; + case T1_FIELD_LOCATION_PRIVATE: dummy_object = &face->type1.private_dict; objects = &dummy_object; diff --git a/src/type1/t1tokens.h b/src/type1/t1tokens.h index db08e045c..bfbd0ef86 100644 --- a/src/type1/t1tokens.h +++ b/src/type1/t1tokens.h @@ -41,6 +41,12 @@ T1_FIELD_DICT_FONTDICT ) T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, T1_FIELD_DICT_FONTDICT ) + +#undef FT_STRUCTURE +#define FT_STRUCTURE PS_FontExtraRec +#undef T1CODE +#define T1CODE T1_FIELD_LOCATION_FONT_EXTRA + T1_FIELD_NUM ( "FSType", fs_type, T1_FIELD_DICT_FONTDICT ) diff --git a/src/type42/t42drivr.c b/src/type42/t42drivr.c index a6e4cf4b6..92b40e1e6 100644 --- a/src/type42/t42drivr.c +++ b/src/type42/t42drivr.c @@ -127,6 +127,13 @@ return T42_Err_Ok; } + static FT_Error + t42_ps_get_font_extra( FT_Face face, + PS_FontExtraRec* afont_extra ) + { + *afont_extra = ((T42_Face)face)->type1.font_extra; + return T42_Err_Ok; + } static FT_Int t42_ps_has_glyph_names( FT_Face face ) @@ -148,6 +155,7 @@ static const FT_Service_PsInfoRec t42_service_ps_info = { (PS_GetFontInfoFunc) t42_ps_get_font_info, + (PS_GetFontExtraFunc) t42_ps_get_font_extra, (PS_HasGlyphNamesFunc) t42_ps_has_glyph_names, (PS_GetFontPrivateFunc)t42_ps_get_font_private }; diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c index b5e257dbb..88d7a442a 100644 --- a/src/type42/t42parse.c +++ b/src/type42/t42parse.c @@ -68,6 +68,12 @@ T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch, 0 ) T1_FIELD_NUM ( "UnderlinePosition", underline_position, 0 ) T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, 0 ) + +#undef FT_STRUCTURE +#define FT_STRUCTURE PS_FontExtraRec +#undef T1CODE +#define T1CODE T1_FIELD_LOCATION_FONT_EXTRA + T1_FIELD_NUM ( "FSType", fs_type, 0 ) #undef FT_STRUCTURE