Commit 2b54eba36b40806b4cae290518fcb2911eb79959

Werner Lemberg 2004-05-07T07:08:14

* src/cff/cffobjs.c (cff_size_done, cff_size_init, cff_size_reset, cff_slot_done, cff_slot_init, cff_face_init, cff_face_done): Access root fields directly. * src/cff/cffdrivr.c (Load_Glyph): Access root fields directly. * src/truetype/ttgload.c (TT_Process_Simple_Glyph): Save current frame before calling TT_Vary_Get_Glyph_Deltas. * src/pcf/pcfdrivr.c (PCF_CMapRec): Rename `cmap' to `root' for consistency. (pcf_cmap_init, pcf_cmap_done, pcf_cmap_char_index, pcf_cmap_char_next): Don't use PCF_XXX but FT_XXX arguments which are typecast to the proper PCF_XXX types within the function. Update code accordingly. (pcf_cmap_class): Remove casts. (PCF_Face_Done, PCF_Face_Init, PCF_Set_Pixel_Size): Don't use PCF_XXX but FT_XXX arguments which are typecast to the proper PCF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (PCF_Set_Point_Size): New wrapper function. (PCF_Glyph_Load, pcf_driver_requester): Use FT_CALLBACK_DEF. (pcf_driver_class): Remove casts.

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
diff --git a/ChangeLog b/ChangeLog
index c1d0838..61e4c26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2004-05-06  Werner Lemberg  <wl@gnu.org>
+
+	* src/cff/cffobjs.c (cff_size_done, cff_size_init, cff_size_reset,
+	cff_slot_done, cff_slot_init, cff_face_init, cff_face_done): Access
+	root fields directly.
+	* src/cff/cffdrivr.c (Load_Glyph): Access root fields directly.
+
+	* src/truetype/ttgload.c (TT_Process_Simple_Glyph): Save current
+	frame before calling TT_Vary_Get_Glyph_Deltas.
+
+	* src/pcf/pcfdrivr.c (PCF_CMapRec): Rename `cmap' to `root' for
+	consistency.
+	(pcf_cmap_init, pcf_cmap_done, pcf_cmap_char_index,
+	pcf_cmap_char_next): Don't use PCF_XXX but FT_XXX arguments which
+	are typecast to the proper PCF_XXX types within the function. 
+	Update code accordingly.
+	(pcf_cmap_class): Remove casts.
+	(PCF_Face_Done, PCF_Face_Init, PCF_Set_Pixel_Size): Don't use
+	PCF_XXX but FT_XXX arguments which are typecast to the proper
+	PCF_XXX types within the function.
+	Update code accordingly.
+	Use FT_CALLBACK_DEF throughout.
+	(PCF_Set_Point_Size): New wrapper function.
+	(PCF_Glyph_Load, pcf_driver_requester): Use FT_CALLBACK_DEF.
+	(pcf_driver_class): Remove casts.
+
 2004-05-04  Steve Hartwell  <shspamsink@comcast.net>
 
 	* src/truetype/ttobjs.c (tt_driver_done): Fix typo.
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 73db190..e1f274e 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -203,8 +203,8 @@
     /* reset the size object if necessary */
     if ( size )
     {
-      /* these two object must have the same parent */
-      if ( size->root.face != slot->root.face )
+      /* these two objects must have the same parent */
+      if ( cffsize->face != cffslot->face )
         return CFF_Err_Invalid_Face_Handle;
     }
 
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 5860d21..ec4d1e4 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -46,7 +46,7 @@
   /*                                                                       */
   /*                            SIZE FUNCTIONS                             */
   /*                                                                       */
-  /*  Note that we store the global hints in the size's "internal" root    */
+  /*  Note that we store the global hints in the size's `internal' root    */
   /*  field.                                                               */
   /*                                                                       */
   /*************************************************************************/
@@ -140,16 +140,16 @@
     CFF_Size  size = (CFF_Size)cffsize;
 
 
-    if ( size->root.internal )
+    if ( cffsize->internal )
     {
       PSH_Globals_Funcs  funcs;
 
 
       funcs = cff_size_get_globals_funcs( size );
       if ( funcs )
-        funcs->destroy( (PSH_Globals)size->root.internal );
+        funcs->destroy( (PSH_Globals)cffsize->internal );
 
-      size->root.internal = 0;
+      cffsize->internal = 0;
     }
   }
 
@@ -165,7 +165,7 @@
     if ( funcs )
     {
       PSH_Globals    globals;
-      CFF_Face       face    = (CFF_Face)size->root.face;
+      CFF_Face       face    = (CFF_Face)cffsize->face;
       CFF_Font       font    = (CFF_FontRec *)face->extra.data;
       CFF_SubFont    subfont = &font->top_font;
 
@@ -219,9 +219,9 @@
         priv.lenIV          = cpriv->lenIV;
       }
 
-      error = funcs->create( size->root.face->memory, &priv, &globals );
+      error = funcs->create( cffsize->face->memory, &priv, &globals );
       if ( !error )
-        size->root.internal = (FT_Size_Internal)(void*)globals;
+        cffsize->internal = (FT_Size_Internal)(void*)globals;
     }
 
     return error;
@@ -236,16 +236,16 @@
     CFF_Size           size  = (CFF_Size)cffsize;
     PSH_Globals_Funcs  funcs = cff_size_get_globals_funcs( size );
     FT_Error           error = CFF_Err_Ok;
-    FT_Face            face  = size->root.face;
+    FT_Face            face  = cffsize->face;
 
     FT_UNUSED( char_width );
     FT_UNUSED( char_height );
 
 
     if ( funcs )
-      error = funcs->set_scale( (PSH_Globals)size->root.internal,
-                                 size->root.metrics.x_scale,
-                                 size->root.metrics.y_scale,
+      error = funcs->set_scale( (PSH_Globals)cffsize->internal,
+                                 cffsize->metrics.x_scale,
+                                 cffsize->metrics.y_scale,
                                  0, 0 );
 
 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
@@ -255,7 +255,7 @@
       error = sbit_size_reset( size );
 
       if ( !error && !( face->face_flags & FT_FACE_FLAG_SCALABLE ) )
-        size->root.metrics = size->strike_metrics;
+        cffsize->metrics = size->strike_metrics;
     }
 
 #endif
@@ -290,19 +290,16 @@
   /*************************************************************************/
 
   FT_LOCAL_DEF( void )
-  cff_slot_done( FT_GlyphSlot  cffslot )        /* CFF_GlyphSlot */
+  cff_slot_done( FT_GlyphSlot  slot )
   {
-    CFF_GlyphSlot  slot = (CFF_GlyphSlot)cffslot;
-
-    slot->root.internal->glyph_hints = 0;
+    slot->internal->glyph_hints = 0;
   }
 
 
   FT_LOCAL_DEF( FT_Error )
-  cff_slot_init( FT_GlyphSlot  cffslot )        /* CFF_GlyphSlot */
+  cff_slot_init( FT_GlyphSlot  slot )
   {
-    CFF_GlyphSlot     slot     = (CFF_GlyphSlot)cffslot;
-    CFF_Face          face     = (CFF_Face)slot->root.face;
+    CFF_Face          face     = (CFF_Face)slot->face;
     CFF_Font          font     = (CFF_FontRec *)face->extra.data;
     PSHinter_Service  pshinter = (PSHinter_Service)font->pshinter;
 
@@ -312,7 +309,7 @@
       FT_Module  module;
 
 
-      module = FT_Get_Module( slot->root.face->driver->root.library,
+      module = FT_Get_Module( slot->face->driver->root.library,
                               "pshinter" );
       if ( module )
       {
@@ -320,7 +317,7 @@
 
 
         funcs = pshinter->get_t2_funcs( module );
-        slot->root.internal->glyph_hints = (void*)funcs;
+        slot->internal->glyph_hints = (void*)funcs;
       }
     }
 
@@ -379,14 +376,14 @@
       goto Bad_Format;
 #else
     sfnt = (SFNT_Service)FT_Get_Module_Interface(
-             face->root.driver->root.library, "sfnt" );
+             cffface->driver->root.library, "sfnt" );
     if ( !sfnt )
       goto Bad_Format;
 
     FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
 
     pshinter = (PSHinter_Service)FT_Get_Module_Interface(
-                 face->root.driver->root.library, "pshinter" );
+                 cffface->driver->root.library, "pshinter" );
 #endif
 
     /* create input stream from resource */
@@ -451,8 +448,7 @@
     {
       CFF_Font         cff;
       CFF_FontRecDict  dict;
-      FT_Memory        memory = face->root.memory;
-      FT_Face          root;
+      FT_Memory        memory = cffface->memory;
       FT_Int32         flags;
 
 
@@ -470,8 +466,7 @@
       /* Complement the root flags with some interesting information. */
       /* Note that this is only necessary for pure CFF and CEF fonts. */
 
-      root             = &face->root;
-      root->num_glyphs = cff->num_glyphs;
+      cffface->num_glyphs = cff->num_glyphs;
 
       dict = &cff->top_font.font_dict;
 
@@ -492,46 +487,46 @@
 
 
         /* Set up num_faces. */
-        root->num_faces = cff->num_faces;
+        cffface->num_faces = cff->num_faces;
 
         /* compute number of glyphs */
         if ( dict->cid_registry != 0xFFFFU )
-          root->num_glyphs = dict->cid_count;
+          cffface->num_glyphs = dict->cid_count;
         else
-          root->num_glyphs = cff->charstrings_index.count;
+          cffface->num_glyphs = cff->charstrings_index.count;
 
         /* set global bbox, as well as EM size */
-        root->bbox.xMin =   dict->font_bbox.xMin             >> 16;
-        root->bbox.yMin =   dict->font_bbox.yMin             >> 16;
-        root->bbox.xMax = ( dict->font_bbox.xMax + 0xFFFFU ) >> 16;
-        root->bbox.yMax = ( dict->font_bbox.yMax + 0xFFFFU ) >> 16;
+        cffface->bbox.xMin =   dict->font_bbox.xMin             >> 16;
+        cffface->bbox.yMin =   dict->font_bbox.yMin             >> 16;
+        cffface->bbox.xMax = ( dict->font_bbox.xMax + 0xFFFFU ) >> 16;
+        cffface->bbox.yMax = ( dict->font_bbox.yMax + 0xFFFFU ) >> 16;
 
-        root->ascender  = (FT_Short)( root->bbox.yMax );
-        root->descender = (FT_Short)( root->bbox.yMin );
-        root->height    = (FT_Short)(
-          ( ( root->ascender - root->descender ) * 12 ) / 10 );
+        cffface->ascender  = (FT_Short)( cffface->bbox.yMax );
+        cffface->descender = (FT_Short)( cffface->bbox.yMin );
+        cffface->height    = (FT_Short)(
+          ( ( cffface->ascender - cffface->descender ) * 12 ) / 10 );
 
         if ( dict->units_per_em )
-          root->units_per_EM = dict->units_per_em;
+          cffface->units_per_EM = dict->units_per_em;
         else
-          root->units_per_EM = 1000;
+          cffface->units_per_EM = 1000;
 
-        root->underline_position  =
+        cffface->underline_position  =
           (FT_Short)( dict->underline_position >> 16 );
-        root->underline_thickness =
+        cffface->underline_thickness =
           (FT_Short)( dict->underline_thickness >> 16 );
 
         /* retrieve font family & style name */
-        root->family_name = cff_index_get_name( &cff->name_index,
-                                                face_index );
+        cffface->family_name = cff_index_get_name( &cff->name_index,
+                                                   face_index );
 
-        if ( root->family_name )
+        if ( cffface->family_name )
         {
           char*  full   = cff_index_get_sid_string( &cff->string_index,
                                                     dict->full_name,
                                                     psnames );
           char*  fullp  = full;
-          char*  family = root->family_name;
+          char*  family = cffface->family_name;
 
           /* We try to extract the style name from the full name.   */
           /* We need to ignore spaces and dashes during the search. */
@@ -584,14 +579,14 @@
 
           /* do we have a `/FontName' for a CID-keyed font? */
           if ( cid_font_name )
-            root->family_name = cid_font_name;
+            cffface->family_name = cid_font_name;
         }
 
         if ( style_name )
-          root->style_name = style_name;
+          cffface->style_name = style_name;
         else
           /* assume "Regular" style if we don't know better */
-          root->style_name = cff_strcpy( memory, (char *)"Regular" );
+          cffface->style_name = cff_strcpy( memory, (char *)"Regular" );
 
         /*******************************************************************/
         /*                                                                 */
@@ -614,7 +609,7 @@
           flags |= FT_FACE_FLAG_KERNING;
 #endif
 
-        root->face_flags = flags;
+        cffface->face_flags = flags;
 
         /*******************************************************************/
         /*                                                                 */
@@ -638,14 +633,14 @@
           FT_FREE( weight );
         }
 
-        root->style_flags = flags;
+        cffface->style_flags = flags;
       }
 
 #ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
       /* CID-keyed CFF fonts don't have glyph names -- the SFNT loader */
       /* has unset this flag because of the 3.0 `post' table           */
       if ( dict->cid_registry == 0xFFFFU )
-        root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
+        cffface->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
 #endif
 
       /*******************************************************************/
@@ -663,9 +658,9 @@
         CFF_Encoding   encoding = &cff->encoding;
 
 
-        for ( nn = 0; nn < (FT_UInt)root->num_charmaps; nn++ )
+        for ( nn = 0; nn < (FT_UInt)cffface->num_charmaps; nn++ )
         {
-          cmap = root->charmaps[nn];
+          cmap = cffface->charmaps[nn];
 
           /* Windows Unicode (3,1)? */
           if ( cmap->platform_id == 3 && cmap->encoding_id == 1 )
@@ -682,18 +677,18 @@
           goto Exit;
 
         /* we didn't find a Unicode charmap -- synthetize one */
-        cmaprec.face        = root;
+        cmaprec.face        = cffface;
         cmaprec.platform_id = 3;
         cmaprec.encoding_id = 1;
         cmaprec.encoding    = FT_ENCODING_UNICODE;
 
-        nn = (FT_UInt)root->num_charmaps;
+        nn = (FT_UInt)cffface->num_charmaps;
 
         FT_CMap_New( &cff_cmap_unicode_class_rec, NULL, &cmaprec, NULL );
 
         /* if no Unicode charmap was previously selected, select this one */
-        if ( root->charmap == NULL && nn != (FT_UInt)root->num_charmaps )
-          root->charmap = root->charmaps[nn];
+        if ( cffface->charmap == NULL && nn != (FT_UInt)cffface->num_charmaps )
+          cffface->charmap = cffface->charmaps[nn];
 
       Skip_Unicode:
         if ( encoding->count > 0 )
@@ -701,7 +696,7 @@
           FT_CMap_Class  clazz;
 
 
-          cmaprec.face        = root;
+          cmaprec.face        = cffface;
           cmaprec.platform_id = 7;  /* Adobe platform id */
 
           if ( encoding->offset == 0 )
@@ -741,7 +736,7 @@
   cff_face_done( FT_Face  cffface )         /* CFF_Face */
   {
     CFF_Face      face   = (CFF_Face)cffface;
-    FT_Memory     memory = face->root.memory;
+    FT_Memory     memory = cffface->memory;
     SFNT_Service  sfnt   = (SFNT_Service)face->sfnt;
 
 
diff --git a/src/cff/cffobjs.h b/src/cff/cffobjs.h
index 0a5c969..338ec74 100644
--- a/src/cff/cffobjs.h
+++ b/src/cff/cffobjs.h
@@ -131,10 +131,10 @@ FT_BEGIN_HEADER
                         FT_UInt     vert_resolution );
 
   FT_LOCAL( void )
-  cff_slot_done( FT_GlyphSlot  slot );      /* CFF_GlyphSlot */
+  cff_slot_done( FT_GlyphSlot  slot );
 
   FT_LOCAL( FT_Error )
-  cff_slot_init( FT_GlyphSlot   slot );     /* CFF_GlyphSlot */
+  cff_slot_init( FT_GlyphSlot  slot );
 
 
   /*************************************************************************/
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index eaf95c0..a74740c 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -48,9 +48,10 @@ THE SOFTWARE.
 #include FT_SERVICE_BDF_H
 #include FT_SERVICE_XFREE86_NAME_H
 
+
   typedef struct  PCF_CMapRec_
   {
-    FT_CMapRec    cmap;
+    FT_CMapRec    root;
     FT_UInt       num_encodings;
     PCF_Encoding  encodings;
 
@@ -58,9 +59,13 @@ THE SOFTWARE.
 
 
   FT_CALLBACK_DEF( FT_Error )
-  pcf_cmap_init( PCF_CMap  cmap )
+  pcf_cmap_init( FT_CMap     pcfcmap,   /* PCF_CMap */
+                 FT_Pointer  init_data )
   {
-    PCF_Face  face = (PCF_Face)FT_CMAP_FACE( cmap );
+    PCF_CMap  cmap = (PCF_CMap)pcfcmap;
+    PCF_Face  face = (PCF_Face)FT_CMAP_FACE( pcfcmap );
+
+    FT_UNUSED( init_data );
 
 
     cmap->num_encodings = (FT_UInt)face->nencodings;
@@ -71,20 +76,24 @@ THE SOFTWARE.
 
 
   FT_CALLBACK_DEF( void )
-  pcf_cmap_done( PCF_CMap  cmap )
+  pcf_cmap_done( FT_CMap  pcfcmap )         /* PCF_CMap */
   {
+    PCF_CMap  cmap = (PCF_CMap)pcfcmap;
+
+
     cmap->encodings     = NULL;
     cmap->num_encodings = 0;
   }
 
 
   FT_CALLBACK_DEF( FT_UInt )
-  pcf_cmap_char_index( PCF_CMap   cmap,
+  pcf_cmap_char_index( FT_CMap    pcfcmap,  /* PCF_CMap */
                        FT_UInt32  charcode )
   {
+    PCF_CMap      cmap      = (PCF_CMap)pcfcmap;
     PCF_Encoding  encodings = cmap->encodings;
     FT_UInt       min, max, mid;
-    FT_UInt       result = 0;
+    FT_UInt       result    = 0;
 
 
     min = 0;
@@ -115,13 +124,14 @@ THE SOFTWARE.
 
 
   FT_CALLBACK_DEF( FT_UInt )
-  pcf_cmap_char_next( PCF_CMap    cmap,
+  pcf_cmap_char_next( FT_CMap    pcfcmap,   /* PCF_CMap */
                       FT_UInt32  *acharcode )
   {
+    PCF_CMap      cmap      = (PCF_CMap)pcfcmap;
     PCF_Encoding  encodings = cmap->encodings;
     FT_UInt       min, max, mid;
-    FT_UInt32     charcode = *acharcode + 1;
-    FT_UInt       result   = 0;
+    FT_UInt32     charcode  = *acharcode + 1;
+    FT_UInt       result    = 0;
 
 
     min = 0;
@@ -163,10 +173,10 @@ THE SOFTWARE.
   FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec  pcf_cmap_class =
   {
     sizeof( PCF_CMapRec ),
-    (FT_CMap_InitFunc)     pcf_cmap_init,
-    (FT_CMap_DoneFunc)     pcf_cmap_done,
-    (FT_CMap_CharIndexFunc)pcf_cmap_char_index,
-    (FT_CMap_CharNextFunc) pcf_cmap_char_next
+    pcf_cmap_init,
+    pcf_cmap_done,
+    pcf_cmap_char_index,
+    pcf_cmap_char_next
   };
 
 
@@ -180,9 +190,10 @@ THE SOFTWARE.
 #define FT_COMPONENT  trace_pcfdriver
 
 
-  FT_CALLBACK_DEF( FT_Error )
-  PCF_Face_Done( PCF_Face  face )
+  FT_CALLBACK_DEF( void )
+  PCF_Face_Done( FT_Face  pcfface )         /* PCF_Face */
   {
+    PCF_Face   face   = (PCF_Face)pcfface;
     FT_Memory  memory = FT_FACE_MEMORY( face );
 
 
@@ -208,31 +219,30 @@ THE SOFTWARE.
     }
 
     FT_FREE( face->toc.tables );
-    FT_FREE( face->root.family_name );
-    FT_FREE( face->root.available_sizes );
+    FT_FREE( pcfface->family_name );
+    FT_FREE( pcfface->available_sizes );
     FT_FREE( face->charset_encoding );
     FT_FREE( face->charset_registry );
 
     FT_TRACE4(( "PCF_Face_Done: done face\n" ));
 
     /* close gzip/LZW stream if any */
-    if ( face->root.stream == &face->gzip_stream )
+    if ( pcfface->stream == &face->gzip_stream )
     {
       FT_Stream_Close( &face->gzip_stream );
-      face->root.stream = face->gzip_source;
+      pcfface->stream = face->gzip_source;
     }
-
-    return PCF_Err_Ok;
   }
 
 
   FT_CALLBACK_DEF( FT_Error )
   PCF_Face_Init( FT_Stream      stream,
-                 PCF_Face       face,
+                 FT_Face        pcfface,        /* PCF_Face */
                  FT_Int         face_index,
                  FT_Int         num_params,
                  FT_Parameter*  params )
   {
+    PCF_Face  face  = (PCF_Face)pcfface;
     FT_Error  error = PCF_Err_Ok;
 
     FT_UNUSED( num_params );
@@ -267,9 +277,9 @@ THE SOFTWARE.
           goto Fail;
 
         face->gzip_source = stream;
-        face->root.stream = &face->gzip_stream;
+        pcfface->stream   = &face->gzip_stream;
 
-        stream = face->root.stream;
+        stream = pcfface->stream;
 
         error = pcf_load_font( stream, face );
         if ( error )
@@ -278,9 +288,9 @@ THE SOFTWARE.
       else
       {
         face->gzip_source = stream;
-        face->root.stream = &face->gzip_stream;
+        pcfface->stream   = &face->gzip_stream;
 
-        stream = face->root.stream;
+        stream = pcfface->stream;
 
         error = pcf_load_font( stream, face );
         if ( error )
@@ -337,8 +347,8 @@ THE SOFTWARE.
 
 #if 0
         /* Select default charmap */
-        if (face->root.num_charmaps)
-          face->root.charmap = face->root.charmaps[0];
+        if ( pcfface->num_charmaps )
+          pcfface->charmap = pcfface->charmaps[0];
 #endif
       }
     }
@@ -353,10 +363,15 @@ THE SOFTWARE.
   }
 
 
-  static FT_Error
-  PCF_Set_Pixel_Size( FT_Size  size )
+  FT_CALLBACK_DEF( FT_Error )
+  PCF_Set_Pixel_Size( FT_Size  size,
+                      FT_UInt  pixel_width,
+                      FT_UInt  pixel_height )
   {
-    PCF_Face face = (PCF_Face)FT_SIZE_FACE( size );
+    PCF_Face  face = (PCF_Face)FT_SIZE_FACE( size );
+
+    FT_UNUSED( pixel_width );
+    FT_UNUSED( pixel_height );
 
 
     FT_TRACE4(( "rec %d - pres %d\n", size->metrics.y_ppem,
@@ -384,7 +399,23 @@ THE SOFTWARE.
   }
 
 
-  static FT_Error
+  FT_CALLBACK_DEF( FT_Error )
+  PCF_Set_Point_Size( FT_Size     size,
+                      FT_F26Dot6  char_width,
+                      FT_F26Dot6  char_height,
+                      FT_UInt     horz_resolution,
+                      FT_UInt     vert_resolution )
+  {
+    FT_UNUSED( char_width );
+    FT_UNUSED( char_height );
+    FT_UNUSED( horz_resolution );
+    FT_UNUSED( vert_resolution );
+
+    return PCF_Set_Pixel_Size( size, 0, 0 );
+  }
+
+
+  FT_CALLBACK_DEF( FT_Error )
   PCF_Glyph_Load( FT_GlyphSlot  slot,
                   FT_Size       size,
                   FT_UInt       glyph_index,
@@ -568,7 +599,7 @@ THE SOFTWARE.
   };
 
 
-  static FT_Module_Interface
+  FT_CALLBACK_DEF( FT_Module_Interface )
   pcf_driver_requester( FT_Module    module,
                         const char*  name )
   {
@@ -592,30 +623,30 @@ THE SOFTWARE.
 
       0,
 
-      (FT_Module_Constructor)0,
-      (FT_Module_Destructor) 0,
-      (FT_Module_Requester)  pcf_driver_requester
+      0,
+      0,
+      pcf_driver_requester
     },
 
-    sizeof( PCF_FaceRec ),
-    sizeof( FT_SizeRec ),
-    sizeof( FT_GlyphSlotRec ),
+    sizeof ( PCF_FaceRec ),
+    sizeof ( FT_SizeRec ),
+    sizeof ( FT_GlyphSlotRec ),
 
-    (FT_Face_InitFunc)        PCF_Face_Init,
-    (FT_Face_DoneFunc)        PCF_Face_Done,
-    (FT_Size_InitFunc)        0,
-    (FT_Size_DoneFunc)        0,
-    (FT_Slot_InitFunc)        0,
-    (FT_Slot_DoneFunc)        0,
+    PCF_Face_Init,
+    PCF_Face_Done,
+    0,                      /* FT_Size_InitFunc */
+    0,                      /* FT_Size_DoneFunc */
+    0,                      /* FT_Slot_InitFunc */
+    0,                      /* FT_Slot_DoneFunc */
 
-    (FT_Size_ResetPointsFunc) PCF_Set_Pixel_Size,
-    (FT_Size_ResetPixelsFunc) PCF_Set_Pixel_Size,
+    PCF_Set_Point_Size,
+    PCF_Set_Pixel_Size,
 
-    (FT_Slot_LoadFunc)        PCF_Glyph_Load,
+    PCF_Glyph_Load,
 
-    (FT_Face_GetKerningFunc)  0,
-    (FT_Face_AttachFunc)      0,
-    (FT_Face_GetAdvancesFunc) 0
+    0,                      /* FT_Face_GetKerningFunc  */
+    0,                      /* FT_Face_AttachFunc      */
+    0                       /* FT_Face_GetAdvancesFunc */
   };
 
 
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 0a2faf1..b0093f9 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -738,15 +738,25 @@
     if ( ((TT_Face)load->face)->doblend )
     {
       /* Deltas apply to the unscaled data. */
-      FT_Vector*  deltas;
-      FT_Memory   memory = load->face->memory;
-      FT_UInt     i;
+      FT_Vector*    deltas;
+      FT_Memory     memory       = load->face->memory;
+      FT_StreamRec  saved_stream = *(load->stream);
+      FT_UInt       i;
 
 
-      if ( ( error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(load->face),
-                                               load->glyph_index,
-                                               &deltas,
-                                               n_points ) ) )
+      /* TT_Vary_Get_Glyph_Deltas uses a frame, thus we have to save */
+      /* (and restore) the current one                               */
+      load->stream->cursor = 0;
+      load->stream->limit  = 0;
+
+      error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(load->face),
+                                        load->glyph_index,
+                                        &deltas,
+                                        n_points );
+
+      *(load->stream) = saved_stream;
+
+      if ( error )
         goto Exit;
 
       for ( i = 0; i < n_points; ++i )
@@ -863,7 +873,7 @@
 #endif
 
     FT_Error        error;
-    TT_Face         face   = (TT_Face)loader->face;
+    TT_Face         face = (TT_Face)loader->face;
     FT_ULong        offset;
     FT_Int          contours_count;
     FT_UInt         num_points, count;
@@ -872,9 +882,9 @@
     FT_Bool         opened_frame = 0;
 
 #ifdef FT_CONFIG_OPTION_INCREMENTAL
-    struct FT_StreamRec_  inc_stream;
-    FT_Data               glyph_data;
-    FT_Bool               glyph_data_loaded = 0;
+    FT_StreamRec    inc_stream;
+    FT_Data         glyph_data;
+    FT_Bool         glyph_data_loaded = 0;
 #endif
 
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT