* src/tools/ftrandom.c (font_size): New global variable. (TestFace): Use it. (main): Handle new option `--size' to set `font_size'. (Usage): Updated. Formatting.
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
diff --git a/ChangeLog b/ChangeLog
index 61e3968..50ef6a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,24 @@
-2006-06-16 David Turner <david@freetype.org>
+2006-06-17 Werner Lemberg <wl@gnu.org>
+
+ * src/tools/ftrandom.c (font_size): New global variable.
+ (TestFace): Use it.
+ (main): Handle new option `--size' to set `font_size'.
+ (Usage): Updated.
- * src/smooth/ftgrays.c (gray_hline): prevent integer overflows
- when rendering *very* large outlines
+2006-06-16 David Turner <david@freetype.org>
- * src/truetype/ttgload.c (TT_Load_Simple_Glyph): check the well-formedness
- of the contours array when loading a glyph
+ * src/smooth/ftgrays.c (gray_find_cell, gray_set_cell, gray_hline):
+ Prevent integer overflows when rendering very large outlines.
- * src/truetype/ttinterp.c (Ins_IP): check argument ranges to reject
- bogus operations properly
+ * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Check the
+ well-formedness of the contours array when loading a glyph.
+ * src/truetype/ttinterp.c (TT_Load_Context): Initialize `zp0', `zp1',
+ and `zp2'.
+ (Ins_IP): Check argument ranges to reject bogus operations properly.
+ (IUP_WorkerRec): Add `max_points' member.
+ (_iup_worker_interpolate): Check argument ranges.
+ (Ins_IUP): Ignore empty outlines.
2006-06-16 Dmitry Timoshkov <dmitry@codeweavers.com>
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 9e8ee5f..5a4a544 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -197,7 +197,7 @@
#define ONE_PIXEL ( 1L << PIXEL_BITS )
#define PIXEL_MASK ( -1L << PIXEL_BITS )
-#define TRUNC( x ) ( (TCoord)((x) >> PIXEL_BITS) )
+#define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) )
#define SUBPIXELS( x ) ( (TPos)(x) << PIXEL_BITS )
#define FLOOR( x ) ( (x) & -ONE_PIXEL )
#define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL )
@@ -397,7 +397,8 @@
PCell *pcell, cell;
int x = ras.ex;
- if (x > ras.max_ex)
+
+ if ( x > ras.max_ex )
x = ras.max_ex;
pcell = &ras.ycells[ras.ey];
@@ -465,7 +466,7 @@
/* min_ex - 1 horizontal position. */
ey -= ras.min_ey;
- if (ex > ras.max_ex)
+ if ( ex > ras.max_ex )
ex = ras.max_ex;
ex -= ras.min_ex;
@@ -1206,7 +1207,7 @@
x += (TCoord)ras.min_ex;
/* FT_Span.x is a 16-bit short, so limit our coordinates appropriately */
- if (x >= 32768)
+ if ( x >= 32768 )
x = 32767;
if ( coverage )
diff --git a/src/tools/ftrandom/ftrandom.c b/src/tools/ftrandom/ftrandom.c
index 16d4be0..fcff27b 100644
--- a/src/tools/ftrandom/ftrandom.c
+++ b/src/tools/ftrandom/ftrandom.c
@@ -84,6 +84,8 @@
static int error_count = 1;
static int error_fraction = 0;
+ static FT_F26Dot6 font_size = 12 * 64;
+
static struct fontlist
{
char* name;
@@ -156,7 +158,7 @@
if ( nohints )
load_flags |= FT_LOAD_NO_HINTING;
- FT_Set_Char_Size( face, 0, (int)( 12 * 64 ), 72, 72 );
+ FT_Set_Char_Size( face, 0, font_size, 72, 72 );
for ( gid = 0; gid < face->num_glyphs; ++gid )
{
@@ -543,6 +545,7 @@
fprintf( out, " --nohints Turn off hinting.\n" );
fprintf( out, " --rasterize Attempt to rasterize each glyph.\n" );
fprintf( out, " --results <dir> Directory in which to place the test fonts.\n" );
+ fprintf( out, " --size <float> Use the given font size for the tests.\n" );
fprintf( out, " --test <file> Run a single test on an already existing file.\n" );
}
@@ -611,6 +614,15 @@
rasterize = true;
else if ( strcmp( pt, "-results" ) == 0 )
results_dir = argv[++i];
+ else if ( strcmp( pt, "-size" ) == 0 )
+ {
+ font_size = (FT_F26Dot6)( strtod( argv[++i], &end ) * 64 );
+ if ( *end != '\0' || font_size < 64 )
+ {
+ fprintf( stderr, "Bad value for size: %s\n", argv[i] );
+ exit( 1 );
+ }
+ }
else if ( strcmp( pt, "-test" ) == 0 )
testfile = argv[++i];
else
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 90e4385..540e3aa 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -264,16 +264,16 @@
cont_limit = cont + n_contours;
/* check space for contours array + instructions count */
- if ( n_contours >= 0xFFF || p + (n_contours + 1) * 2 > limit )
+ if ( n_contours >= 0xFFF || p + ( n_contours + 1 ) * 2 > limit )
goto Invalid_Outline;
cont[0] = prev_cont = FT_NEXT_USHORT( p );
for ( cont++; cont < cont_limit; cont++ )
{
cont[0] = FT_NEXT_USHORT( p );
- if (cont[0] > prev_cont)
+ if ( cont[0] > prev_cont )
{
- /* unordered contours, this is invalid */
+ /* unordered contours: this is invalid */
error = FT_Err_Invalid_Table;
goto Fail;
}
@@ -591,13 +591,14 @@
FT_UInt start_point,
FT_UInt start_contour )
{
- zone->n_points = (FT_UShort)( load->outline.n_points - start_point );
- zone->n_contours = (FT_Short) ( load->outline.n_contours - start_contour );
- zone->org = load->extra_points + start_point;
- zone->cur = load->outline.points + start_point;
- zone->orus = load->extra_points2 + start_point;
- zone->tags = (FT_Byte*)load->outline.tags + start_point;
- zone->contours = (FT_UShort*)load->outline.contours + start_contour;
+ zone->n_points = (FT_UShort)( load->outline.n_points - start_point );
+ zone->n_contours = (FT_Short) ( load->outline.n_contours -
+ start_contour );
+ zone->org = load->extra_points + start_point;
+ zone->cur = load->outline.points + start_point;
+ zone->orus = load->extra_points2 + start_point;
+ zone->tags = (FT_Byte*)load->outline.tags + start_point;
+ zone->contours = (FT_UShort*)load->outline.contours + start_contour;
zone->first_point = (FT_UShort)start_point;
}
@@ -1336,11 +1337,11 @@
/* this provides additional offsets */
/* for each component's translation */
- if ( (error = TT_Vary_Get_Glyph_Deltas(
- face,
- glyph_index,
- &deltas,
- gloader->current.num_subglyphs + 4 )) != 0 )
+ if ( ( error = TT_Vary_Get_Glyph_Deltas(
+ face,
+ glyph_index,
+ &deltas,
+ gloader->current.num_subglyphs + 4 )) != 0 )
goto Exit;
subglyph = gloader->current.subglyphs + gloader->base.num_subglyphs;
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 080337c..4e35147 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -620,6 +620,7 @@
exec->pts.n_points = 0;
exec->pts.n_contours = 0;
+
exec->zp1 = exec->pts;
exec->zp2 = exec->pts;
exec->zp0 = exec->pts;
@@ -6151,7 +6152,7 @@
*/
twilight = CUR.GS.gep0 == 0 || CUR.GS.gep1 == 0 || CUR.GS.gep2 == 0;
- if ( BOUNDS(CUR.GS.rp1, CUR.zp0.n_points) )
+ if ( BOUNDS( CUR.GS.rp1, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = TT_Err_Invalid_Reference;
@@ -6302,8 +6303,8 @@
if ( p1 > p2 )
return;
- if ( BOUNDS(ref1, worker->max_points) ||
- BOUNDS(ref2, worker->max_points) )
+ if ( BOUNDS( ref1, worker->max_points ) ||
+ BOUNDS( ref2, worker->max_points ) )
return;
orus1 = worker->orus[ref1].x;
@@ -6404,6 +6405,7 @@
FT_UNUSED_ARG;
+
/* ignore empty outlines */
if ( CUR.pts.n_contours == 0 )
return;