From ac250b228afab02fa213362fb92e2a3b038b0af3 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sat, 13 Jan 2007 14:01:36 +0000 Subject: [PATCH] Add FT_Get_PS_Font_Info interface to CFF driver. * src/cff/cfftypes.h: Include FT_TYPE1_TABLES_H. (CFF_FontRec): Add `font_info' field. * src/cff/cffload.c: Include FT_TYPE1_TABLES_H. (cff_font_done): Free font->font_info if necessary. * src/cff/cffdrvr.c (cff_ps_get_font_info): New function. (cff_service_ps_info): Register cff_ps_get_font_info. --- ChangeLog | 13 ++++++++++++ src/cff/cffdrivr.c | 52 ++++++++++++++++++++++++++++++++++++++++++++-- src/cff/cffload.c | 11 ++++++++++ src/cff/cfftypes.h | 4 ++++ 4 files changed, 78 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b4c83d93f..a701fc899 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-01-13 Derek Clegg + + Add FT_Get_PS_Font_Info interface to CFF driver. + + * src/cff/cfftypes.h: Include FT_TYPE1_TABLES_H. + (CFF_FontRec): Add `font_info' field. + + * src/cff/cffload.c: Include FT_TYPE1_TABLES_H. + (cff_font_done): Free font->font_info if necessary. + + * src/cff/cffdrvr.c (cff_ps_get_font_info): New function. + (cff_service_ps_info): Register cff_ps_get_font_info. + 2007-01-13 Werner Lemberg * src/base/ftoutln.c (FT_Outline_Get_Orientation): Fix compilation diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c index e90e2b04e..7728cf7fa 100644 --- a/src/cff/cffdrivr.c +++ b/src/cff/cffdrivr.c @@ -4,7 +4,7 @@ /* */ /* OpenType font driver implementation (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -302,9 +302,57 @@ } + static FT_Error + cff_ps_get_font_info( CFF_Face face, + PS_FontInfoRec* afont_info ) + { + CFF_Font cff = (CFF_Font)face->extra.data; + FT_Error error = FT_Err_Ok; + + + if ( cff && cff->font_info == NULL ) + { + CFF_FontRecDict dict = &cff->top_font.font_dict; + PS_FontInfoRec *font_info; + FT_Memory memory = face->root.memory; + + + if ( FT_ALLOC( font_info, sizeof ( *font_info ) ) ) + goto Fail; + + font_info->version = cff_index_get_sid_string( &cff->string_index, + dict->version, + cff->psnames ); + font_info->notice = cff_index_get_sid_string( &cff->string_index, + dict->notice, + cff->psnames ); + font_info->full_name = cff_index_get_sid_string( &cff->string_index, + dict->full_name, + cff->psnames ); + font_info->family_name = cff_index_get_sid_string( &cff->string_index, + dict->family_name, + cff->psnames ); + font_info->weight = cff_index_get_sid_string( &cff->string_index, + dict->weight, + cff->psnames ); + font_info->italic_angle = dict->italic_angle; + font_info->is_fixed_pitch = dict->is_fixed_pitch; + font_info->underline_position = dict->underline_position; + font_info->underline_thickness = dict->underline_thickness; + + cff->font_info = font_info; + } + + *afont_info = *cff->font_info; + + Fail: + return error; + } + + static const FT_Service_PsInfoRec cff_service_ps_info = { - (PS_GetFontInfoFunc) NULL, /* unsupported with CFF fonts */ + (PS_GetFontInfoFunc) cff_ps_get_font_info, (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names, (PS_GetFontPrivateFunc)NULL /* unsupported with CFF fonts */ }; diff --git a/src/cff/cffload.c b/src/cff/cffload.c index b07e90302..d88b4fd79 100644 --- a/src/cff/cffload.c +++ b/src/cff/cffload.c @@ -22,6 +22,7 @@ #include FT_INTERNAL_STREAM_H #include FT_SERVICE_POSTSCRIPT_CMAPS_H #include FT_TRUETYPE_TAGS_H +#include FT_TYPE1_TABLES_H #include "cffload.h" #include "cffparse.h" @@ -1582,6 +1583,16 @@ CFF_Done_FD_Select( &font->fd_select, font->stream ); + if (font->font_info != NULL) + { + FT_FREE( font->font_info->version ); + FT_FREE( font->font_info->notice ); + FT_FREE( font->font_info->full_name ); + FT_FREE( font->font_info->family_name ); + FT_FREE( font->font_info->weight ); + FT_FREE( font->font_info ); + } + FT_FREE( font->global_subrs ); FT_FREE( font->font_name ); } diff --git a/src/cff/cfftypes.h b/src/cff/cfftypes.h index 96301d633..306e5aab6 100644 --- a/src/cff/cfftypes.h +++ b/src/cff/cfftypes.h @@ -23,6 +23,7 @@ #include #include FT_FREETYPE_H +#include FT_TYPE1_TABLES_H FT_BEGIN_HEADER @@ -255,6 +256,9 @@ FT_BEGIN_HEADER /* interface to Postscript Names service */ void* psnames; + /* since version 2.3.0 */ + PS_FontInfoRec* font_info; /* font info dictionary */ + } CFF_FontRec, *CFF_Font;