From 3605e470c1c846715d2383e84ac7330660ccdf56 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 12 Nov 2004 07:02:45 +0000 Subject: [PATCH] Add new function FT_Get_PS_Font_Private(). * include/freetype/internal/services/svpsinfo.h (PS_GetFontPrivateFunc): New service function. * include/freetype/t1tables.h, src/base/fttype1.c (FT_Get_PS_Font_Private): New function. * src/type1/t1driver.c (t1_ps_get_font_private): New function. (t1_service_ps_info): Updated. * src/cff/cffdrivr.c (cff_service_ps_info): Updated. * src/cid/cidriver.c (cid_service_ps_info): Updated. * src/type42/t42drivr.c (t42_ps_get_font_private): New function. (t42_service_ps_info): Updated. * src/type42/t42parse.c (t42_parse_dict): Remove compiler warning. --- ChangeLog | 22 +++++++++++++ include/freetype/internal/services/svpsinfo.h | 11 +++++-- include/freetype/t1tables.h | 32 +++++++++++++++++++ src/base/fttype1.c | 26 ++++++++++++++- src/cff/cffdrivr.c | 5 +-- src/cid/cidriver.c | 5 +-- src/type1/t1driver.c | 14 ++++++-- src/type42/t42drivr.c | 16 ++++++++-- src/type42/t42parse.c | 6 ++-- 9 files changed, 121 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index d1e2e5072..93090c4f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2004-11-11 Werner Lemberg + + * src/cff/cffdrivr.c (cff_service_ps_info): Updated. + * src/cid/cidriver.c (cid_service_ps_info): Updated. + * src/type42/t42drivr.c (t42_ps_get_font_private): New function. + (t42_service_ps_info): Updated. + + * src/type42/t42parse.c (t42_parse_dict): Remove compiler warning. + +2004-11-11 David Bevan + + Add new function FT_Get_PS_Font_Private(). + + * include/freetype/internal/services/svpsinfo.h + (PS_GetFontPrivateFunc): New service function. + + * include/freetype/t1tables.h, src/base/fttype1.c + (FT_Get_PS_Font_Private): New function. + + * src/type1/t1driver.c (t1_ps_get_font_private): New function. + (t1_service_ps_info): Updated. + 2004-10-13 Werner Lemberg * include/freetype/config/ftstdlib.h: Include `stddef.h'. diff --git a/include/freetype/internal/services/svpsinfo.h b/include/freetype/internal/services/svpsinfo.h index 73c02cdb7..63f5db9c1 100644 --- a/include/freetype/internal/services/svpsinfo.h +++ b/include/freetype/internal/services/svpsinfo.h @@ -4,7 +4,7 @@ /* */ /* The FreeType PostScript info service (specification). */ /* */ -/* Copyright 2003 by */ +/* Copyright 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -36,11 +36,16 @@ FT_BEGIN_HEADER typedef FT_Int (*PS_HasGlyphNamesFunc)( FT_Face face ); + typedef FT_Error + (*PS_GetFontPrivateFunc)( FT_Face face, + PS_PrivateRec* afont_private ); + FT_DEFINE_SERVICE( PsInfo ) { - PS_GetFontInfoFunc ps_get_font_info; - PS_HasGlyphNamesFunc ps_has_glyph_names; + PS_GetFontInfoFunc ps_get_font_info; + PS_HasGlyphNamesFunc ps_has_glyph_names; + PS_GetFontPrivateFunc ps_get_font_private; }; /* */ diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h index 60938aa83..5ae12b826 100644 --- a/include/freetype/t1tables.h +++ b/include/freetype/t1tables.h @@ -387,6 +387,38 @@ FT_BEGIN_HEADER FT_Get_PS_Font_Info( FT_Face face, PS_FontInfoRec *afont_info ); + + /************************************************************************ + * + * @function: + * FT_Get_PS_Font_Private + * + * @description: + * Retrieve the @PS_PrivateRec structure corresponding to a given + * Postscript font. + * + * @input: + * face :: + * Postscript face handle. + * + * @output: + * afont_private :: + * Output private dictionary structure pointer. + * + * @return: + * FreeType error code. 0 means success. + * + * @note: + * The string pointers within the font info structure are owned by + * the face and don't need to be freed by the caller. + * + * If the font's format is not Postscript-based, this function will + * return the FT_Err_Invalid_Argument error code. + */ + FT_EXPORT( FT_Error ) + FT_Get_PS_Font_Private( FT_Face face, + PS_PrivateRec *afont_private ); + /* */ diff --git a/src/base/fttype1.c b/src/base/fttype1.c index 553b84f56..3975584db 100644 --- a/src/base/fttype1.c +++ b/src/base/fttype1.c @@ -4,7 +4,7 @@ /* */ /* FreeType utility file for PS names support (body). */ /* */ -/* Copyright 2002, 2003 by */ +/* Copyright 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -67,4 +67,28 @@ } + /* documentation is in t1tables.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Get_PS_Font_Private( FT_Face face, + PS_PrivateRec* afont_private ) + { + FT_Error error = FT_Err_Invalid_Argument; + + + if ( face ) + { + FT_Service_PsInfo service = NULL; + + + FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO ); + + if ( service && service->ps_get_font_private ) + error = service->ps_get_font_private( face, afont_private ); + } + + return error; + } + + /* END */ diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c index e1f274e84..b84bfdbf9 100644 --- a/src/cff/cffdrivr.c +++ b/src/cff/cffdrivr.c @@ -338,8 +338,9 @@ static const FT_Service_PsInfoRec cff_service_ps_info = { - (PS_GetFontInfoFunc) NULL, /* unsupported with CFF fonts */ - (PS_HasGlyphNamesFunc)cff_ps_has_glyph_names + (PS_GetFontInfoFunc) NULL, /* unsupported with CFF fonts */ + (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names, + (PS_GetFontPrivateFunc)NULL /* unsupported with CFF fonts */ }; diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c index 7d885a818..377835b3c 100644 --- a/src/cid/cidriver.c +++ b/src/cid/cidriver.c @@ -78,8 +78,9 @@ static const FT_Service_PsInfoRec cid_service_ps_info = { - (PS_GetFontInfoFunc) cid_ps_get_font_info, - (PS_HasGlyphNamesFunc)NULL /* unsupported with CID fonts */ + (PS_GetFontInfoFunc) cid_ps_get_font_info, + (PS_HasGlyphNamesFunc) NULL, /* unsupported with CID fonts */ + (PS_GetFontPrivateFunc)NULL /* unsupported */ }; diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c index 652eebc18..dbcdb2a5f 100644 --- a/src/type1/t1driver.c +++ b/src/type1/t1driver.c @@ -160,10 +160,20 @@ } + static FT_Error + t1_ps_get_font_private( FT_Face face, + PS_PrivateRec* afont_private ) + { + *afont_private = ((T1_Face)face)->type1.private_dict; + return 0; + } + + static const FT_Service_PsInfoRec t1_service_ps_info = { - (PS_GetFontInfoFunc) t1_ps_get_font_info, - (PS_HasGlyphNamesFunc)t1_ps_has_glyph_names + (PS_GetFontInfoFunc) t1_ps_get_font_info, + (PS_HasGlyphNamesFunc) t1_ps_has_glyph_names, + (PS_GetFontPrivateFunc)t1_ps_get_font_private, }; diff --git a/src/type42/t42drivr.c b/src/type42/t42drivr.c index 2afe2db84..c87c3f2aa 100644 --- a/src/type42/t42drivr.c +++ b/src/type42/t42drivr.c @@ -139,7 +139,7 @@ PS_FontInfoRec* afont_info ) { *afont_info = ((T42_Face)face)->type1.font_info; - return 0; + return T42_Err_Ok; } @@ -151,10 +151,20 @@ } + static FT_Error + t42_ps_get_font_private( FT_Face face, + PS_PrivateRec* afont_private ) + { + *afont_private = ((T42_Face)face)->type1.private_dict; + return T42_Err_Ok; + } + + static const FT_Service_PsInfoRec t42_service_ps_info = { - (PS_GetFontInfoFunc) t42_ps_get_font_info, - (PS_HasGlyphNamesFunc)t42_ps_has_glyph_names + (PS_GetFontInfoFunc) t42_ps_get_font_info, + (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 ff53a3eb4..30846c07b 100644 --- a/src/type42/t42parse.c +++ b/src/type42/t42parse.c @@ -1053,9 +1053,9 @@ if ( !name ) continue; - if ( cur[0] == name[0] && - len == ft_strlen( (const char *)name ) && - ft_memcmp( cur, name, len ) == 0 ) + if ( cur[0] == name[0] && + len == (FT_PtrDist)ft_strlen( (const char *)name ) && + ft_memcmp( cur, name, len ) == 0 ) { /* we found it -- run the parsing callback! */ parser->root.error = t42_load_keyword( face,