Commit 9b3d1c75ad150b7964b7e8cc5619c0f5b49ec72f

David Turner 2000-07-07T19:47:34

- fixed a leak in the Type 1 driver - updated the CFF driver to support flex opcodes

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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
diff --git a/CHANGES b/CHANGES
index e3f1720..b78c57b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,23 @@
 LATEST CHANGES
 
+  - found a memory leak in the "type1" driver
+  
+  - incorporated Tom's patches to support flex operators correctly
+    in OpenType/CFF fonts.. Now all I need is to support pure CFF
+    and CEF fonts to be done with this driver.. :-)
+
+  - added the Windows FNT/FON driver in "src/winfonts". For now,
+    it always "simulates" a Unicode charmap, so it shouldn't be
+    considered completed right now..
+    
+    It's there to be more a proof of concept than anything else
+    anyway. The driver is a single C source file, that compiles
+    to 3 Kb of code..
+    
+    I'm still working on the PCF/BDF drivers.. but I'm too lazy
+    to finish them now..
+
+
   - CHANGES TO THE HIGH-LEVEL API
   
     o FT_Get_Kerning has a new parameter that allows you to select
diff --git a/include/freetype/config/ftmodule.h b/include/freetype/config/ftmodule.h
index 69ef5f7..57164c8 100644
--- a/include/freetype/config/ftmodule.h
+++ b/include/freetype/config/ftmodule.h
@@ -7,3 +7,4 @@ FT_USE_MODULE(ft_smooth_renderer_class)
 FT_USE_MODULE(tt_driver_class)
 FT_USE_MODULE(t1_driver_class)
 FT_USE_MODULE(t1z_driver_class)
+FT_USE_MODULE(winfnt_driver_class)
diff --git a/include/freetype/ftoutln.h b/include/freetype/ftoutln.h
index 04a9ece..12320d5 100644
--- a/include/freetype/ftoutln.h
+++ b/include/freetype/ftoutln.h
@@ -96,6 +96,11 @@
                                            FT_Int       numContours,
                                            FT_Outline*  outline );
 
+  FT_EXPORT_DEF(FT_Error)  FT_Outline_New_Internal( FT_Memory    memory,
+                                                    FT_UInt      numPoints,
+                                                    FT_Int       numContours,
+                                                    FT_Outline*  outline );
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -129,6 +134,9 @@
   FT_EXPORT_DEF(FT_Error)  FT_Outline_Done( FT_Library   library,
                                             FT_Outline*  outline );
 
+  FT_EXPORT_DEF( FT_Error )  FT_Outline_Done_Internal( FT_Memory    memory,
+                                                       FT_Outline*  outline );
+
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
diff --git a/include/freetype/internal/ftstream.h b/include/freetype/internal/ftstream.h
index f7dbd3b..e7a86e2 100644
--- a/include/freetype/internal/ftstream.h
+++ b/include/freetype/internal/ftstream.h
@@ -175,6 +175,10 @@ typedef struct FT_Frame_Field_
 #define GET_ULong()    FT_GET_MACRO( FT_Get_Long, FT_ULong )
 #define GET_Tag4()     FT_GET_MACRO( FT_Get_Long, FT_ULong )
 
+#define GET_ShortLE()   FT_GET_MACRO( FT_Get_ShortLE, FT_Short )
+#define GET_UShortLE()  FT_GET_MACRO( FT_Get_ShortLE, FT_UShort )
+#define GET_LongLE()    FT_GET_MACRO( FT_Get_LongLE,  FT_Short )
+#define GET_ULongLE()   FT_GET_MACRO( FT_Get_LongLE,  FT_Short )
 
 #define FT_READ_MACRO( func, type, var )        \
           ( var = (type)func( stream, &error ), \
@@ -189,6 +193,10 @@ typedef struct FT_Frame_Field_
 #define READ_Long( var )     FT_READ_MACRO( FT_Read_Long, FT_Long, var )
 #define READ_ULong( var )    FT_READ_MACRO( FT_Read_Long, FT_ULong, var )
 
+#define READ_ShortLE( var )    FT_READ_MACRO( FT_Read_ShortLE, FT_Short, var )
+#define READ_UShortLE( var )   FT_READ_MACRO( FT_Read_ShortLE, FT_UShort, var )
+#define READ_LongLE( var )     FT_READ_MACRO( FT_Read_LongLE, FT_Long, var )
+#define READ_ULongLE( var )    FT_READ_MACRO( FT_Read_LongLE, FT_ULong, var )
 
 
   BASE_DEF(void) FT_New_Memory_Stream( FT_Library  library,
@@ -234,6 +242,9 @@ typedef struct FT_Frame_Field_
 
   BASE_DEF(FT_Long)   FT_Get_Long( FT_Stream  stream );
 
+  BASE_DEF(FT_Short)  FT_Get_ShortLE( FT_Stream  stream );
+
+  BASE_DEF(FT_Long)   FT_Get_LongLE( FT_Stream  stream );
 
 
   BASE_DEF(FT_Char)   FT_Read_Char( FT_Stream  stream,
@@ -248,6 +259,12 @@ typedef struct FT_Frame_Field_
   BASE_DEF(FT_Long)   FT_Read_Long( FT_Stream  stream,
                                     FT_Error*  error );
 
+  BASE_DEF(FT_Short)  FT_Read_ShortLE( FT_Stream  stream,
+                                       FT_Error*  error );
+
+  BASE_DEF(FT_Long)   FT_Read_LongLE( FT_Stream  stream,
+                                      FT_Error*  error );
+
   BASE_DEF(FT_Error)  FT_Read_Fields( FT_Stream             stream,
                                       const FT_Frame_Field* fields,
                                       void*                 structure );
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 5ae839e..474063b 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1937,9 +1937,9 @@
     {
       metrics->x_scale = FT_DivFix( dim_x, face->units_per_EM );
       metrics->y_scale = FT_DivFix( dim_y, face->units_per_EM );
-    }
 
-    ft_recompute_scaled_metrics( face, metrics );
+      ft_recompute_scaled_metrics( face, metrics );
+    }
 
     if ( clazz->set_char_sizes )
       error = clazz->set_char_sizes( face->size,
@@ -2014,10 +2014,10 @@
 
       metrics->y_scale = FT_DivFix( metrics->y_ppem << 6,
                                     face->units_per_EM );
+                                    
+      ft_recompute_scaled_metrics( face, metrics );
     }
 
-    ft_recompute_scaled_metrics( face, metrics );
-
     if ( clazz->set_pixel_sizes )
       error = clazz->set_pixel_sizes( face->size,
                                       pixel_width,
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 1629abb..cceefd7 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -270,6 +270,39 @@
   }
 
 
+  FT_EXPORT_FUNC( FT_Error )  FT_Outline_New_Internal( FT_Memory    memory,
+                                                       FT_UInt      numPoints,
+                                                       FT_Int       numContours,
+                                                       FT_Outline*  outline )
+  {
+    FT_Error   error;
+
+
+    if ( !outline )
+      return FT_Err_Invalid_Argument;
+
+    *outline = null_outline;
+
+    if ( ALLOC_ARRAY( outline->points,   numPoints * 2L, FT_Pos    ) ||
+         ALLOC_ARRAY( outline->tags,     numPoints,      FT_Byte   ) ||
+         ALLOC_ARRAY( outline->contours, numContours,    FT_UShort ) )
+      goto Fail;
+
+    outline->n_points    = (FT_UShort)numPoints;
+    outline->n_contours  = (FT_Short)numContours;
+    outline->flags      |= ft_outline_owner;
+
+    return FT_Err_Ok;
+
+  Fail:
+    outline->flags |= ft_outline_owner;
+    FT_Outline_Done_Internal( memory, outline );
+
+    return error;
+  }
+
+
+
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
@@ -302,39 +335,16 @@
   /*    The reason why this function takes a `library' parameter is simply */
   /*    to use the library's memory allocator.                             */
   /*                                                                       */
-  BASE_FUNC( FT_Error )  FT_Outline_New( FT_Library   library,
-                                         FT_UInt      numPoints,
-                                         FT_Int       numContours,
-                                         FT_Outline*  outline )
+  FT_EXPORT_FUNC( FT_Error )  FT_Outline_New( FT_Library   library,
+                                              FT_UInt      numPoints,
+                                              FT_Int       numContours,
+                                              FT_Outline*  outline )
   {
-    FT_Error   error;
-    FT_Memory  memory;
-
-
-    if ( !outline )
-      return FT_Err_Invalid_Argument;
-
-    *outline = null_outline;
-    memory   = library->memory;
-
-    if ( ALLOC_ARRAY( outline->points,   numPoints * 2L, FT_Pos    ) ||
-         ALLOC_ARRAY( outline->tags,     numPoints,      FT_Byte   ) ||
-         ALLOC_ARRAY( outline->contours, numContours,    FT_UShort ) )
-      goto Fail;
-
-    outline->n_points    = (FT_UShort)numPoints;
-    outline->n_contours  = (FT_Short)numContours;
-    outline->flags      |= ft_outline_owner;
-
-    return FT_Err_Ok;
-
-  Fail:
-    outline->flags |= ft_outline_owner;
-    FT_Outline_Done( library, outline );
-
-    return error;
+    return FT_Outline_New_Internal( library->memory, numPoints,
+                                    numContours, outline );
+    
   }
-
+  
 
   /*************************************************************************/
   /*                                                                       */
@@ -414,12 +424,10 @@
   /*    The reason why this function takes an `outline' parameter is       */
   /*    simply to use FT_Free().                                           */
   /*                                                                       */
-  BASE_FUNC( FT_Error )  FT_Outline_Done( FT_Library   library,
-                                          FT_Outline*  outline )
-  {
-    FT_Memory  memory = library->memory;
-
 
+  FT_EXPORT_FUNC( FT_Error )  FT_Outline_Done_Internal( FT_Memory    memory,
+                                                        FT_Outline*  outline )
+  {
     if ( outline )
     {
       if ( outline->flags & ft_outline_owner )
@@ -435,7 +443,14 @@
     else
       return FT_Err_Invalid_Argument;
   }
+                                          
+                                          
+  FT_EXPORT_FUNC( FT_Error )  FT_Outline_Done( FT_Library   library,
+                                               FT_Outline*  outline )
 
+  {
+    return FT_Outline_Done_Internal( library->memory, outline );
+  }
 
   /*************************************************************************/
   /*                                                                       */
@@ -463,8 +478,8 @@
   /* <MT-Note>                                                             */
   /*    Yes.                                                               */
   /*                                                                       */
-  BASE_FUNC( void )  FT_Outline_Get_CBox( FT_Outline*  outline,
-                                          FT_BBox*     cbox )
+  FT_EXPORT_FUNC( void )  FT_Outline_Get_CBox( FT_Outline*  outline,
+                                               FT_BBox*     cbox )
   {
     FT_Pos  xMin, yMin, xMax, yMax;
 
@@ -529,9 +544,9 @@
   /* <MT-Note>                                                             */
   /*    Yes.                                                               */
   /*                                                                       */
-  BASE_FUNC( void )  FT_Outline_Translate( FT_Outline*  outline,
-                                           FT_Pos       xOffset,
-                                           FT_Pos       yOffset )
+  FT_EXPORT_FUNC( void )  FT_Outline_Translate( FT_Outline*  outline,
+                                                FT_Pos       xOffset,
+                                                FT_Pos       yOffset )
   {
     FT_UShort   n;
     FT_Vector*  vec = outline->points;
@@ -562,7 +577,7 @@
   /*    This functions toggles the bit flag `ft_outline_reverse_fill' in   */
   /*    the outline's `flags' field.                                       */
   /*                                                                       */
-  BASE_FUNC( void )  FT_Outline_Reverse( FT_Outline*  outline )
+  FT_EXPORT_FUNC( void )  FT_Outline_Reverse( FT_Outline*  outline )
   {
     FT_UShort  n;
     FT_Int     first, last;
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index 03413ee..b79ccba 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -301,6 +301,24 @@
   }
 
 
+  BASE_FUNC( FT_Short )  FT_Get_ShortLE( FT_Stream  stream )
+  {
+    FT_Byte*  p;
+    FT_Short  result;
+
+
+    FT_Assert( stream && stream->cursor );
+
+    result         = 0;
+    p              = stream->cursor;
+    if ( p + 1 < stream->limit )
+      result       = NEXT_ShortLE( p );
+    stream->cursor = p;
+
+    return result;
+  }
+
+
   BASE_FUNC( FT_Long )  FT_Get_Offset( FT_Stream  stream )
   {
     FT_Byte*  p;
@@ -335,6 +353,23 @@
   }
 
 
+  BASE_FUNC( FT_Long )  FT_Get_LongLE( FT_Stream  stream )
+  {
+    FT_Byte*  p;
+    FT_Long   result;
+
+
+    FT_Assert( stream && stream->cursor );
+
+    result         = 0;
+    p              = stream->cursor;
+    if ( p + 3 < stream->limit )
+      result       = NEXT_LongLE( p );
+    stream->cursor = p;
+    return result;
+  }
+
+
   BASE_FUNC( FT_Char )  FT_Read_Char( FT_Stream  stream,
                                       FT_Error*  error )
   {
@@ -417,6 +452,52 @@
   }
 
 
+  BASE_FUNC( FT_Short )  FT_Read_ShortLE( FT_Stream  stream,
+                                          FT_Error*  error )
+  {
+    FT_Byte   reads[2];
+    FT_Byte*  p = 0;
+    FT_Short  result = 0;
+
+
+    FT_Assert( stream );
+
+    *error = FT_Err_Ok;
+
+    if ( stream->pos + 1 < stream->size )
+    {
+      if ( stream->read )
+      {
+        if ( stream->read( stream, stream->pos, reads, 2L ) != 2L )
+          goto Fail;
+
+        p = reads;
+      }
+      else
+      {
+        p = stream->base + stream->pos;
+      }
+
+      if ( p )
+        result = NEXT_ShortLE( p );
+    }
+    else
+      goto Fail;
+
+    stream->pos += 2;
+
+    return result;
+
+  Fail:
+    *error = FT_Err_Invalid_Stream_Operation;
+    FT_ERROR(( "FT_Read_Short:" ));
+    FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
+               stream->pos, stream->size ));
+
+    return 0;
+  }
+
+
   BASE_FUNC( FT_Long )  FT_Read_Offset( FT_Stream  stream,
                                         FT_Error*  error )
   {
@@ -509,6 +590,54 @@
   }
 
 
+  BASE_FUNC( FT_Long )  FT_Read_LongLE( FT_Stream  stream,
+                                        FT_Error*  error )
+  {
+    FT_Byte   reads[4];
+    FT_Byte*  p = 0;
+    FT_Long   result = 0;
+
+
+    FT_Assert( stream );
+
+    *error = FT_Err_Ok;
+
+    if ( stream->pos + 3 < stream->size )
+    {
+      if ( stream->read )
+      {
+        if ( stream->read( stream, stream->pos, reads, 4L ) != 4L )
+          goto Fail;
+
+        p = reads;
+      }
+      else
+      {
+        p = stream->base + stream->pos;
+      }
+
+      if ( p )
+        result = NEXT_LongLE( p );
+    }
+    else
+      goto Fail;
+
+    stream->pos += 4;
+
+    return result;
+
+  Fail:
+    FT_ERROR(( "FT_Read_Long:" ));
+    FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
+               stream->pos, stream->size ));
+    *error = FT_Err_Invalid_Stream_Operation;
+
+    return 0;
+  }
+
+
+
+
   BASE_FUNC( FT_Error ) FT_Read_Fields( FT_Stream              stream,
                                         const FT_Frame_Field*  fields,
                                         void*                  structure )
diff --git a/src/cff/t2gload.c b/src/cff/t2gload.c
index 03bace5..12335af 100644
--- a/src/cff/t2gload.c
+++ b/src/cff/t2gload.c
@@ -464,19 +464,17 @@
                          FT_Pos       x,
                          FT_Pos       y )
   {
+    FT_Error  error;
+    
     /* test whether we are building a new contour */
     if ( !builder->path_begun )
     {
-      FT_Error  error;
-
-
       builder->path_begun = 1;
       error = add_contour( builder );
-      if ( error )
-        return error;
+      if ( !error )
+        error = add_point1( builder, x, y );
     }
-
-    return add_point1( builder, x, y );
+    return error;
   }
 
 
@@ -901,7 +899,7 @@
           break;
 
         case t2_op_hmoveto:
-          FT_TRACE4(( " vmoveto" ));
+          FT_TRACE4(( " hmoveto" ));
 
           close_contour( builder );
           builder->path_begun = 0;
@@ -1152,6 +1150,7 @@
           }
           break;
 
+
         case t2_op_rcurveline:
           {
             FT_Int  num_curves = ( num_args - 2 ) / 6;
@@ -1192,6 +1191,198 @@
           }
           break;
 
+
+
+        case t2_op_hflex1:
+          {
+            FT_Pos start_y;
+   
+            FT_TRACE4(( " hflex1" ));
+   
+            args = stack;
+   
+            /* Adding five more points; 4 control points, 1 on curve point. */
+            if (start_point ( builder, x, y ) || check_points ( builder, 5 ) )
+              goto Memory_Error;
+   
+            /* Record the starting point's y postion for later use */
+            start_y = y;
+   
+            /* first control point */
+            x += args[0];
+            y += args[1];
+            add_point( builder, x, y, 0 );
+   
+            /* second control point */
+            x += args[2];
+            y += args[3];
+            add_point( builder, x, y, 0 );
+   
+            /* join point; on curve, with y-value the same as the last */
+            /* control point's y-value                                 */
+            x += args[4];
+            add_point( builder, x, y, 1 );
+            
+            /* third control point, with y-value the same as the join */
+            /* point's y-value                                        */
+            x += args[5];
+            add_point( builder, x, y, 0 );
+   
+            /* fourth control point */
+            x += args[6];
+            y += args[7];
+            add_point( builder, x, y, 0 );
+   
+            /* ending point, with y-value the same as the start  */
+            /* point's y-value. we don't add this point, though. */
+            x += args[8];
+            y  = start_y;
+   
+            args = stack;
+            break;
+          }
+
+
+        case t2_op_hflex:
+          {
+            FT_Pos start_y;
+ 
+            FT_TRACE4(( " hflex" ));
+ 
+            args = stack;
+ 
+            /* Adding five more points; 4 control points, 1 on curve point. */
+            if (start_point ( builder, x, y ) || check_points ( builder, 5 ) )
+ 
+              goto Memory_Error;
+ 
+            /* Record the starting point's y postion for later use */
+            start_y = y;
+ 
+            /* first control point */
+            x += args[0];
+            add_point( builder, x, y, 0 );
+ 
+            /* second control point */
+            x += args[1];
+            y += args[2];
+            add_point( builder, x, y, 0 );
+  
+            /* join point; on curve, with y-value the same as the last */
+            /* control point's y-value                                 */
+            x += args[3];
+            add_point( builder, x, y, 1 );
+ 
+            /* third control point, with y-value the same as the join */
+            /* point's y-value                                        */
+            x += args[4];
+            add_point( builder, x, y, 0 );
+ 
+            /* fourth control point */
+            x += args[5];
+            y  = start_y;
+            add_point( builder, x, y, 0 );
+ 
+            /* ending point, with y-value the same as the start point's */
+            /* y-value we don't add this point, though.                 */
+            x += args[6];
+ 
+            args = stack;
+            break;
+          }
+
+
+        case t2_op_flex1:
+          {
+            FT_Pos start_x, start_y; /* record start x,y values for alter use */
+            FT_Int dx = 0, dy = 0;   /* used in hort./vert. algorithm below   */
+            FT_Int hort_flag, count;
+ 
+            FT_TRACE4(( " flex1" ));
+   
+            /* Adding five more points; 4 control points, 1 on curve point. */
+            if (start_point ( builder, x, y ) || check_points ( builder, 5 ) )
+               goto Memory_Error;
+   
+             /* Record the starting point's x,y postion for later use */
+            start_x = x;
+            start_y = y;
+   
+            /* XXXX: figure out if this is supposed to be a horizontal or */
+            /* vertical flex. The Type 2 specification is vague...        */
+   
+            args = stack;
+            
+            /* grab up to the last argument */
+            while ( args < decoder->top - 1)
+            {
+              dx += args[0];
+              dy += args[1];
+              args += 2;
+            }
+   
+            /* rewind */
+            args = stack;
+   
+            if ( dx < 0 ) dx = -dx;
+            if ( dy < 0 ) dy = -dy;
+   
+            /* strange test, but here it is... */
+            hort_flag = (dx > dy);
+   
+            for ( count = 5; count > 0; count-- )
+            {
+              x += args[0];
+              y += args[1];
+              add_point( builder, x, y, (FT_Bool)(count == 3) );
+              args += 2;
+            }
+   
+            if (hort_flag)
+            {
+              x += args[0];
+              y  = start_y;
+            }
+            else
+            {
+              x  = start_x;
+              y += args[0];
+            }
+   
+            args = stack;
+            break;
+           }
+  
+
+        case t2_op_flex:
+          {
+            FT_UInt   count;
+            
+            FT_TRACE4(( " flex" ));
+   
+             if (start_point ( builder, x, y ) || check_points ( builder, 5 ) )
+               goto Memory_Error;
+   
+            args = stack;
+            for ( count = 5; count > 0; count-- )
+            {
+              x += args[0];
+              y += args[1];
+              add_point( builder, x, y, (FT_Bool)(count == 3) );
+              args += 2;
+            }
+            
+            x += args[0];
+            y += args[1];
+  
+            args = stack;
+          }
+          break;
+
+
+
+
+
         case t2_op_endchar:
           FT_TRACE4(( " endchar" ));
 
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index a5957ae..b9a94f5 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -239,7 +239,7 @@
   const CID_Field_Rec  t1_field_records[] =
   {
 #include <cidtokens.h>
-    { 0 }
+    { 0, 0, 0, 0, 0, 0, 0, 0 }
   };
 
 
diff --git a/src/type1/t1tokens.c b/src/type1/t1tokens.c
index b9d7ca9..4487b49 100644
--- a/src/type1/t1tokens.c
+++ b/src/type1/t1tokens.c
@@ -373,6 +373,7 @@
     return T1_Err_Ok;
 
   Fail:
+    FREE( tokzer->base );
     FREE( tokzer );
     return error;
   }