Add missing objects (2/2). Synthesize a `SubFont' object for Type 1 fonts. This is used in the interpreter to access Private dict data, which are stored in different places for Type 1 and CFF. This allows the same data to be used in either mode. * src/psaux/psobjs.c (t1_make_subfont): New procedure to copy required values to a dummy `CFF_SubFont' object. This is similar to `cff_make_private_dict'. * src/psaux/psobjs.h: Add the new declaration. * include/freetype/internal/psaux.h, src/psaux/psauxmod.c: Ditto. Add this to the PSAux Service for future use with CID fonts. * src/type1/t1gload.c: Include FT_INTERNAL_CFF_TYPES_H. (T1_Parse_Glyph_And_Get_Char_String): Add the call.
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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
diff --git a/ChangeLog b/ChangeLog
index 620f84c..c41b9f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
2017-09-25 Ewald Hew <ewaldhew@gmail.com>
+ [psaux] Add missing objects (2/2).
+
+ Synthesize a `SubFont' object for Type 1 fonts. This is used in the
+ interpreter to access Private dict data, which are stored in
+ different places for Type 1 and CFF. This allows the same data to
+ be used in either mode.
+
+ * src/psaux/psobjs.c (t1_make_subfont): New procedure to copy
+ required values to a dummy `CFF_SubFont' object. This is similar to
+ `cff_make_private_dict'.
+ * src/psaux/psobjs.h: Add the new declaration.
+
+ * include/freetype/internal/psaux.h, src/psaux/psauxmod.c: Ditto.
+ Add this to the PSAux Service for future use with CID fonts.
+
+ * src/type1/t1gload.c: Include FT_INTERNAL_CFF_TYPES_H.
+ (T1_Parse_Glyph_And_Get_Char_String): Add the call.
+
+2017-09-25 Ewald Hew <ewaldhew@gmail.com>
+
[psaux] Add missing objects for Type 1 (1/2).
Move `CF2_Font' instance to `PS_Decoder'. This is the context for
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index b28392b..9748368 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -1290,6 +1290,10 @@ FT_BEGIN_HEADER
FT_Bool is_t1,
PS_Decoder* ps_decoder );
+ void
+ (*t1_make_subfont)( T1_Face face,
+ CFF_SubFont subfont );
+
T1_CMap_Classes t1_cmap_classes;
diff --git a/src/psaux/psauxmod.c b/src/psaux/psauxmod.c
index 9c07309..b071929 100644
--- a/src/psaux/psauxmod.c
+++ b/src/psaux/psauxmod.c
@@ -154,6 +154,7 @@
t1_decrypt,
cff_random,
ps_decoder_init,
+ t1_make_subfont,
(const T1_CMap_ClassesRec*) &t1_cmap_classes,
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 8d0f0fe..3fd2fda 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -2327,6 +2327,91 @@
/*************************************************************************/
/*************************************************************************/
+
+ FT_LOCAL_DEF( void )
+ t1_make_subfont( T1_Face face,
+ CFF_SubFont subfont )
+ {
+ PS_Private priv = &face->type1.private_dict;
+ CFF_Private cpriv = &subfont->private_dict;
+ FT_UInt n, count;
+
+ FT_ZERO( subfont );
+ FT_ZERO( cpriv );
+
+ count = cpriv->num_blue_values = priv->num_blue_values;
+ for ( n = 0; n < count; n++ )
+ cpriv->blue_values[n] = (FT_Pos)priv->blue_values[n];
+
+ count = cpriv->num_other_blues = priv->num_other_blues;
+ for ( n = 0; n < count; n++ )
+ cpriv->other_blues[n] = (FT_Pos)priv->other_blues[n];
+
+ count = cpriv->num_family_blues = priv->num_family_blues;
+ for ( n = 0; n < count; n++ )
+ cpriv->family_blues[n] = (FT_Pos)priv->family_blues[n];
+
+ count = cpriv->num_family_other_blues = priv->num_family_other_blues;
+ for ( n = 0; n < count; n++ )
+ cpriv->family_other_blues[n] = (FT_Pos)priv->family_other_blues[n];
+
+ cpriv->blue_scale = priv->blue_scale;
+ cpriv->blue_shift = (FT_Pos)priv->blue_shift;
+ cpriv->blue_fuzz = (FT_Pos)priv->blue_fuzz;
+
+ cpriv->standard_width = (FT_Pos)priv->standard_width[0];
+ cpriv->standard_height = (FT_Pos)priv->standard_height[0];
+
+ count = cpriv->num_snap_widths = priv->num_snap_widths;
+ for ( n = 0; n < count; n++ )
+ cpriv->snap_widths[n] = (FT_Pos)priv->snap_widths[n];
+
+ count = cpriv->num_snap_heights = priv->num_snap_heights;
+ for ( n = 0; n < count; n++ )
+ cpriv->snap_heights[n] = (FT_Pos)priv->snap_heights[n];
+
+ cpriv->force_bold = priv->force_bold;
+ cpriv->lenIV = priv->lenIV;
+ cpriv->language_group = priv->language_group;
+ cpriv->expansion_factor = priv->expansion_factor;
+
+ cpriv->subfont = subfont;
+
+
+ /* Initialize the random number generator. */
+ if ( face->root.internal->random_seed != -1 )
+ {
+ /* . If we have a face-specific seed, use it. */
+ /* If non-zero, update it to a positive value. */
+ subfont->random = (FT_UInt32)face->root.internal->random_seed;
+ if ( face->root.internal->random_seed )
+ {
+ do
+ {
+ face->root.internal->random_seed =
+ (FT_Int32)((PSAux_Service)face->psaux)->cff_random(
+ (FT_UInt32)face->root.internal->random_seed );
+
+ } while ( face->root.internal->random_seed < 0 );
+ }
+ }
+ if ( !subfont->random )
+ {
+ FT_UInt32 seed;
+
+ /* compute random seed from some memory addresses */
+ seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
+ (FT_Offset)(char*)&face ^
+ (FT_Offset)(char*)&subfont );
+ seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
+ if ( seed == 0 )
+ seed = 0x7384;
+
+ subfont->random = seed;
+ }
+ }
+
+
FT_LOCAL_DEF( void )
t1_decrypt( FT_Byte* buffer,
FT_Offset length,
diff --git a/src/psaux/psobjs.h b/src/psaux/psobjs.h
index 1f68419..2fed988 100644
--- a/src/psaux/psobjs.h
+++ b/src/psaux/psobjs.h
@@ -285,6 +285,10 @@ FT_BEGIN_HEADER
/*************************************************************************/
FT_LOCAL( void )
+ t1_make_subfont( T1_Face face,
+ CFF_SubFont subfont );
+
+ FT_LOCAL( void )
t1_decrypt( FT_Byte* buffer,
FT_Offset length,
FT_UShort seed );
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 22b14e4..56689de 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -23,6 +23,7 @@
#include FT_INTERNAL_STREAM_H
#include FT_OUTLINE_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include FT_INTERNAL_CFF_TYPES_H
#include FT_TYPE1_DRIVER_H
#include "t1errors.h"
@@ -104,8 +105,14 @@
(FT_UInt)char_string->length );
else
{
+ CFF_SubFontRec subfont;
+
+
psaux->ps_decoder_init( decoder, TRUE, &psdecoder );
+ psaux->t1_make_subfont( face, &subfont );
+ psdecoder.current_subfont = &subfont;
+
error = decoder_funcs->parse_charstrings( &psdecoder,
(FT_Byte*)char_string->pointer,
(FT_ULong)char_string->length );