* src/cid/cidparse.c (cid_parser_new): Improve error message for Type 11 fonts. Scan for `/sfnts' token.
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
diff --git a/ChangeLog b/ChangeLog
index 8203510..f26ab93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
2007-01-07 Werner Lemberg <wl@gnu.org>
- * src/cid/cidparse.c (cid_parser_new): Reject Type 42 CID-keyed
- fonts.
+ * src/cid/cidparse.c (cid_parser_new): Improve error message for
+ Type 11 fonts.
+ Scan for `/sfnts' token.
+
+2007-01-07 Werner Lemberg <wl@gnu.org>
+
+ * src/cid/cidparse.c (cid_parser_new): Reject Type 11 fonts.
2007-01-06 Werner Lemberg <wl@gnu.org>
diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c
index 3d342f2..c2381fa 100644
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -83,7 +83,8 @@
goto Exit;
Again:
- /* now, read the rest of the file until we find a `StartData' */
+ /* now, read the rest of the file until we find */
+ /* `StartData' or `/sfnts' */
{
FT_Byte buffer[256 + 10];
FT_Int read_len = 256 + 10;
@@ -92,7 +93,7 @@
for ( offset = (FT_ULong)FT_STREAM_POS(); ; offset += 256 )
{
- FT_Int stream_len;
+ FT_Int stream_len;
stream_len = stream->size - FT_STREAM_POS();
@@ -116,6 +117,11 @@
offset += p - buffer + 10;
goto Found;
}
+ else if ( p[1] == 's' && ft_strncmp( (char*)p, "/sfnts", 6 ) == 0 )
+ {
+ offset += p - buffer + 7;
+ goto Found;
+ }
}
FT_MEM_MOVE( buffer, p, 10 );
@@ -125,8 +131,9 @@
}
Found:
- /* We have found the start of the binary data. Now rewind and */
- /* extract the frame corresponding to the PostScript section. */
+ /* We have found the start of the binary data or the `/sfnts' token. */
+ /* Now rewind and extract the frame corresponding to this PostScript */
+ /* section. */
ps_len = offset - base_offset;
if ( FT_STREAM_SEEK( base_offset ) ||
@@ -140,9 +147,10 @@
parser->root.limit = parser->root.cursor + ps_len;
parser->num_dict = -1;
- /* Finally, we check whether `StartData' was real -- it could be */
- /* in a comment or string. We also get its arguments to find out */
- /* whether the data is represented in binary or hex format. */
+ /* Finally, we check whether `StartData' or `/sfnts' was real -- */
+ /* it could be in a comment or string. We also get the arguments */
+ /* of `StartData' to find out whether the data is represented in */
+ /* binary or hex format. */
arg1 = parser->root.cursor;
cid_parser_skip_PS_token( parser );
@@ -159,7 +167,7 @@
if ( parser->root.error )
break;
- if ( *cur == 'S' && ft_strncmp( (char*)cur, "StartData", 9 ) == 0 )
+ if ( cur[0] == 'S' && ft_strncmp( (char*)cur, "StartData", 9 ) == 0 )
{
if ( ft_strncmp( (char*)arg1, "(Hex)", 5 ) == 0 )
parser->binary_length = ft_atol( (const char *)arg2 );
@@ -168,6 +176,12 @@
cur = parser->root.cursor;
goto Exit;
}
+ else if ( cur[1] == 's' && ft_strncmp( (char*)cur, "/sfnts", 6 ) == 0 )
+ {
+ FT_TRACE2(( "cid_parser_new: cannot handle Type 11 fonts\n" ));
+ error = CID_Err_Unknown_File_Format;
+ goto Exit;
+ }
cid_parser_skip_PS_token( parser );
cid_parser_skip_spaces ( parser );
@@ -183,11 +197,6 @@
goto Again;
Exit:
- if ( !parser->postscript )
- {
- FT_TRACE2(( "[not a valid CID-keyed font]\n" ));
- error = CID_Err_Unknown_File_Format;
- }
return error;
}