shithub: freetype+ttf2subf

Download patch

ref: d18388e44b0052a7ad8b14453fd74a248ddf1e8f
parent: 768c9561f614b1da1b74b2649f19a8f863e3f892
author: David Turner <[email protected]>
date: Mon Jul 3 11:00:49 EDT 2000

fixed a few 64-bit related bugs in "sfnt/ttload.c" and
"base/ftstream.c"

Note that "TT_PCLT" was incorrectly defined in
<freetype/tttables.h>

git/fs: mount .git/fs: mount/attach disallowed
--- a/include/freetype/internal/ftstream.h
+++ b/include/freetype/internal/ftstream.h
@@ -22,6 +22,7 @@
 #define FT_FRAME_OP_SHORT 3  /* read 2-byte value */
 #define FT_FRAME_OP_LONG  4  /* read 4-byte value */
 #define FT_FRAME_OP_OFF3  5  /* read 3-byte value */
+#define FT_FRAME_OP_BYTES 6  /* read a bytes sequence */
 
 typedef enum FT_Frame_Op_
 {
@@ -44,7 +45,9 @@
   ft_frame_uoff3_be  = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 0 ),
   ft_frame_uoff3_le  = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 0, 1 ),
   ft_frame_off3_be   = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 0 ),
-  ft_frame_off3_le   = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 )
+  ft_frame_off3_le   = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 ),
+  
+  ft_frame_bytes     = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 )
 
 } FT_Frame_Op;
 
@@ -86,6 +89,13 @@
 #define FT_FRAME_SKIP_LONG   { ft_frame_long_be, 0, 0 }
 #define FT_FRAME_SKIP_SHORT  { ft_frame_short_be, 0, 0 }
 #define FT_FRAME_SKIP_BYTE   { ft_frame_byte, 0, 0 }
+
+#define FT_FRAME_BYTES( struct_type, field, count )               \
+          {                                                       \
+            ft_frame_bytes,                                       \
+            count,                                                \
+            (FT_UShort)(char*)&FT_FIELD_REF(struct_type,field) }
+
 
 
   /*************************************************************************/
--- a/include/freetype/tttables.h
+++ b/include/freetype/tttables.h
@@ -418,7 +418,7 @@
         FT_Char    TypeFace[16];
 	FT_Char    CharacterComplement[8];
 	FT_Char    FileName[6];
-	FT_Char    StrokeWeight[6];
+	FT_Char    StrokeWeight;
 	FT_Char    WidthType;
 	FT_Byte    SerifStyle;
 	FT_Byte    Reserved;
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -561,7 +561,6 @@
   /* <Note>                                                                */
   /*    The 2x2 transformation matrix is also applied to the glyph's       */
   /*    advance vector.                                                    */
-  /*                                                                       */
   FT_EXPORT_FUNC( FT_Error )  FT_Glyph_Transform( FT_Glyph    glyph,
                                                   FT_Matrix*  matrix,
                                                   FT_Vector*  delta )
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -539,6 +539,21 @@
         fields++;
         continue;  /* loop! */
 
+      case ft_frame_bytes:  /* read a byte sequence */
+        {
+          FT_Int  len = stream->limit - stream->cursor;
+          
+          if (len > fields->size)
+            len = fields->size;
+
+          p = (FT_Byte*)structure + fields->offset;
+          MEM_Copy( p, stream->cursor, len );
+          stream->cursor += len;  
+          fields++;
+          continue;
+        }
+        
+
       case ft_frame_byte:
       case ft_frame_schar:  /* read a single byte */
         value = GET_Byte();
@@ -611,13 +626,12 @@
           value = 0;
           p     = stream->cursor;
 
-          if ( p + 3 < stream->limit )
+          if ( p + 2 < stream->limit )
           {
             value =   (FT_ULong)p[0]         |
                     ( (FT_ULong)p[1] << 8  ) |
-                    ( (FT_ULong)p[2] << 16 ) |
-                    ( (FT_ULong)p[3] << 24 );
-            stream->cursor += 4;
+                    ( (FT_ULong)p[2] << 16 );
+            stream->cursor += 3;
           }
           sign_shift = 8;
           break;
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -1330,7 +1330,7 @@
   {
     static const FT_Frame_Field  pclt_fields[] =
     {
-      FT_FRAME_START( 20 ),
+      FT_FRAME_START( 54 ),
         FT_FRAME_ULONG ( TT_PCLT, Version ),
         FT_FRAME_ULONG ( TT_PCLT, FontNumber ),
         FT_FRAME_USHORT( TT_PCLT, Pitch ),
@@ -1338,6 +1338,13 @@
         FT_FRAME_USHORT( TT_PCLT, Style ),
         FT_FRAME_USHORT( TT_PCLT, TypeFamily ),
         FT_FRAME_USHORT( TT_PCLT, CapHeight ),
+        FT_FRAME_BYTES ( TT_PCLT, TypeFace, 16 ),
+        FT_FRAME_BYTES ( TT_PCLT, CharacterComplement, 8 ),
+        FT_FRAME_BYTES ( TT_PCLT, FileName, 6 ),
+        FT_FRAME_CHAR  ( TT_PCLT, StrokeWeight ),
+        FT_FRAME_CHAR  ( TT_PCLT, WidthType ),
+        FT_FRAME_BYTE  ( TT_PCLT, SerifStyle ),
+        FT_FRAME_BYTE  ( TT_PCLT, Reserved ),
       FT_FRAME_END
     };
 
@@ -1344,10 +1351,6 @@
     static const FT_Frame_Field  pclt_fields2[] =
     {
       FT_FRAME_START( 4 ),
-        FT_FRAME_CHAR( TT_PCLT, StrokeWeight ),
-        FT_FRAME_CHAR( TT_PCLT, WidthType ),
-        FT_FRAME_BYTE( TT_PCLT, SerifStyle ),
-        FT_FRAME_BYTE( TT_PCLT, Reserved ),
       FT_FRAME_END
     };
 
@@ -1366,11 +1369,7 @@
       return TT_Err_Ok;
     }
 
-    if ( READ_Fields( pclt_fields, pclt )            ||
-         FILE_Read  ( pclt->TypeFace, 16 )           ||
-         FILE_Read  ( pclt->CharacterComplement, 8 ) ||
-         FILE_Read  ( pclt->FileName, 6 )            ||
-         READ_Fields( pclt_fields2, pclt )           )
+    if ( READ_Fields( pclt_fields, pclt ) )
       goto Exit;
 
     FT_TRACE2(( "loaded\n" ));