* src/type1/t1load.c (parse_font_matrix, parse_charstrings): Remove code specially for synthetic fonts; this is handled elsewhere. (parse_encoding): Remove code specially for synthetic fonts; this is handled elsewhere. Improve boundary checking while parsing. (parse_dict): Improve boundary checking while parsing. Use ft_memcmp to simplify code.
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 196 197 198 199 200 201 202 203 204 205 206 207 208
diff --git a/ChangeLog b/ChangeLog
index 05f9466..011389e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2003-10-08 Werner Lemberg <wl@gnu.org>
+
+ * src/type1/t1load.c (parse_font_matrix, parse_charstrings): Remove
+ code specially for synthetic fonts; this is handled elsewhere.
+ (parse_encoding): Remove code specially for synthetic fonts; this is
+ handled elsewhere.
+ Improve boundary checking while parsing.
+ (parse_dict): Improve boundary checking while parsing.
+ Use ft_memcmp to simplify code.
+
2003-10-07 Werner Lemberg <wl@gnu.org>
* src/type1/t1load.c (parse_subrs, parse_dict): Handle synthetic
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index a59e2a8..e563d63 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -772,9 +772,9 @@
static int
is_space( FT_Byte c )
{
- return ( c == ' ' || c == '\t' ||
+ return ( c == ' ' || c == '\t' ||
c == '\r' || c == '\n' || c == '\f' ||
- c == '\0' );
+ c == '\0' );
}
@@ -831,10 +831,6 @@
FT_Fixed temp_scale;
- if ( matrix->xx || matrix->yx )
- /* with synthetic fonts it is possible we get here twice */
- return;
-
(void)T1_ToFixedArray( parser, 6, temp, 3 );
temp_scale = ABS( temp[3] );
@@ -863,8 +859,8 @@
matrix->yy = temp[3];
/* note that the offsets must be expressed in integer font units */
- offset->x = temp[4] >> 16;
- offset->y = temp[5] >> 16;
+ offset->x = temp[4] >> 16;
+ offset->y = temp[5] >> 16;
}
@@ -899,10 +895,6 @@
FT_Error error;
- if ( encode->char_index )
- /* with synthetic fonts it is possible we get here twice */
- return;
-
/* read the number of entries in the encoding; should be 256 */
count = (FT_Int)T1_ToInt( parser );
T1_Skip_Spaces( parser );
@@ -941,10 +933,10 @@
/* used to clean the encoding array before anything else. */
n = 0;
+ T1_Skip_Spaces( parser );
while ( parser->root.cursor < limit )
{
- T1_Skip_Spaces( parser );
cur = parser->root.cursor;
/* we stop when we encounter a `def' */
@@ -991,6 +983,8 @@
}
else
T1_Skip_PS_Token( parser );
+
+ T1_Skip_Spaces( parser );
}
face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
@@ -1044,7 +1038,7 @@
T1_Skip_PS_Token( parser );
T1_Skip_Spaces ( parser );
if ( parser->root.cursor >= parser->root.limit ||
- *parser->root.cursor != ']' )
+ *parser->root.cursor != ']' )
parser->root.error = T1_Err_Invalid_File_Format;
return;
}
@@ -1161,10 +1155,6 @@
FT_Byte notdef_found = 0;
- if ( loader->num_glyphs )
- /* with synthetic fonts it is possible we get here twice */
- return;
-
loader->num_glyphs = (FT_Int)T1_ToInt( parser );
if ( parser->root.error )
return;
@@ -1187,7 +1177,6 @@
/* index 0 names and codes (if necessary). */
error = psaux->ps_table_funcs->init( swap_table, 4, memory );
-
if ( error )
goto Fail;
@@ -1458,15 +1447,16 @@
limit = parser->root.limit;
+ T1_Skip_Spaces( parser );
+
while ( parser->root.cursor < limit )
{
FT_Byte* cur;
- T1_Skip_Spaces( parser );
cur = parser->root.cursor;
- /* look for `FontDirectory', which causes problems for some fonts */
+ /* look for `FontDirectory' which causes problems for some fonts */
if ( *cur == 'F' && cur + 25 < limit &&
ft_strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
{
@@ -1524,7 +1514,7 @@
len = parser->root.cursor - cur;
- if ( len > 0 && len < 22 )
+ if ( len > 0 && len < 22 && parser->root.cursor < limit )
{
/* now compare the immediate name to the keyword table */
T1_Field keyword = (T1_Field)t1_keywords;
@@ -1543,35 +1533,27 @@
break;
}
- if ( cur[0] == name[0] &&
- len == ft_strlen( (const char*)name ) )
+ if ( cur[0] == name[0] &&
+ len == ft_strlen( (const char *)name ) &&
+ ft_memcmp( cur, name, len ) == 0 )
{
- FT_PtrDist n;
-
-
- for ( n = 1; n < len; n++ )
- if ( cur[n] != name[n] )
- break;
-
- 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; /Subrs is handled specially. */
+ if ( keyword_flag[0] == 0 ||
+ ft_strcmp( (const char*)name, "Subrs" ) == 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,
- keyword );
- if ( parser->root.error )
- return parser->root.error;
- }
- keyword_flag[0] = 1;
- break;
+ parser->root.error = t1_load_keyword( face,
+ loader,
+ keyword );
+ if ( parser->root.error )
+ return parser->root.error;
}
+ keyword_flag[0] = 1;
+ break;
}
+
keyword++;
keyword_flag++;
}
@@ -1579,7 +1561,10 @@
}
else
T1_Skip_PS_Token( parser );
+
+ T1_Skip_Spaces( parser );
}
+
return parser->root.error;
}