* src/type1/t1load.c (parse_subrs, parse_dict): Handle synthetic fonts properly.
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
diff --git a/ChangeLog b/ChangeLog
index 6983ffe..c848f6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-07 Werner Lemberg <wl@gnu.org>
+
+ * src/type1/t1load.c (parse_subrs, parse_dict): Handle synthetic
+ fonts properly.
+
2003-10-06 Werner Lemberg <wl@gnu.org>
Heavy modification of the PS parser to handle comments and strings
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 0440e21..3f1322d 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -1030,15 +1030,11 @@
PS_Table table = &loader->subrs;
FT_Memory memory = parser->root.memory;
FT_Error error;
- FT_Int n;
+ FT_Int n, num_subrs;
PSAux_Service psaux = (PSAux_Service)face->psaux;
- if ( loader->num_subrs )
- /* with synthetic fonts it is possible we get here twice */
- return;
-
T1_Skip_Spaces( parser );
/* test for empty array */
@@ -1053,14 +1049,14 @@
return;
}
- loader->num_subrs = (FT_Int)T1_ToInt( parser );
+ num_subrs = (FT_Int)T1_ToInt( parser );
/* position the parser right before the `dup' of the first subr */
T1_Skip_PS_Token( parser ); /* `array' */
T1_Skip_Spaces ( parser );
/* initialize subrs array */
- error = psaux->ps_table_funcs->init( table, loader->num_subrs, memory );
+ error = psaux->ps_table_funcs->init( table, num_subrs, memory );
if ( error )
goto Fail;
@@ -1068,7 +1064,7 @@
/* */
/* `index' + binary data */
/* */
- for ( n = 0; n < loader->num_subrs; n++ )
+ for ( n = 0; n < num_subrs; n++ )
{
FT_Long idx, size;
FT_Byte* base;
@@ -1099,6 +1095,10 @@
T1_Skip_Spaces ( parser );
}
+ /* with synthetic fonts it is possible we get here twice */
+ if ( loader->num_subrs )
+ continue;
+
/* some fonts use a value of -1 for lenIV to indicate that */
/* the charstrings are unencoded */
/* */
@@ -1124,6 +1124,9 @@
if ( error )
goto Fail;
}
+
+ loader->num_subrs = num_subrs;
+
return;
Fail:
@@ -1474,8 +1477,8 @@
/* look up the `known' keyword */
while ( cur < limit )
{
- if ( *cur == 'k' && cur + 5 < limit &&
- ft_strncmp( (char*)cur, "known", 5 ) )
+ if ( *cur == 'k' && cur + 5 < limit &&
+ ft_strncmp( (char*)cur, "known", 5 ) == 0 )
break;
T1_Skip_PS_Token( parser );
@@ -1548,10 +1551,12 @@
if ( n >= len )
{
- /* We found it -- run the parsing callback! */
- /* We only record the first instance of any */
- /* field to deal adequately with synthetic fonts */
- if ( keyword_flag[0] == 0 )
+ /* We found it -- run the parsing callback! */
+ /* We only record the first instance of any */
+ /* field to deal adequately with synthetic */
+ /* fonts; /Subrs is handled specially. */
+ if ( keyword_flag[0] == 0 ||
+ ft_strcmp( (const char*)name, "Subrs" ) == 0 )
{
parser->root.error = t1_load_keyword( face,
loader,