Commit 08fdac980acd8e2ef3a17685f4f32fbe3625b96f

David Turner 2000-02-21T16:01:33

fixed a bug in the glyph loader that caused a memory block to be freed twice. Also performed changes to use the new glyph zone object that has appeared in ftobjs.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
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
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index f7a27a2..3b012f6 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -153,8 +153,8 @@
   /*    assemble composite glyphs.                                         */
   /*                                                                       */
   static
-  void  mount_zone( TT_GlyphZone*  source,
-                    TT_GlyphZone*  target )
+  void  mount_zone( FT_GlyphZone*  source,
+                    FT_GlyphZone*  target )
   {
     TT_UInt  np;
     TT_Int   nc;
@@ -164,7 +164,7 @@
 
     target->org   = source->org + np;
     target->cur   = source->cur + np;
-    target->touch = source->touch + np;
+    target->flags = source->flags + np;
 
     target->contours = source->contours + nc;
 
@@ -194,7 +194,7 @@
   {
     TT_Error       error;
     FT_Stream      stream = load->stream;
-    TT_GlyphZone*  zone   = &load->zone;
+    FT_GlyphZone*  zone   = &load->zone;
     TT_Face        face = load->face;
 
     TT_UShort      n_ins;
@@ -258,11 +258,14 @@
     }
 
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
-    MEM_Copy( load->exec->glyphIns, stream->cursor, n_ins );
+    if ( (load->load_flags & (FT_LOAD_NO_SCALE|FT_LOAD_NO_HINTING))==0 )
+    {
+      MEM_Copy( load->exec->glyphIns, stream->cursor, n_ins );
 
-    error = TT_Set_CodeRange( load->exec, tt_coderange_glyph,
-                              load->exec->glyphIns, n_ins );
-    if (error) goto Fail;
+      error = TT_Set_CodeRange( load->exec, tt_coderange_glyph,
+                                load->exec->glyphIns, n_ins );
+      if (error) goto Fail;
+    }
 #endif
 
     stream->cursor += n_ins;
@@ -271,7 +274,7 @@
     /* reading the point flags                                           */
 
     {    
-      TT_Byte*  flag  = load->zone.touch;
+      TT_Byte*  flag  = load->zone.flags;
       TT_Byte*  limit = flag + n_points;
       TT_Byte   c, count;
       
@@ -292,7 +295,7 @@
     {
       TT_Vector*  vec   = zone->org;
       TT_Vector*  limit = vec + n_points;
-      TT_Byte*    flag  = zone->touch;
+      TT_Byte*    flag  = zone->flags;
       TT_Pos      x     = 0;
       
       for ( ; vec < limit; vec++, flag++ )
@@ -313,12 +316,12 @@
     }
 
     /*********************************************************************/
-    /* reading the YX coordinates                                         */
+    /* reading the Y coordinates                                         */
 
     {
       TT_Vector*  vec   = zone->org;
       TT_Vector*  limit = vec + n_points;
-      TT_Byte*    flag  = zone->touch;
+      TT_Byte*    flag  = zone->flags;
       TT_Pos      x     = 0;
       
       for ( ; vec < limit; vec++, flag++ )
@@ -362,10 +365,10 @@
         
       /* clear the touch flags */
       for ( n = 0; n < n_points; n++ )
-        zone->touch[n] &= FT_Curve_Tag_On;
+        zone->flags[n] &= FT_Curve_Tag_On;
 
-      zone->touch[n_points    ] = 0;
-      zone->touch[n_points + 1] = 0;
+      zone->flags[n_points    ] = 0;
+      zone->flags[n_points + 1] = 0;
     }
     /* Note that we return two more points that are not */
     /* part of the glyph outline.                       */
@@ -418,7 +421,7 @@
           load->exec->is_composite     = FALSE;
           load->exec->pedantic_hinting = (TT_Bool)(load->load_flags & FT_LOAD_PEDANTIC);
           load->exec->pts              = *zone;
-          load->exec->pts.n_points   += 2;
+          load->exec->pts.n_points    += 2;
 
           error = TT_Run_Context( load->exec, debug );
           if ( error && load->exec->pedantic_hinting )
@@ -485,6 +488,7 @@
     
     x_scale = 0x10000;
     y_scale = 0x10000;
+    if ( (loader->load_flags & FT_LOAD_NO_SCALE)==0 )
     {
       x_scale = loader->size->root.metrics.x_scale;
       y_scale = loader->size->root.metrics.y_scale;
@@ -819,7 +823,7 @@
           TT_UShort       n_ins;
           TT_ExecContext  exec = loader->exec;
           TT_UInt         n_points = loader->base.n_points;
-          TT_GlyphZone*   pts;
+          FT_GlyphZone*   pts;
           TT_Vector*      pp1;
           
           /* read size of instructions */
@@ -857,8 +861,8 @@
           pp1[0] = loader->pp1;
           pp1[1] = loader->pp2;
       
-          pts->touch[num_points - 1] = 0;
-          pts->touch[num_points - 2] = 0;
+          pts->flags[num_points + 1] = 0;
+          pts->flags[num_points + 2] = 0;
       
           /* if hinting, round the phantom points */
           if ( IS_HINTED(loader->load_flags) )
@@ -870,7 +874,7 @@
           {
             TT_UInt  k;
             for ( k = 0; k < n_points; k++ )
-              pts->touch[k] &= FT_Curve_Tag_On;
+              pts->flags[k] &= FT_Curve_Tag_On;
           }
       
           cur_to_org( n_points, pts );
@@ -946,7 +950,7 @@
       for ( u = 0; u < num_points + 2; u++ )
       {
         glyph->outline.points[u] = loader->base.cur[u];
-        glyph->outline.flags [u] = loader->base.touch[u];
+        glyph->outline.flags [u] = loader->base.flags[u];
       }
 
       for ( u = 0; u < num_contours; u++ )
@@ -1148,6 +1152,7 @@
     FT_Memory        memory;
     TT_Error         error;
     TT_Loader        loader;
+    FT_GlyphZone*    zone;
     
     face   = (TT_Face)glyph->face;
     sfnt   = (SFNT_Interface*)face->sfnt;
@@ -1209,11 +1214,23 @@
     if (error)
     {
       FT_ERROR(( "TT.GLoad: could not access glyph table\n" ));
-      return error;
+      goto Exit;
     }
 
     MEM_Set( &loader, 0, sizeof(loader) );
 
+    /* update the glyph zone bounds */
+    zone   = &((TT_Driver)face->root.driver)->zone;
+    error  = FT_Update_GlyphZone( zone,
+                                  face->root.max_points,
+                                  face->root.max_contours );
+    if (error)
+    {
+      FT_ERROR(( "TT.GLoad: could not update loader glyph zone\n" ));
+      goto Exit;
+    }
+    loader.base = *zone;
+
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
     if ( size )
     {
@@ -1234,11 +1251,7 @@
       glyph->outline.high_precision = ( size->root.metrics.y_ppem < 24 );
 
     /************************************************************************/
-    /* let's initialise our loader now                                      */
-    error = TT_New_GlyphZone( memory, &loader.base,
-                              face->root.max_points, face->root.max_contours );
-    if (error) return error;
-
+    /* let's initialise the rest of our loader now                          */
     loader.left_points   = face->root.max_points;
     loader.left_contours = face->root.max_contours;
     loader.load_flags    = load_flags;
@@ -1267,7 +1280,7 @@
       TT_Done_Context( loader.exec );
 #endif
 
-    TT_Done_GlyphZone( memory, &loader.base );
+  Exit:
     return error;
   }
 
diff --git a/src/truetype/ttgload.h b/src/truetype/ttgload.h
index ac4f29e..5350d64 100644
--- a/src/truetype/ttgload.h
+++ b/src/truetype/ttgload.h
@@ -53,8 +53,8 @@
     TT_ULong        glyf_offset;
         
     /* the zone where we load our glyphs */
-    TT_GlyphZone    base;
-    TT_GlyphZone    zone;
+    FT_GlyphZone    base;
+    FT_GlyphZone    zone;
     
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
     TT_ExecContext  exec;
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 85d2418..b0009e1 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -383,7 +383,6 @@
     exec->loadSize = 0;
 
     /* points zone */
-    TT_Done_GlyphZone( exec->memory, &exec->pts );
     exec->maxPoints   = 0;
     exec->maxContours = 0;
 
@@ -518,57 +517,6 @@
   }
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    Update_Zone                                                        */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Checks the size of a zone and reallocates it if necessary.         */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    newPoints   :: The new capacity for points.  We add two slots for  */
-  /*                   phantom points.                                     */
-  /*                                                                       */
-  /*    newContours :: The new capacity for contours.                      */
-  /*                                                                       */
-  /* <InOut>                                                               */
-  /*    zone        :: The address of the target zone.                     */
-  /*                                                                       */
-  /*    maxPoints   :: The address of the zone's current capacity for      */
-  /*                   points.                                             */
-  /*                                                                       */
-  /*    maxContours :: The address of the zone's current capacity for      */
-  /*                   contours.                                           */
-  /*                                                                       */
-  static
-  TT_Error  Update_Zone( FT_Memory      memory,
-                         TT_GlyphZone*  zone,
-                         TT_UShort*     maxPoints,
-                         TT_Short*      maxContours,
-                         TT_UShort      newPoints,
-                         TT_Short       newContours )
-  {
-    newPoints += 2;
-
-    if ( *maxPoints < newPoints || *maxContours < newContours )
-    {
-      TT_Error  error;
-
-
-      TT_Done_GlyphZone( memory, zone );
-
-      error = TT_New_GlyphZone( memory, zone, newPoints, newContours );
-      if ( error )
-        return error;
-
-      *maxPoints   = newPoints;
-      *maxContours = newContours;
-    }
-
-    return TT_Err_Ok;
-  }
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -601,7 +549,6 @@
     TT_MaxProfile*  maxp;
     TT_Error        error;
 
-
     exec->face = face;
     maxp       = &face->max_profile;
     exec->size = size;
@@ -665,16 +612,6 @@
     if ( error )
       return error;
 
-    /* XXX: Update_Zone() reserves two positions for the phantom points! */
-    error = Update_Zone( exec->memory,
-                         &exec->pts,
-                         &exec->maxPoints,
-                         &exec->maxContours,
-                         exec->face->root.max_points,
-                         exec->face->root.max_contours );
-    if ( error )
-      return error;
-
     exec->pts.n_points   = 0;
     exec->pts.n_contours = 0;
 
@@ -1427,7 +1364,7 @@
   /*    zone     :: The affected glyph zone.                               */
   /*                                                                       */
   static
-  void  Direct_Move( EXEC_OP_ TT_GlyphZone*  zone,
+  void  Direct_Move( EXEC_OP_ FT_GlyphZone*  zone,
                               TT_UShort      point,
                               TT_F26Dot6     distance )
   {
@@ -1446,7 +1383,7 @@
                                        v * 0x10000L,
                                        CUR.F_dot_P );
 #endif
-      zone->touch[point] |= FT_Curve_Tag_Touch_X;
+      zone->flags[point] |= FT_Curve_Tag_Touch_X;
     }
 
     v = CUR.GS.freeVector.y;
@@ -1461,7 +1398,7 @@
                                        v * 0x10000L,
                                        CUR.F_dot_P );
 #endif
-      zone->touch[point] |= FT_Curve_Tag_Touch_Y;
+      zone->flags[point] |= FT_Curve_Tag_Touch_Y;
     }
   }
 
@@ -1476,26 +1413,26 @@
   /*************************************************************************/
 
   static
-  void  Direct_Move_X( EXEC_OP_ TT_GlyphZone*  zone,
+  void  Direct_Move_X( EXEC_OP_ FT_GlyphZone*  zone,
                                 TT_UShort      point,
                                 TT_F26Dot6     distance )
   {
     UNUSED_EXEC;
 
     zone->cur[point].x += distance;
-    zone->touch[point] |= FT_Curve_Tag_Touch_X;
+    zone->flags[point] |= FT_Curve_Tag_Touch_X;
   }
 
 
   static
-  void  Direct_Move_Y( EXEC_OP_ TT_GlyphZone*  zone,
+  void  Direct_Move_Y( EXEC_OP_ FT_GlyphZone*  zone,
                                 TT_UShort      point,
                                 TT_F26Dot6     distance )
   {
     UNUSED_EXEC;
 
     zone->cur[point].y += distance;
-    zone->touch[point] |= FT_Curve_Tag_Touch_Y;
+    zone->flags[point] |= FT_Curve_Tag_Touch_Y;
   }
 
 
@@ -4854,7 +4791,7 @@
         }
       }
       else
-        CUR.pts.touch[point] ^= FT_Curve_Tag_On;
+        CUR.pts.flags[point] ^= FT_Curve_Tag_On;
 
       CUR.GS.loop--;
     }
@@ -4888,7 +4825,7 @@
     }
 
     for ( I = L; I <= K; I++ )
-      CUR.pts.touch[I] |= FT_Curve_Tag_On;
+      CUR.pts.flags[I] |= FT_Curve_Tag_On;
   }
 
 
@@ -4916,17 +4853,17 @@
     }
 
     for ( I = L; I <= K; I++ )
-      CUR.pts.touch[I] &= ~FT_Curve_Tag_On;
+      CUR.pts.flags[I] &= ~FT_Curve_Tag_On;
   }
 
 
   static
   TT_Bool  Compute_Point_Displacement( EXEC_OP_ TT_F26Dot6*    x,
                                                 TT_F26Dot6*    y,
-                                                TT_GlyphZone*  zone,
+                                                FT_GlyphZone*  zone,
                                                 TT_UShort*     refp )
   {
-    TT_GlyphZone  zp;
+    FT_GlyphZone  zp;
     TT_UShort     p;
     TT_F26Dot6    d;
 
@@ -4979,14 +4916,14 @@
     {
       CUR.zp2.cur[point].x += dx;
       if ( touch )
-        CUR.zp2.touch[point] |= FT_Curve_Tag_Touch_X;
+        CUR.zp2.flags[point] |= FT_Curve_Tag_Touch_X;
     }
 
     if ( CUR.GS.freeVector.y != 0 )
     {
       CUR.zp2.cur[point].y += dy;
       if ( touch )
-        CUR.zp2.touch[point] |= FT_Curve_Tag_Touch_Y;
+        CUR.zp2.flags[point] |= FT_Curve_Tag_Touch_Y;
     }
   }
 
@@ -5000,7 +4937,7 @@
   static
   void  Ins_SHP( INS_ARG )
   {
-    TT_GlyphZone  zp;
+    FT_GlyphZone  zp;
     TT_UShort     refp;
 
     TT_F26Dot6    dx,
@@ -5053,7 +4990,7 @@
   static
   void  Ins_SHC( INS_ARG )
   {
-    TT_GlyphZone zp;
+    FT_GlyphZone zp;
     TT_UShort    refp;
     TT_F26Dot6   dx,
                  dy;
@@ -5109,7 +5046,7 @@
   static
   void  Ins_SHZ( INS_ARG )
   {
-    TT_GlyphZone zp;
+    FT_GlyphZone zp;
     TT_UShort    refp;
     TT_F26Dot6   dx,
                  dy;
@@ -5660,7 +5597,7 @@
     dx = CUR.zp0.cur[b0].x - CUR.zp1.cur[a0].x;
     dy = CUR.zp0.cur[b0].y - CUR.zp1.cur[a0].y;
 
-    CUR.zp2.touch[point] |= FT_Curve_Tag_Touch_Both;
+    CUR.zp2.flags[point] |= FT_Curve_Tag_Touch_Both;
 
     discriminant = TT_MULDIV( dax, -dby, 0x40 ) +
                    TT_MULDIV( day, dbx, 0x40 );
@@ -5843,7 +5780,7 @@
     if ( CUR.GS.freeVector.y != 0 )
       mask &= ~FT_Curve_Tag_Touch_Y;
 
-    CUR.zp0.touch[point] &= mask;
+    CUR.zp0.flags[point] &= mask;
   }
 
 
@@ -5996,7 +5933,7 @@
       end_point   = CUR.pts.contours[contour];
       first_point = point;
 
-      while ( point <= end_point && (CUR.pts.touch[point] & mask) == 0 )
+      while ( point <= end_point && (CUR.pts.flags[point] & mask) == 0 )
         point++;
 
       if ( point <= end_point )
@@ -6008,7 +5945,7 @@
 
         while ( point <= end_point )
         {
-          if ( (CUR.pts.touch[point] & mask) != 0 )
+          if ( (CUR.pts.flags[point] & mask) != 0 )
           {
             if ( point > 0 )
               Interp( cur_touched + 1,
@@ -7657,8 +7594,8 @@
 
     TT_Error  error = 0;
 
-    TT_GlyphZone  save;
-    TT_GlyphZone  pts;
+    FT_GlyphZone  save;
+    FT_GlyphZone  pts;
 
 #define TT_Round_Off             5
 #define TT_Round_To_Half_Grid    0
@@ -7695,7 +7632,7 @@
 
     MEM_Alloc( save.org, sizeof ( TT_Vector ) * save.n_points );
     MEM_Alloc( save.cur, sizeof ( TT_Vector ) * save.n_points );
-    MEM_Alloc( save.touch, sizeof ( TT_Byte ) * save.n_points );
+    MEM_Alloc( save.flags, sizeof ( TT_Byte ) * save.n_points );
 
     exc->instruction_trap = 1;
 
@@ -7858,7 +7795,7 @@
 
       MEM_Copy( save.org,   pts.org, pts.n_points * sizeof ( TT_Vector ) );
       MEM_Copy( save.cur,   pts.cur, pts.n_points * sizeof ( TT_Vector ) );
-      MEM_Copy( save.touch, pts.touch, pts.n_points );
+      MEM_Copy( save.flags, pts.flags, pts.n_points );
 
       /* a return indicate the last command */
       if (ch == '\r')
@@ -7912,14 +7849,14 @@
         if ( save.org[A].y != pts.org[A].y ) diff |= 2;
         if ( save.cur[A].x != pts.cur[A].x ) diff |= 4;
         if ( save.cur[A].y != pts.cur[A].y ) diff |= 8;
-        if ( save.touch[A] != pts.touch[A] ) diff |= 16;
+        if ( save.flags[A] != pts.flags[A] ) diff |= 16;
 
         if ( diff )
         {
           FT_TRACE0(( "%02hx  ", A ));
 
           if ( diff & 16 ) temp = "(%01hx)"; else temp = " %01hx ";
-          FT_TRACE0(( temp, save.touch[A] & 7 ));
+          FT_TRACE0(( temp, save.flags[A] & 7 ));
 
           if ( diff & 1 ) temp = "(%08lx)"; else temp = " %08lx ";
           FT_TRACE0(( temp, save.org[A].x ));
@@ -7938,7 +7875,7 @@
           FT_TRACE0(( "%02hx  ", A ));
 
           if ( diff & 16 ) temp = "[%01hx]"; else temp = " %01hx ";
-          FT_TRACE0(( temp, pts.touch[A] & 7 ));
+          FT_TRACE0(( temp, pts.flags[A] & 7 ));
 
           if ( diff & 1 ) temp = "[%08lx]"; else temp = " %08lx ";
           FT_TRACE0(( temp, pts.org[A].x ));
diff --git a/src/truetype/ttinterp.h b/src/truetype/ttinterp.h
index 96cd4a5..1819d7f 100644
--- a/src/truetype/ttinterp.h
+++ b/src/truetype/ttinterp.h
@@ -71,7 +71,7 @@
                                                  TT_F26Dot6  compensation );
 
   /* Point displacement along the freedom vector routine */
-  typedef void  (*TT_Move_Func)( EXEC_OP_ TT_GlyphZone*  zone,
+  typedef void  (*TT_Move_Func)( EXEC_OP_ FT_GlyphZone*  zone,
                                           TT_UInt        point,
                                           TT_F26Dot6     distance );
 
@@ -125,7 +125,7 @@
     TT_Long         args;
     TT_UInt         new_top;    /* new top after exec.  */
 
-    TT_GlyphZone    zp0,        /* zone records */
+    FT_GlyphZone    zp0,        /* zone records */
                     zp1,
                     zp2,
                     pts,
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index 6c60d48..07cd145 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -49,75 +49,6 @@
   /*************************************************************************/
   /*                                                                       */
   /* <Function>                                                            */
-  /*    TT_New_GlyphZone                                                   */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Allocates a new glyph zone.                                        */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    memory      :: A handle to the current memory object.              */
-  /*                                                                       */
-  /*    maxPoints   :: The capacity of glyph zone in points.               */
-  /*                                                                       */
-  /*    maxContours :: The capacity of glyph zone in contours.             */
-  /*                                                                       */
-  /* <InOut>                                                               */
-  /*    pts         :: A pointer to the target glyph zone record.          */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    TrueType error code.  0 means success.                             */
-  /*                                                                       */
-  LOCAL_FUNC
-  TT_Error  TT_New_GlyphZone( FT_Memory      memory,
-                              TT_GlyphZone*  pts,
-                              TT_UShort      maxPoints,
-                              TT_Short       maxContours )
-  {
-    TT_Error  error;
-
-
-    if ( ALLOC( pts->org, maxPoints * 2 * sizeof ( TT_F26Dot6 )   ) ||
-         ALLOC( pts->cur, maxPoints * 2 * sizeof ( TT_F26Dot6 )   ) ||
-         ALLOC( pts->touch, maxPoints * sizeof ( TT_Byte )        ) ||
-         ALLOC( pts->contours, maxContours * sizeof ( TT_UShort ) ) )
-      return error;
-
-    return TT_Err_Ok;
-  }
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_Done_GlyphZone                                                  */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Deallocates a glyph zone.                                          */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    memory :: A handle to the current memory object.                   */
-  /*                                                                       */
-  /*    pts    :: A pointer to the target glyph zone record.               */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    TrueType error code.  0 means success.                             */
-  /*                                                                       */
-  LOCAL_FUNC
-  TT_Error  TT_Done_GlyphZone( FT_Memory      memory,
-                               TT_GlyphZone*  pts )
-  {
-    FREE( pts->contours );
-    FREE( pts->touch );
-    FREE( pts->cur );
-    FREE( pts->org );
-
-    return TT_Err_Ok;
-  }
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
   /*    Get_Name                                                           */
   /*                                                                       */
   /* <Description>                                                         */
@@ -525,7 +456,7 @@
 
     /* reserve twilight zone */
     n_twilight = maxp->maxTwilightPoints;
-    error = TT_New_GlyphZone( memory, &size->twilight, n_twilight, 0 );
+    error = FT_New_GlyphZone( memory, n_twilight, 0, &size->twilight );
     if ( error )
       goto Fail_Memory;
 
@@ -662,7 +593,7 @@
     size->storage_size = 0;
 
     /* twilight zone */
-    TT_Done_GlyphZone( memory, &size->twilight );
+    FT_Done_GlyphZone( &size->twilight );
 
     FREE( size->function_defs );
     FREE( size->instruction_defs );
@@ -894,12 +825,16 @@
   LOCAL_FUNC
   TT_Error  TT_Init_Driver( TT_Driver  driver )
   {
+    FT_Memory  memory = driver->root.memory;
+    FT_Error   error;
+    
+    error = FT_New_GlyphZone( memory, 0, 0, &driver->zone );
+    if (error) return error;
+    
     /* init extension registry if needed */
 #ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
     return TT_Init_Extensions( driver );
 #else
-    UNUSED( driver );
-
     return TT_Err_Ok;
 #endif
   }
@@ -924,6 +859,9 @@
     TT_Done_Extensions( driver );
 #endif
 
+    /* remove the loading glyph zone */
+    FT_Done_GlyphZone( &driver->zone );
+
 #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
     /* destroy the execution context */
     if ( driver->context )
diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h
index 257a3b6..8dd990f 100644
--- a/src/truetype/ttobjs.h
+++ b/src/truetype/ttobjs.h
@@ -161,24 +161,6 @@
   } TT_DefRecord, *TT_DefArray;
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* This type defining a set of glyph points will be used to represent    */
-  /* each zone (regular and twilight) during instructions decoding.        */
-  /*                                                                       */
-  typedef struct  TT_GlyphZone_
-  {
-    TT_UShort   n_points;   /* number of points in zone    */
-    TT_Short    n_contours; /* number of contours          */
-
-    TT_Vector*  org;        /* original point coordinates  */
-    TT_Vector*  cur;        /* current point coordinates   */
-
-    TT_Byte*    touch;      /* current touch flags         */
-    TT_UShort*  contours;   /* contour end points          */
-
-  } TT_GlyphZone;
-
 
   /*************************************************************************/
   /*                                                                       */
@@ -210,7 +192,7 @@
     TT_Pos        left_bearing;
     TT_Pos        advance;
 
-    TT_GlyphZone  zone;
+    FT_GlyphZone  zone;
 
     TT_Long       arg1;         /* first argument                      */
     TT_Long       arg2;         /* second argument                     */
@@ -352,7 +334,7 @@
     TT_UShort          storage_size; /* The storage area is now part of */
     TT_Long*           storage;      /* the instance                    */
 
-    TT_GlyphZone       twilight;     /* The instance's twilight zone    */
+    FT_GlyphZone       twilight;     /* The instance's twilight zone    */
 
     /* debugging variables */
 
@@ -375,215 +357,44 @@
   typedef struct  TT_DriverRec_
   {
     FT_DriverRec    root;
-    TT_ExecContext  context;  /* execution context */
+    TT_ExecContext  context;  /* execution context        */
+    FT_GlyphZone    zone;     /* glyph loader points zone */
 
     void*           extension_component;
 
   } TT_DriverRec;
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_New_GlyphZone                                                   */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Allocates a new glyph zone.                                        */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    memory      :: A handle to the current memory object.              */
-  /*                                                                       */
-  /*    maxPoints   :: The capacity of glyph zone in points.               */
-  /*                                                                       */
-  /*    maxContours :: The capacity of glyph zone in contours.             */
-  /*                                                                       */
-  /* <InOut>                                                               */
-  /*    pts         :: A pointer to the target glyph zone record.          */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    TrueType error code.  0 means success.                             */
-  /*                                                                       */
- LOCAL_DEF
- TT_Error  TT_New_GlyphZone( FT_Memory      memory,
-                             TT_GlyphZone*  pts,
-                             TT_UShort      maxPoints,
-                             TT_Short       maxContours );
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_Done_GlyphZone                                                  */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Deallocates a glyph zone.                                          */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    memory :: A handle to the current memory object.                   */
-  /*                                                                       */
-  /*    pts    :: A pointer to the target glyph zone record.               */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    TrueType error code.  0 means success.                             */
-  /*                                                                       */
-  LOCAL_FUNC
-  TT_Error  TT_Done_GlyphZone( FT_Memory      memory,
-                               TT_GlyphZone*  pts );
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_Init_Face                                                       */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Initializes a given TrueType face object.                          */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    resource   :: The source font resource.                            */
-  /*    face_index :: The index of the font face in the resource.          */
-  /*    face       :: The newly built face object.                         */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    TrueType error code.  0 means success.                             */
-  /*                                                                       */
-  LOCAL_DEF
-  TT_Error  TT_Init_Face( FT_Stream  stream,
-                          TT_Long    face_index,
-                          TT_Face    face );
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_Done_Face                                                       */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Finalizes a given face object.                                     */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    face :: The target face object to finalize.                        */
-  /*                                                                       */
-  LOCAL_DEF
-  void  TT_Done_Face( TT_Face  face );
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_Init_Size                                                       */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Initializes a new TrueType size object.                            */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    size :: A handle to the size object.                               */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    TrueType error code.  0 means success.                             */
-  /*                                                                       */
-  LOCAL_DEF
-  TT_Error  TT_Init_Size( TT_Size  size );
+ /*************************************************************************/
+ /*  Face Funcs                                                           */ 
 
+  LOCAL_DEF TT_Error  TT_Init_Face( FT_Stream  stream,
+                                    TT_Long    face_index,
+                                    TT_Face    face );
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_Done_Size                                                       */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    The TrueType size object finalizer.                                */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    size :: A handle to the target size object.                        */
-  /*                                                                       */
-  LOCAL_DEF
-  void  TT_Done_Size( TT_Size  size );
+  LOCAL_DEF void      TT_Done_Face( TT_Face  face );
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_Reset_Size                                                      */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Resets a TrueType size when resolutions and character dimensions   */
-  /*    have been changed.                                                 */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    size :: A handle to the target size object.                        */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    TrueType error code.  0 means success.                             */
-  /*                                                                       */
-  LOCAL_DEF
-  TT_Error  TT_Reset_Size( TT_Size  size );
+ /*************************************************************************/
+ /*  Size funcs                                                           */ 
 
+  LOCAL_DEF TT_Error  TT_Init_Size ( TT_Size  size );
+  LOCAL_DEF void      TT_Done_Size ( TT_Size  size );
+  LOCAL_DEF TT_Error  TT_Reset_Size( TT_Size  size );
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_Init_GlyphSlot                                                  */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    The TrueType glyph slot initializer.                               */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    glyph :: The glyph record to build.                                */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    TrueType error code.  0 means success.                             */
-  /*                                                                       */
-  LOCAL_DEF
-  TT_Error  TT_Init_GlyphSlot( TT_GlyphSlot  slot );
 
+ /*************************************************************************/
+ /*  GlyphSlot funcs                                                      */ 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_Done_GlyphSlot                                                  */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    The TrueType glyph slot finalizer.                                 */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    glyph :: A handle to the glyph slot object.                        */
-  /*                                                                       */
-  LOCAL_DEF
-  void  TT_Done_GlyphSlot( TT_GlyphSlot  slot );
+  LOCAL_DEF TT_Error  TT_Init_GlyphSlot( TT_GlyphSlot  slot );
+  LOCAL_DEF void      TT_Done_GlyphSlot( TT_GlyphSlot  slot );
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_Init_Driver                                                     */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Initializes a given TrueType driver object.                        */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    driver :: A handle to the target driver object.                    */
-  /*                                                                       */
-  /* <Return>                                                              */
-  /*    TrueType error code.  0 means success.                             */
-  /*                                                                       */
-  LOCAL_DEF
-  TT_Error  TT_Init_Driver( TT_Driver  driver );
-
+ /*************************************************************************/
+ /*  Driver funcs                                                         */ 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    TT_Done_Driver                                                     */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Finalizes a given TrueType driver.                                 */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    driver :: A handle to the target TrueType driver.                  */
-  /*                                                                       */
-  LOCAL_DEF
-  void  TT_Done_Driver( TT_Driver  driver );
+  LOCAL_DEF  TT_Error  TT_Init_Driver( TT_Driver  driver );
+  LOCAL_DEF  void      TT_Done_Driver( TT_Driver  driver );
 
 
 #ifdef __cplusplus