ref: ac250b228afab02fa213362fb92e2a3b038b0af3
parent: b0398be6b8eed3ff1c18b5b5454d264df0434b15
author: Werner Lemberg <[email protected]>
date: Sat Jan 13 09:01:36 EST 2007
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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-01-13 Derek Clegg <[email protected]>
+
+ 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 <[email protected]>
* src/base/ftoutln.c (FT_Outline_Get_Orientation): Fix compilation
--- 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 */
};
--- 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"
@@ -1581,6 +1582,16 @@
cff_subfont_done( memory, &font->top_font );
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 );
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -23,6 +23,7 @@
#include <ft2build.h>
#include FT_FREETYPE_H
+#include FT_TYPE1_TABLES_H
FT_BEGIN_HEADER
@@ -254,6 +255,9 @@
/* interface to Postscript Names service */
void* psnames;
+
+ /* since version 2.3.0 */
+ PS_FontInfoRec* font_info; /* font info dictionary */
} CFF_FontRec, *CFF_Font;