[cff] Add support for `FSType'. * include/freetype/internal/cfftypes.h (CFF_FontRec): Add `font_extra' entry. * src/cff/cffdrivr.c (cff_ps_get_font_extra): New function to retrieve FSType info from the embedded PostScript data. (cff_service_ps_info): Register function. * src/cff/cffload.c (cff_font_done): Free `font_extra'.
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 145 146 147 148 149 150 151 152 153
diff --git a/ChangeLog b/ChangeLog
index dac2e7d..b30c3b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2017-10-04 John Tytgat <John.Tytgat@esko.com>
+
+ [cff] Add support for `FSType'.
+
+ * include/freetype/internal/cfftypes.h (CFF_FontRec): Add
+ `font_extra' entry.
+
+ * src/cff/cffdrivr.c (cff_ps_get_font_extra): New function to
+ retrieve FSType info from the embedded PostScript data.
+ (cff_service_ps_info): Register function.
+
+ * src/cff/cffload.c (cff_font_done): Free `font_extra'.
+
2017-09-30 Alexei Podtelezhnikov <apodtele@gmail.com>
Signedness fixes in bitmap presetting.
diff --git a/include/freetype/internal/cfftypes.h b/include/freetype/internal/cfftypes.h
index d6de1f3..0b9dbdf 100644
--- a/include/freetype/internal/cfftypes.h
+++ b/include/freetype/internal/cfftypes.h
@@ -27,6 +27,7 @@
#include FT_INTERNAL_SERVICE_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
+#include FT_INTERNAL_TYPE1_TYPES_H
FT_BEGIN_HEADER
@@ -397,6 +398,9 @@ FT_BEGIN_HEADER
/* since version 2.7.1 */
CFF_VStoreRec vstore; /* parsed vstore structure */
+ /* since version 2.8.2 */
+ PS_FontExtraRec* font_extra;
+
} CFF_FontRec;
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 340de9c..e761409 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -496,11 +496,91 @@
}
+ static FT_Error
+ cff_ps_get_font_extra( CFF_Face face,
+ PS_FontExtraRec* afont_extra )
+ {
+ CFF_Font cff = (CFF_Font)face->extra.data;
+ FT_Error error = FT_Err_Ok;
+
+
+ if ( cff && cff->font_extra == NULL )
+ {
+ CFF_FontRecDict dict = &cff->top_font.font_dict;
+ PS_FontExtraRec* font_extra = NULL;
+ FT_Memory memory = face->root.memory;
+ FT_String* embedded_postscript;
+
+
+ if ( FT_ALLOC( font_extra, sizeof ( *font_extra ) ) )
+ goto Fail;
+
+ font_extra->fs_type = 0u;
+
+ embedded_postscript = cff_index_get_sid_string(
+ cff,
+ dict->embedded_postscript );
+ if ( embedded_postscript )
+ {
+ FT_String* start_fstype;
+ FT_String* start_def;
+
+
+ /* Identify the XYZ integer in `/FSType XYZ def' substring. */
+ if ( ( start_fstype = ft_strstr( embedded_postscript,
+ "/FSType" ) ) != NULL &&
+ ( start_def = ft_strstr( start_fstype +
+ sizeof ( "/FSType" ) - 1,
+ "def" ) ) != NULL )
+ {
+ FT_String* s;
+
+
+ for ( s = start_fstype + sizeof ( "/FSType" ) - 1;
+ s != start_def;
+ s++ )
+ {
+ if ( *s >= '0' && *s <= '9' )
+ {
+ FT_UShort prev_fs_type;
+
+
+ prev_fs_type = font_extra->fs_type;
+ font_extra->fs_type = 10 * font_extra->fs_type + *s - '0';
+ if ( font_extra->fs_type < prev_fs_type )
+ {
+ /* Overflow - ignore the FSType value. */
+ font_extra->fs_type = 0U;
+ break;
+ }
+ }
+ else if ( *s != ' ' && *s != '\n' && *s != '\r' )
+ {
+ /* Non-whitespace character between `/FSType' and next `def' */
+ /* - ignore the FSType value. */
+ font_extra->fs_type = 0U;
+ break;
+ }
+ }
+ }
+ }
+
+ cff->font_extra = font_extra;
+ }
+
+ if ( cff )
+ *afont_extra = *cff->font_extra;
+
+ Fail:
+ return error;
+ }
+
+
FT_DEFINE_SERVICE_PSINFOREC(
cff_service_ps_info,
(PS_GetFontInfoFunc) cff_ps_get_font_info, /* ps_get_font_info */
- (PS_GetFontExtraFunc) NULL, /* ps_get_font_extra */
+ (PS_GetFontExtraFunc) cff_ps_get_font_extra, /* ps_get_font_extra */
(PS_HasGlyphNamesFunc) cff_ps_has_glyph_names, /* ps_has_glyph_names */
/* unsupported with CFF fonts */
(PS_GetFontPrivateFunc)NULL, /* ps_get_font_private */
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 0875ead..0f0c839 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -2539,6 +2539,8 @@
font->cf2_instance.finalizer( font->cf2_instance.data );
FT_FREE( font->cf2_instance.data );
}
+
+ FT_FREE( font->font_extra );
}