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>
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
diff --git a/include/freetype/internal/ftstream.h b/include/freetype/internal/ftstream.h
index aca4a1c..82e1bf2 100644
--- 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 @@ typedef enum FT_Frame_Op_
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;
@@ -87,6 +90,13 @@ typedef struct FT_Frame_Field_
#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) }
+
+
/*************************************************************************/
/* */
diff --git a/include/freetype/tttables.h b/include/freetype/tttables.h
index d01a8e2..0ac83e6 100644
--- 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;
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
index 592efa3..7b6c2d3 100644
--- 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 )
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index c1cb122..5be5da9 100644
--- 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;
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index f448405..3506938 100644
--- 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,16 +1338,19 @@
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
};
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" ));