freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Found problem with Subrs parsing...


From: Just van Rossum
Subject: Re: Found problem with Subrs parsing...
Date: Mon, 24 Jul 2000 22:59:44 +0100

At 3:47 PM -0400 24-07-2000, Tom Kacvinsky wrote:
>Sound about right?

Yeah...

I've made a patch which works like this: always make sure the next token is
"dup" when starting to parse a new subr. Here it is:

cvs -z9 -q diff -c z1load.c (in directory DevDev:PyPy:freetype2:src:type1z:)
Index: z1load.c
===================================================================
RCS file: /cvsroot/freetype2/src/type1z/z1load.c,v
retrieving revision 1.7
diff -c -r1.7 z1load.c
*** z1load.c    2000/07/10 21:41:32     1.7
--- z1load.c    2000/07/25 05:07:35
***************
*** 1243,1248 ****
--- 1243,1253 ----
      if ( parser->error )
        return;

+     /* position the parser right before the "dup" of the first subr */
+     skip_whitespace( parser );
+     skip_blackspace( parser ); /* "array" */
+     skip_whitespace( parser );
+
      /* initialize subrs array */
      error = Z1_New_Table( table, loader->num_subrs, memory );
      if ( error )
***************
*** 1259,1274 ****
        FT_Byte*  base;


        index = Z1_ToInt( parser );

-       /* make sure we get subr index and loop count in sync --  */
-       /* in some cases, the dictionary count is simply the last */
-       /* subr index + 1, with possible holes in the table       */
-       if ( index > n )
-         n = index;
-
        if ( !read_binary_data( parser, &size, &base ) )
          return;

        /* some fonts use a value of -1 for lenIV to indicate that */
        /* the charstrings are unencoded..                         */
--- 1264,1292 ----
        FT_Byte*  base;


+       /* If the next token isn't "dup", we're also done. This   */
+       /* happens when there are "holes" in the Subrs array.     */
+       if ( strncmp( (char*)parser->cursor, "dup", 3 ) != 0 )
+         break;
+
        index = Z1_ToInt( parser );

        if ( !read_binary_data( parser, &size, &base ) )
          return;
+
+       /* The binary string is followed by one token, eg. "NP"   */
+       /* (bound to "noaccess put") or by two separate tokens:   */
+       /*   noaccess put                                         */
+       /* We position the parser right before the next dup,      */
+       /* if any. */
+       skip_whitespace( parser );
+       skip_blackspace( parser ); /* "NP" or "I" or "noaccess"   */
+       skip_whitespace( parser );
+       if ( strncmp( (char*)parser->cursor, "put", 3 ) == 0 )
+       {
+         skip_blackspace( parser ); /* "put" */
+         skip_whitespace( parser );
+       }

        /* some fonts use a value of -1 for lenIV to indicate that */
        /* the charstrings are unencoded..                         */




David, if you agree with this, I'll check it in for you.

Just





reply via email to

[Prev in Thread] Current Thread [Next in Thread]