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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
diff --git a/ChangeLog b/ChangeLog
index b4c83d9..a701fc8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-01-13 Derek Clegg <dclegg@apple.com>
+
+ 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 <wl@gnu.org>
* src/base/ftoutln.c (FT_Outline_Get_Orientation): Fix compilation
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index e90e2b0..7728cf7 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 b07e903..d88b4fd 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 96301d6..306e5aa 100644
--- 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
@@ -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;