@@ -203,8 +203,9 @@ void GlyphToType3::PSConvert(TTStreamWriter& stream)
203
203
/* Step thru the coutours. */
204
204
/* I believe that a contour is a detatched */
205
205
/* set of curves and lines. */
206
- i=j=k=0 ;
207
- while ( i < num_ctr )
206
+ for (i = j = k = 0 ;
207
+ i != NOMOREOUTCTR && i < num_ctr;
208
+ k = nextinctr (i, k), (k == NOMOREINCTR && (i = k = nextoutctr (i))))
208
209
{
209
210
// A TrueType contour consists of on-path and off-path points.
210
211
// Two consecutive on-path points are to be joined with a
@@ -224,24 +225,13 @@ void GlyphToType3::PSConvert(TTStreamWriter& stream)
224
225
}
225
226
}
226
227
227
- // For any two consecutive off-path points, insert the implied
228
- // on-path point.
229
-
230
228
if (points.size () == 0 ) {
231
- k=nextinctr (i,k);
232
-
233
- if (k==NOMOREINCTR)
234
- {
235
- i=k=nextoutctr (i);
236
- }
237
-
238
- if (i==NOMOREOUTCTR)
239
- {
240
- break ;
241
- }
229
+ // Don't try to access the last element of an empty list
242
230
continue ;
243
231
}
244
232
233
+ // For any two consecutive off-path points, insert the implied
234
+ // on-path point.
245
235
FlaggedPoint prev = points.back ();
246
236
for (std::list<FlaggedPoint>::iterator it = points.begin ();
247
237
it != points.end ();
@@ -270,44 +260,35 @@ void GlyphToType3::PSConvert(TTStreamWriter& stream)
270
260
points.push_back (points.front ());
271
261
}
272
262
273
- // For output, a vector is more convenient than a list.
274
- std::vector<FlaggedPoint> points_v (points.begin (), points.end ());
275
263
// The first point
276
264
stack (stream, 3 );
277
- PSMoveto (stream, points_v .front ().x , points_v .front ().y );
265
+ PSMoveto (stream, points .front ().x , points .front ().y );
278
266
279
267
// Step through the remaining points
280
- for (size_t p = 1 ; p < points_v.size (); )
268
+ std::list<FlaggedPoint>::const_iterator it = points.begin ();
269
+ for (it++; it != points.end (); /* incremented inside */ )
281
270
{
282
- const FlaggedPoint& point = points_v. at (p) ;
271
+ const FlaggedPoint& point = *it ;
283
272
if (point.flag == ON_PATH)
284
273
{
285
274
stack (stream, 3 );
286
275
PSLineto (stream, point.x , point.y );
287
- p ++;
276
+ it ++;
288
277
} else {
289
- assert (points_v.at (p-1 ).flag == ON_PATH);
290
- assert (points_v.at (p+1 ).flag == ON_PATH);
278
+ std::list<FlaggedPoint>::const_iterator prev = it, next = it;
279
+ prev--;
280
+ next++;
281
+ assert (prev->flag == ON_PATH);
282
+ assert (next->flag == ON_PATH);
291
283
stack (stream, 7 );
292
284
PSCurveto (stream,
293
- points_v. at (p- 1 ). x , points_v. at (p- 1 ). y ,
285
+ prev-> x , prev-> y ,
294
286
point.x , point.y ,
295
- points_v.at (p+1 ).x , points_v.at (p+1 ).y );
296
- p += 2 ;
287
+ next->x , next->y );
288
+ it++;
289
+ it++;
297
290
}
298
291
}
299
-
300
- k=nextinctr (i,k);
301
-
302
- if (k==NOMOREINCTR)
303
- {
304
- i=k=nextoutctr (i);
305
- }
306
-
307
- if (i==NOMOREOUTCTR)
308
- {
309
- break ;
310
- }
311
292
}
312
293
313
294
/* Now, we can fill the whole thing. */
0 commit comments