Commit 3864f4eae9781bf95a444f66326ee9e9825e8192

Werner Lemberg 2003-09-30T06:43:54

* src/cid/cidload.c (cid_parse_dict): Skip token if no keyword is found. * src/type1/t1parse.c (IS_T1_WHITESPACE, IS_T1_LINESPACE, IS_T1_SPACE): Removed. (PFB_Tag): Removed. (read_pfb_tag): Don't use PFB_Tag. * src/type42/t42parse.c (t42_is_space): Handle `\f' also. (t42_parse_encoding): Handle synthetic fonts.

diff --git a/ChangeLog b/ChangeLog
index b1cd95e..c5286de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2003-09-30  Werner Lemberg  <wl@gnu.org>
+
+	* src/cid/cidload.c (cid_parse_dict): Skip token if no keyword is
+	found.
+
+	* src/type1/t1parse.c (IS_T1_WHITESPACE, IS_T1_LINESPACE,
+	IS_T1_SPACE): Removed.
+	(PFB_Tag): Removed.
+	(read_pfb_tag): Don't use PFB_Tag.
+
+	* src/type42/t42parse.c (t42_is_space): Handle `\f' also.
+	(t42_parse_encoding): Handle synthetic fonts.
+
 2003-09-29  Werner Lemberg  <wl@gnu.org>
 
 	* include/freetype/internal/t1types.h: Don't include
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 7b0aba6..32c4a0d 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -191,7 +191,7 @@
       offset->y  = temp[5] >> 16;
     }
 
-    return CID_Err_Ok;       /* this is a callback function; */
+    return CID_Err_Ok;      /* this is a callback function; */
                             /* we must return an error code */
   }
 
@@ -265,7 +265,7 @@
       FT_Byte*  limit = cur + size;
 
 
-      for ( ;cur < limit; cur++ )
+      for ( ; cur < limit; cur++ )
       {
         /* look for `%ADOBeginFontDict' */
         if ( *cur == '%' && cur + 20 < limit &&
@@ -281,7 +281,7 @@
         /* look for immediates */
         else if ( *cur == '/' && cur + 2 < limit )
         {
-          FT_Int  len;
+          FT_PtrDist  len;
 
 
           cur++;
@@ -289,11 +289,11 @@
           parser->root.cursor = cur;
           cid_parser_skip_alpha( parser );
 
-          len = (FT_Int)( parser->root.cursor - cur );
+          len = parser->root.cursor - cur;
           if ( len > 0 && len < 22 )
           {
             /* now compare the immediate name to the keyword table */
-            T1_Field  keyword = (T1_Field) cid_field_records;
+            T1_Field  keyword = (T1_Field)cid_field_records;
 
 
             for (;;)
@@ -303,12 +303,15 @@
 
               name = (FT_Byte*)keyword->ident;
               if ( !name )
+              {
+                cid_parser_skip_alpha( parser );
                 break;
+              }
 
-              if ( cur[0] == name[0]                          &&
-                   len == (FT_Int)ft_strlen( (const char*)name ) )
+              if ( cur[0] == name[0]                     &&
+                   len == ft_strlen( (const char*)name ) )
               {
-                FT_Int  n;
+                FT_PtrDist  n;
 
 
                 for ( n = 1; n < len; n++ )
diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c
index cf12c5a..d785aec 100644
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -65,41 +65,28 @@
   /*************************************************************************/
 
 
-#define IS_T1_WHITESPACE( c )  ( (c) == ' '  || (c) == '\t' )
-#define IS_T1_LINESPACE( c )   ( (c) == '\r' || (c) == '\n' )
-
-#define IS_T1_SPACE( c )  ( IS_T1_WHITESPACE( c ) || IS_T1_LINESPACE( c ) )
-
-
-  typedef struct  PFB_Tag_
-  {
-    FT_UShort  tag;
-    FT_Long    size;
-
-  } PFB_Tag;
-
-
   static FT_Error
   read_pfb_tag( FT_Stream   stream,
-                FT_UShort*  tag,
-                FT_Long*    size )
+                FT_UShort  *atag,
+                FT_Long    *asize )
   {
-    FT_Error  error;
-    PFB_Tag   head;
+    FT_Error   error;
+    FT_UShort  tag;
+    FT_Long    size;
 
 
-    *tag  = 0;
-    *size = 0;
+    *atag  = 0;
+    *asize = 0;
 
-    if ( !FT_READ_USHORT( head.tag ) )
+    if ( !FT_READ_USHORT( tag ) )
     {
-      if ( head.tag == 0x8001U || head.tag == 0x8002U )
+      if ( tag == 0x8001U || tag == 0x8002U )
       {
-        if ( !FT_READ_LONG_LE( head.size ) )
-          *size = head.size;
+        if ( !FT_READ_LONG_LE( size ) )
+          *asize = size;
       }
 
-      *tag = head.tag;
+      *atag = tag;
     }
 
     return error;
diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c
index ae4b7fc..071c6ec 100644
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -158,8 +158,8 @@
     /*   When creating a new Type 42 parser, we try to locate and load */
     /*   the base dictionary, loading the whole font into memory.      */
     /*                                                                 */
-    /*   When `loading' the base dictionary, we only setup pointers in */
-    /*   the case of a memory-based stream.  Otherwise, we allocate    */
+    /*   When `loading' the base dictionary, we only set up pointers   */
+    /*   in the case of a memory-based stream.  Otherwise, we allocate */
     /*   and load the base dictionary in it.                           */
     /*                                                                 */
     /*   parser->in_memory is set if we have a memory stream.          */
@@ -245,7 +245,7 @@
   static int
   t42_is_space( FT_Byte  c )
   {
-    return ( c == ' ' || c == '\t' || c == '\r' || c == '\n' );
+    return ( c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f' );
   }
 
 
@@ -327,6 +327,10 @@
       FT_Error     error;
 
 
+      if ( encode->char_index )
+        /*  with synthetic fonts, it's possible we get here twice  */
+        return;
+
       /* read the number of entries in the encoding, should be 256 */
       count = (FT_Int)T1_ToInt( parser );
       if ( parser->root.error )
@@ -407,14 +411,14 @@
           {
             /* bingo, we have an immediate name -- it must be a */
             /* character name                                   */
-            FT_Byte*  cur2 = cur + 1;
-            FT_Int    len;
+            FT_Byte*    cur2 = cur + 1;
+            FT_PtrDist  len;
 
 
             while ( cur2 < limit && t42_is_alpha( *cur2 ) )
               cur2++;
 
-            len = (FT_Int)( cur2 - cur - 1 );
+            len = cur2 - cur - 1;
 
             parser->root.error = T1_Add_Table( char_table, charcode,
                                                cur + 1, len + 1 );