Added FT_FRAME_SKIP_xxx to skip fields. More use of READ_Fields() in ttsbit.c Other minor fixes.
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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
diff --git a/include/freetype/internal/ftstream.h b/include/freetype/internal/ftstream.h
index 02d3820..aca4a1c 100644
--- a/include/freetype/internal/ftstream.h
+++ b/include/freetype/internal/ftstream.h
@@ -83,6 +83,11 @@ typedef struct FT_Frame_Field_
#define FT_FRAME_SHORT_LE(s,f) FT_FRAME_FIELD( ft_frame_short_le, s, f )
#define FT_FRAME_USHORT_LE(s,f) FT_FRAME_FIELD( ft_frame_ushort_le, s, f )
+#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 }
+
+
/*************************************************************************/
/* */
/* integer extraction macros - the `buffer' parameter must ALWAYS be of */
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index f0dcf1e..2a48b23 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -373,7 +373,7 @@
else
a = 0x7FFFFFFFL;
- return ( s < 0 ) ? -a : a;
+ return ( s < 0 ? -a : a );
}
@@ -648,14 +648,14 @@
else
q = 0x7FFFFFFFL;
- return ( s < 0 ) ? -(FT_Int32)q : (FT_Int32)q;
+ return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
}
r = x->hi;
lo = x->lo;
if ( r >= (FT_Word32)y ) /* we know y is to be treated as unsigned here */
- return ( s < 0 ) ? 0x80000001UL : 0x7FFFFFFFUL;
+ return ( s < 0 ? 0x80000001UL : 0x7FFFFFFFUL );
/* Return Max/Min Int32 if division overflow. */
/* This includes division by zero! */
q = 0;
@@ -673,7 +673,7 @@
lo <<= 1;
}
- return ( s < 0 ) ? -(FT_Int32)q : (FT_Int32)q;
+ return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
}
diff --git a/src/base/ftraster.c b/src/base/ftraster.c
index 40ee193..9687366 100644
--- a/src/base/ftraster.c
+++ b/src/base/ftraster.c
@@ -1371,7 +1371,7 @@
{
/* the arc is y-monotonous, either ascending or descending */
/* detect a change of direction */
- state_bez = y1 < y3 ? Ascending : Descending;
+ state_bez = y1 < y3 ? Ascending : Descending;
if ( ras.state != state_bez )
{
/* finalize current profile if any */
@@ -1498,7 +1498,7 @@
}
else
{
- state_bez = ( y1 <= y4 ) ? Ascending : Descending;
+ state_bez = y1 <= y4 ? Ascending : Descending;
/* detect a change of direction */
if ( ras.state != state_bez )
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index d43eb01..7395367 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -531,38 +531,35 @@
switch ( fields->value )
{
case ft_frame_start: /* access a new frame */
- {
- error = FT_Access_Frame( stream, fields->offset );
- if ( error )
- goto Exit;
+ error = FT_Access_Frame( stream, fields->offset );
+ if ( error )
+ goto Exit;
- frame_accessed = 1;
- fields++;
- continue; /* loop! */
- }
+ frame_accessed = 1;
+ fields++;
+ continue; /* loop! */
case ft_frame_byte:
case ft_frame_schar: /* read a single byte */
- {
- value = GET_Byte();
- sign_shift = 24;
- break;
- }
+ value = GET_Byte();
+ sign_shift = 24;
+ break;
case ft_frame_short_be:
case ft_frame_ushort_be: /* read a 2-byte big-endian short */
- {
- value = GET_UShort();
- sign_shift = 16;
- break;
- }
+ value = GET_UShort();
+ sign_shift = 16;
+ break;
case ft_frame_short_le:
case ft_frame_ushort_le: /* read a 2-byte little-endian short */
{
char* p;
+
+
value = 0;
p = stream->cursor;
+
if ( p + 1 < stream->limit )
{
value = ( FT_UShort)p[0] | ((FT_UShort)p[1] << 8 );
@@ -574,11 +571,9 @@
case ft_frame_long_be:
case ft_frame_ulong_be: /* read a 4-byte big-endian long */
- {
- value = GET_ULong();
- sign_shift = 0;
- break;
- }
+ value = GET_ULong();
+ sign_shift = 0;
+ break;
case ft_frame_long_le:
case ft_frame_ulong_le: /* read a 4-byte little-endian long */
@@ -588,12 +583,13 @@
value = 0;
p = stream->cursor;
+
if ( p + 3 < stream->limit )
{
- value = (FT_ULong)p[0] |
- ( (FT_ULong)p[1] << 8 ) |
- ( (FT_ULong)p[2] << 16 ) |
- ( (FT_ULong)p[3] << 24 );
+ value = (FT_ULong)p[0] |
+ ( (FT_ULong)p[1] << 8 ) |
+ ( (FT_ULong)p[2] << 16 ) |
+ ( (FT_ULong)p[3] << 24 );
stream->cursor += 4;
}
sign_shift = 0;
@@ -602,11 +598,9 @@
case ft_frame_off3_be:
case ft_frame_uoff3_be: /* read a 3-byte big-endian long */
- {
- value = GET_UOffset();
- sign_shift = 8;
- break;
- }
+ value = GET_UOffset();
+ sign_shift = 8;
+ break;
case ft_frame_off3_le:
case ft_frame_uoff3_le: /* read a 3-byte little-endian long */
@@ -616,12 +610,13 @@
value = 0;
p = stream->cursor;
+
if ( p + 3 < stream->limit )
{
- value = (FT_ULong)p[0] |
- ( (FT_ULong)p[1] << 8 ) |
- ( (FT_ULong)p[2] << 16 ) |
- ( (FT_ULong)p[3] << 24 );
+ value = (FT_ULong)p[0] |
+ ( (FT_ULong)p[1] << 8 ) |
+ ( (FT_ULong)p[2] << 16 ) |
+ ( (FT_ULong)p[3] << 24 );
stream->cursor += 4;
}
sign_shift = 8;
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index 6012301..8ef9619 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -130,7 +130,7 @@
/* load subheaders */
cmap2->numGlyphId = l =
- ( ( cmap->length - 2L * ( 256 + 3 ) - num_SH * 8L ) & 0xffff ) / 2;
+ ( ( cmap->length - 2L * ( 256 + 3 ) - num_SH * 8L ) & 0xFFFF ) / 2;
if ( ALLOC_ARRAY( cmap2->subHeaders,
num_SH + 1,
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 07c165f..efb5831 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -403,6 +403,28 @@
FT_FRAME_END
};
+ const FT_Frame_Field strike_start_fields[] =
+ {
+ /* no FT_FRAME_START */
+ FT_FRAME_ULONG( TT_SBit_Strike, ranges_offset ),
+ FT_FRAME_SKIP_LONG,
+ FT_FRAME_ULONG( TT_SBit_Strike, num_ranges ),
+ FT_FRAME_ULONG( TT_SBit_Strike, color_ref ),
+ FT_FRAME_END
+ };
+
+ const FT_Frame_Field strike_end_fields[] =
+ {
+ /* no FT_FRAME_START */
+ FT_FRAME_USHORT( TT_SBit_Strike, start_glyph ),
+ FT_FRAME_USHORT( TT_SBit_Strike, end_glyph ),
+ FT_FRAME_BYTE ( TT_SBit_Strike, x_ppem ),
+ FT_FRAME_BYTE ( TT_SBit_Strike, y_ppem ),
+ FT_FRAME_BYTE ( TT_SBit_Strike, bit_depth ),
+ FT_FRAME_CHAR ( TT_SBit_Strike, flags ),
+ FT_FRAME_END
+ };
+
face->num_sbit_strikes = 0;
@@ -450,24 +472,12 @@
while ( count > 0 )
{
- TT_ULong indexTablesSize;
-
-
- strike->ranges_offset = GET_ULong();
- indexTablesSize = GET_ULong(); /* don't save */
-
- strike->num_ranges = GET_ULong();
- strike->color_ref = GET_ULong();
+ (void)READ_Fields( strike_start_fields, strike );
(void)READ_Fields( sbit_line_metrics_fields, &strike->hori );
(void)READ_Fields( sbit_line_metrics_fields, &strike->vert );
- strike->start_glyph = GET_UShort();
- strike->end_glyph = GET_UShort();
- strike->x_ppem = GET_Byte();
- strike->y_ppem = GET_Byte();
- strike->bit_depth = GET_Byte();
- strike->flags = GET_Char();
+ (void)READ_Fields( strike_end_fields, strike );
count--;
strike++;