Commit 3bcad43998e3bb0c9d848756970618a8cc61edb3

Werner Lemberg 2004-05-06T11:48:35

* src/truetype/ttobjs.c (tt_driver_done): Fix typo. * src/bdf/bdfdrivr.c (BDF_Face_Done, BDF_Face_Init, BDF_Set_Pixel_Size): Don't use BDF_XXX but FT_XXX arguments which are typecast to the proper BDF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (BDF_Set_Point_Size): New wrapper function. (bdf_driver_class): Remove casts. * src/cff/cffdrivr.c (Get_Kerning, Load_Glyph, cff_get_interface): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (cff_driver_class): Remove casts. * src/cff/cffobjs.h, 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, cff_driver_init, cff_driver_done): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. (cff_point_size_reset): New wrapper function. * src/cid/cidobjs.h, src/cid/cidobjs.c (cid_slot_done, cid_slot_init, cid_size_done, cid_size_init, cid_size_reset, cid_face_done, cid_face_init, cid_driver_init, cid_driver_done): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. (cid_point_size_reset): New wrapper function. * src/cid/cidgload.c, src/cid/cidgload.h (cid_slot_load_glyph): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. * src/cid/cidriver.c (cid_get_interface): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF. (t1cid_driver_class): Remove casts. * src/truetype/ttdriver.c (tt_get_interface): Use FT_CALLBACK_DEF. * src/truetype/ttgxvar.c (ft_var_load_avar): Don't free non-local variables (this is done later). (ft_var_load_avar): Fix call to FT_FRAME_ENTER. (TT_Get_MM_Var): Fix size for `fvar_fields'. (TT_Vary_Get_Glyph_Deltas): Handle deallocation of local variables correctly. * src/base/ftdbgmem.c (ft_mem_debug_realloc): Don't abort if current size is zero.

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
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
diff --git a/ChangeLog b/ChangeLog
index d9b6f1a..c1d0838 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,15 +1,75 @@
+2004-05-04  Steve Hartwell  <shspamsink@comcast.net>
+
+	* src/truetype/ttobjs.c (tt_driver_done): Fix typo.
+
+2004-05-04  Werner Lemberg  <wl@gnu.org>
+
+	* src/bdf/bdfdrivr.c (BDF_Face_Done, BDF_Face_Init,
+	BDF_Set_Pixel_Size): Don't use BDF_XXX but FT_XXX arguments which
+	are typecast to the proper BDF_XXX types within the function.
+	Update code accordingly.
+	Use FT_CALLBACK_DEF throughout.
+	(BDF_Set_Point_Size): New wrapper function.
+	(bdf_driver_class): Remove casts.
+
+	* src/cff/cffdrivr.c (Get_Kerning, Load_Glyph, cff_get_interface):
+	Don't use CFF_XXX but FT_XXX arguments which are typecast to the
+	proper CFF_XXX types within the function.
+	Update code accordingly.
+	Use FT_CALLBACK_DEF throughout.
+	(cff_driver_class): Remove casts.
+
+	* src/cff/cffobjs.h, 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, cff_driver_init, cff_driver_done):
+	Don't use CFF_XXX but FT_XXX arguments which are typecast to the
+	proper CFF_XXX types within the function.
+	Update code accordingly.
+	(cff_point_size_reset): New wrapper function.
+
+	* src/cid/cidobjs.h, src/cid/cidobjs.c (cid_slot_done,
+	cid_slot_init, cid_size_done, cid_size_init, cid_size_reset,
+	cid_face_done, cid_face_init, cid_driver_init, cid_driver_done):
+	Don't use CID_XXX but FT_XXX arguments which are typecast to the
+	proper CID_XXX types within the function.
+	Update code accordingly.
+	(cid_point_size_reset): New wrapper function.
+
+	* src/cid/cidgload.c, src/cid/cidgload.h (cid_slot_load_glyph):
+	Don't use CID_XXX but FT_XXX arguments which are typecast to the
+	proper CID_XXX types within the function.
+	Update code accordingly.
+
+	* src/cid/cidriver.c (cid_get_interface):
+	Don't use CID_XXX but FT_XXX arguments which are typecast to the
+	proper CID_XXX types within the function.
+	Update code accordingly.
+	Use FT_CALLBACK_DEF.
+	(t1cid_driver_class): Remove casts.
+
+	* src/truetype/ttdriver.c (tt_get_interface): Use FT_CALLBACK_DEF.
+	* src/truetype/ttgxvar.c (ft_var_load_avar): Don't free non-local
+	variables (this is done later).
+	(ft_var_load_avar): Fix call to FT_FRAME_ENTER.
+	(TT_Get_MM_Var): Fix size for `fvar_fields'.
+	(TT_Vary_Get_Glyph_Deltas): Handle deallocation of local variables
+	correctly.
+
+	* src/base/ftdbgmem.c (ft_mem_debug_realloc): Don't abort if
+	current size is zero.
+
 2004-05-03  Steve Hartwell  <shspamsink@comcast.net>
 
 	* src/truetype/ttobjs.h, src/truetype/ttobjs.c (tt_face_init,
 	tt_face_done, tt_size_init, tt_size_done, tt_driver_init,
 	tt_driver_done): Don't use TT_XXX but FT_XXX arguments which are
-	typecast to the proper TT_XXX within the function.
+	typecast to the proper TT_XXX types within the function.
 	Update code accordingly.
 
 	* src/truetype/ttdriver.c (Get_Kerning, Set_Char_Sizes,
 	Set_Pixel_Sizes, Load_Glyph, tt_get_interface): Don't use TT_XXX but
-	FT_XXX arguments which are typecast to the proper TT_XXX within the
-	function.
+	FT_XXX arguments which are typecast to the proper TT_XXX types
+	within the function.
 	Update code accordingly.
 	(tt_driver_class): Remove casts.
 
@@ -1402,7 +1462,7 @@
 	(FT_Load_Glyph): Update computation of linearHoriAdvance and
 	linearVertAdvance.
 
-	* src/true/type/ttinterp.c (Update_Max): Use FT_REALLOC.
+	* src/truetype/ttinterp.c (Update_Max): Use FT_REALLOC.
 
 2003-11-22  David Turner  <david@freetype.org>
 
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 152220c..05226e5 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -540,10 +540,15 @@
     FT_Long      line_no   = table->line_no;
 
 
+    /* the following is valid according to ANSI C */
+#if 0
     if ( block == NULL || cur_size == 0 )
       ft_mem_debug_panic( "trying to reallocate NULL in (%s:%ld)",
-                           file_name, line_no );
+                          file_name, line_no );
+#endif
 
+    /* while the following is allowed in ANSI C also, we abort since */
+    /* such code shouldn't be in FreeType...                         */
     if ( new_size <= 0 )
       ft_mem_debug_panic(
         "trying to reallocate %p to size 0 (current is %ld) in (%s:%ld)",
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index 2e8f93c..e02a571 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -284,9 +284,10 @@ THE SOFTWARE.
   }
 
 
-  FT_CALLBACK_DEF( FT_Error )
-  BDF_Face_Done( BDF_Face  face )
+  FT_CALLBACK_DEF( void )
+  BDF_Face_Done( FT_Face  bdfface )         /* BDF_Face */
   {
+    BDF_Face   face   = (BDF_Face)bdfface;
     FT_Memory  memory = FT_FACE_MEMORY( face );
 
 
@@ -296,26 +297,25 @@ THE SOFTWARE.
 
     FT_FREE( face->charset_encoding );
     FT_FREE( face->charset_registry );
-    FT_FREE( face->root.family_name );
+    FT_FREE( bdfface->family_name );
 
-    FT_FREE( face->root.available_sizes );
+    FT_FREE( bdfface->available_sizes );
 
     FT_FREE( face->bdffont );
 
     FT_TRACE4(( "BDF_Face_Done: done face\n" ));
-
-    return BDF_Err_Ok;
   }
 
 
   FT_CALLBACK_DEF( FT_Error )
   BDF_Face_Init( FT_Stream      stream,
-                 BDF_Face       face,
+                 FT_Face        bdfface,        /* BDF_Face */
                  FT_Int         face_index,
                  FT_Int         num_params,
                  FT_Parameter*  params )
   {
     FT_Error       error  = BDF_Err_Ok;
+    BDF_Face       face   = (BDF_Face)bdfface;
     FT_Memory      memory = FT_FACE_MEMORY( face );
 
     bdf_font_t*    font;
@@ -346,7 +346,6 @@ THE SOFTWARE.
     /* we have a bdf font: let's construct the face object */
     face->bdffont = font;
     {
-      FT_Face          root = FT_FACE( face );
       bdf_property_t*  prop = NULL;
 
 
@@ -357,18 +356,18 @@ THE SOFTWARE.
                   font->unencoded_size,
                   font->unencoded_used ));
 
-      root->num_faces  = 1;
-      root->face_index = 0;
-      root->face_flags = FT_FACE_FLAG_FIXED_SIZES |
-                         FT_FACE_FLAG_HORIZONTAL  |
-                         FT_FACE_FLAG_FAST_GLYPHS;
+      bdfface->num_faces  = 1;
+      bdfface->face_index = 0;
+      bdfface->face_flags = FT_FACE_FLAG_FIXED_SIZES |
+                            FT_FACE_FLAG_HORIZONTAL  |
+                            FT_FACE_FLAG_FAST_GLYPHS;
 
       prop = bdf_get_font_property( font, "SPACING" );
       if ( prop && prop->format == BDF_ATOM                             &&
            prop->value.atom                                             &&
            ( *(prop->value.atom) == 'M' || *(prop->value.atom) == 'm' ||
              *(prop->value.atom) == 'C' || *(prop->value.atom) == 'c' ) )
-        root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
+        bdfface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
 
       /* FZ XXX: TO DO: FT_FACE_FLAGS_VERTICAL   */
       /* FZ XXX: I need a font to implement this */
@@ -379,24 +378,24 @@ THE SOFTWARE.
         int  l = ft_strlen( prop->value.atom ) + 1;
 
 
-        if ( FT_NEW_ARRAY( root->family_name, l ) )
+        if ( FT_NEW_ARRAY( bdfface->family_name, l ) )
           goto Exit;
-        ft_strcpy( root->family_name, prop->value.atom );
+        ft_strcpy( bdfface->family_name, prop->value.atom );
       }
       else
-        root->family_name = 0;
+        bdfface->family_name = 0;
 
       if ( ( error = bdf_interpret_style( face ) ) != 0 )
         goto Exit;
 
-      root->num_glyphs = font->glyphs_size;     /* unencoded included */
+      bdfface->num_glyphs = font->glyphs_size;     /* unencoded included */
 
-      root->num_fixed_sizes = 1;
-      if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )
+      bdfface->num_fixed_sizes = 1;
+      if ( FT_NEW_ARRAY( bdfface->available_sizes, 1 ) )
         goto Exit;
 
       {
-        FT_Bitmap_Size*  bsize = root->available_sizes;
+        FT_Bitmap_Size*  bsize = bdfface->available_sizes;
         FT_Short         resolution_x = 0, resolution_y = 0;
 
 
@@ -521,8 +520,8 @@ THE SOFTWARE.
 
 #if 0
               /* Select default charmap */
-              if (root->num_charmaps)
-                root->charmap = root->charmaps[0];
+              if ( bdfface->num_charmaps )
+                bdfface->charmap = bdfface->charmaps[0];
 #endif
             }
 
@@ -544,27 +543,32 @@ THE SOFTWARE.
           error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
 
           /* Select default charmap */
-          if (root->num_charmaps)
-            root->charmap = root->charmaps[0];
+          if ( bdfface->num_charmaps )
+            bdfface->charmap = bdfface->charmaps[0];
         }
       }
-    }
+   }
 
   Exit:
     return error;
 
   Fail:
-    BDF_Face_Done( face );
+    BDF_Face_Done( bdfface );
     return BDF_Err_Unknown_File_Format;
   }
 
 
-  static FT_Error
-  BDF_Set_Pixel_Size( FT_Size  size )
+  FT_CALLBACK_DEF( FT_Error )
+  BDF_Set_Pixel_Size( FT_Size  size,
+                      FT_UInt  char_width,
+                      FT_UInt  char_height )
   {
     BDF_Face  face = (BDF_Face)FT_SIZE_FACE( size );
     FT_Face   root = FT_FACE( face );
 
+    FT_UNUSED( char_width );
+    FT_UNUSED( char_height );
+
 
     FT_TRACE4(( "rec %d - pres %d\n",
                 size->metrics.y_ppem, root->available_sizes->y_ppem ));
@@ -584,7 +588,23 @@ THE SOFTWARE.
   }
 
 
-  static FT_Error
+  FT_CALLBACK_DEF( FT_Error )
+  BDF_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 BDF_Set_Pixel_Size( size, 0, 0 );
+  }
+
+
+  FT_CALLBACK_DEF( FT_Error )
   BDF_Glyph_Load( FT_GlyphSlot  slot,
                   FT_Size       size,
                   FT_UInt       glyph_index,
@@ -817,7 +837,7 @@ THE SOFTWARE.
   };
 
 
-  static FT_Module_Interface
+  FT_CALLBACK_DEF( FT_Module_Interface )
   bdf_driver_requester( FT_Module    module,
                         const char*  name )
   {
@@ -851,21 +871,21 @@ THE SOFTWARE.
     sizeof ( FT_SizeRec ),
     sizeof ( FT_GlyphSlotRec ),
 
-    (FT_Face_InitFunc)        BDF_Face_Init,
-    (FT_Face_DoneFunc)        BDF_Face_Done,
-    (FT_Size_InitFunc)        0,
-    (FT_Size_DoneFunc)        0,
-    (FT_Slot_InitFunc)        0,
-    (FT_Slot_DoneFunc)        0,
+    BDF_Face_Init,
+    BDF_Face_Done,
+    0,                          /* FT_Size_InitFunc */
+    0,                          /* FT_Size_DoneFunc */
+    0,                          /* FT_Slot_InitFunc */
+    0,                          /* FT_Slot_DoneFunc */
 
-    (FT_Size_ResetPointsFunc) BDF_Set_Pixel_Size,
-    (FT_Size_ResetPixelsFunc) BDF_Set_Pixel_Size,
+    BDF_Set_Point_Size,
+    BDF_Set_Pixel_Size,
 
-    (FT_Slot_LoadFunc)        BDF_Glyph_Load,
+    BDF_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/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 60ee90a..73db190 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -96,12 +96,13 @@
   /*                                                                       */
   /*    They can be implemented by format-specific interfaces.             */
   /*                                                                       */
-  static FT_Error
-  Get_Kerning( TT_Face     face,
+  FT_CALLBACK_DEF( FT_Error )
+  Get_Kerning( FT_Face     ttface,          /* TT_Face */
                FT_UInt     left_glyph,
                FT_UInt     right_glyph,
                FT_Vector*  kerning )
   {
+    TT_Face        face = (TT_Face)ttface;
     TT_Kern0_Pair  pair;
 
 
@@ -178,13 +179,15 @@
   /* <Return>                                                              */
   /*    FreeType error code.  0 means success.                             */
   /*                                                                       */
-  static FT_Error
-  Load_Glyph( CFF_GlyphSlot  slot,
-              CFF_Size       size,
-              FT_UShort      glyph_index,
-              FT_Int32       load_flags )
+  FT_CALLBACK_DEF( FT_Error )
+  Load_Glyph( FT_GlyphSlot  cffslot,        /* CFF_GlyphSlot */
+              FT_Size       cffsize,        /* CFF_Size      */
+              FT_UInt       glyph_index,
+              FT_Int32      load_flags )
   {
     FT_Error  error;
+    CFF_GlyphSlot  slot = (CFF_GlyphSlot)cffslot;
+    CFF_Size       size = (CFF_Size)cffsize;
 
 
     if ( !slot )
@@ -409,8 +412,8 @@
   };
 
 
-  static FT_Module_Interface
-  cff_get_interface( CFF_Driver   driver,
+  FT_CALLBACK_DEF( FT_Module_Interface )
+  cff_get_interface( FT_Module    driver,       /* CFF_Driver */
                      const char*  module_interface )
   {
     FT_Module            sfnt;
@@ -422,7 +425,7 @@
       return  result;
 
     /* we pass our request to the `sfnt' module */
-    sfnt = FT_Get_Module( driver->root.root.library, "sfnt" );
+    sfnt = FT_Get_Module( driver->library, "sfnt" );
 
     return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0;
   }
@@ -446,9 +449,9 @@
 
       0,   /* module-specific interface */
 
-      (FT_Module_Constructor)cff_driver_init,
-      (FT_Module_Destructor) cff_driver_done,
-      (FT_Module_Requester)  cff_get_interface,
+      cff_driver_init,
+      cff_driver_done,
+      cff_get_interface,
     },
 
     /* now the specific driver fields */
@@ -456,21 +459,21 @@
     sizeof( CFF_SizeRec ),
     sizeof( CFF_GlyphSlotRec ),
 
-    (FT_Face_InitFunc)       cff_face_init,
-    (FT_Face_DoneFunc)       cff_face_done,
-    (FT_Size_InitFunc)       cff_size_init,
-    (FT_Size_DoneFunc)       cff_size_done,
-    (FT_Slot_InitFunc)       cff_slot_init,
-    (FT_Slot_DoneFunc)       cff_slot_done,
+    cff_face_init,
+    cff_face_done,
+    cff_size_init,
+    cff_size_done,
+    cff_slot_init,
+    cff_slot_done,
 
-    (FT_Size_ResetPointsFunc)cff_size_reset,
-    (FT_Size_ResetPixelsFunc)cff_size_reset,
+    cff_point_size_reset,
+    cff_size_reset,
 
-    (FT_Slot_LoadFunc)       Load_Glyph,
+    Load_Glyph,
 
-    (FT_Face_GetKerningFunc) Get_Kerning,
-    (FT_Face_AttachFunc)     0,
-    (FT_Face_GetAdvancesFunc)0,
+    Get_Kerning,
+    0,                      /* FT_Face_AttachFunc      */
+    0                       /* FT_Face_GetAdvancesFunc */
   };
 
 
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 44f3254..350e01f 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1095,7 +1095,7 @@
 
     idx->stream = stream;
     if ( !FT_READ_USHORT( count ) &&
-         count > 0             )
+         count > 0                )
     {
       FT_Byte*   p;
       FT_Byte    offsize;
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 4d23b9a..5860d21 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -135,8 +135,11 @@
 
 
   FT_LOCAL_DEF( void )
-  cff_size_done( CFF_Size  size )
+  cff_size_done( FT_Size  cffsize )        /* CFF_Size */
   {
+    CFF_Size  size = (CFF_Size)cffsize;
+
+
     if ( size->root.internal )
     {
       PSH_Globals_Funcs  funcs;
@@ -152,8 +155,9 @@
 
 
   FT_LOCAL_DEF( FT_Error )
-  cff_size_init( CFF_Size  size )
+  cff_size_init( FT_Size  cffsize )         /* CFF_Size */
   {
+    CFF_Size           size  = (CFF_Size)cffsize;
     FT_Error           error = CFF_Err_Ok;
     PSH_Globals_Funcs  funcs = cff_size_get_globals_funcs( size );
 
@@ -225,12 +229,18 @@
 
 
   FT_LOCAL_DEF( FT_Error )
-  cff_size_reset( CFF_Size  size )
+  cff_size_reset( FT_Size  cffsize,         /* CFF_Size */
+                  FT_UInt  char_width,
+                  FT_UInt  char_height )
   {
+    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_UNUSED( char_width );
+    FT_UNUSED( char_height );
+
 
     if ( funcs )
       error = funcs->set_scale( (PSH_Globals)size->root.internal,
@@ -257,6 +267,22 @@
   }
 
 
+  FT_LOCAL_DEF( FT_Error )
+  cff_point_size_reset( FT_Size     cffsize,
+                        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 cff_size_reset( cffsize, 0, 0 );
+  }
+
+
   /*************************************************************************/
   /*                                                                       */
   /*                            SLOT  FUNCTIONS                            */
@@ -264,15 +290,18 @@
   /*************************************************************************/
 
   FT_LOCAL_DEF( void )
-  cff_slot_done( CFF_GlyphSlot  slot )
+  cff_slot_done( FT_GlyphSlot  cffslot )        /* CFF_GlyphSlot */
   {
+    CFF_GlyphSlot  slot = (CFF_GlyphSlot)cffslot;
+
     slot->root.internal->glyph_hints = 0;
   }
 
 
   FT_LOCAL_DEF( FT_Error )
-  cff_slot_init( CFF_GlyphSlot  slot )
+  cff_slot_init( FT_GlyphSlot  cffslot )        /* CFF_GlyphSlot */
   {
+    CFF_GlyphSlot     slot     = (CFF_GlyphSlot)cffslot;
     CFF_Face          face     = (CFF_Face)slot->root.face;
     CFF_Font          font     = (CFF_FontRec *)face->extra.data;
     PSHinter_Service  pshinter = (PSHinter_Service)font->pshinter;
@@ -328,11 +357,12 @@
 
   FT_LOCAL_DEF( FT_Error )
   cff_face_init( FT_Stream      stream,
-                 CFF_Face       face,
+                 FT_Face        cffface,        /* CFF_Face */
                  FT_Int         face_index,
                  FT_Int         num_params,
                  FT_Parameter*  params )
   {
+    CFF_Face            face = (CFF_Face)cffface;
     FT_Error            error;
     SFNT_Service        sfnt;
     FT_Service_PsCMaps  psnames;
@@ -708,8 +738,9 @@
 
 
   FT_LOCAL_DEF( void )
-  cff_face_done( CFF_Face  face )
+  cff_face_done( FT_Face  cffface )         /* CFF_Face */
   {
+    CFF_Face      face   = (CFF_Face)cffface;
     FT_Memory     memory = face->root.memory;
     SFNT_Service  sfnt   = (SFNT_Service)face->sfnt;
 
@@ -731,18 +762,18 @@
 
 
   FT_LOCAL_DEF( FT_Error )
-  cff_driver_init( CFF_Driver  driver )
+  cff_driver_init( FT_Module  module )
   {
-    FT_UNUSED( driver );
+    FT_UNUSED( module );
 
     return CFF_Err_Ok;
   }
 
 
   FT_LOCAL_DEF( void )
-  cff_driver_done( CFF_Driver  driver )
+  cff_driver_done( FT_Module  module )
   {
-    FT_UNUSED( driver );
+    FT_UNUSED( module );
   }
 
 
diff --git a/src/cff/cffobjs.h b/src/cff/cffobjs.h
index f02a5d7..0a5c969 100644
--- a/src/cff/cffobjs.h
+++ b/src/cff/cffobjs.h
@@ -113,19 +113,28 @@ FT_BEGIN_HEADER
 
 
   FT_LOCAL( FT_Error )
-  cff_size_init( CFF_Size  size );
+  cff_size_init( FT_Size  size );           /* CFF_Size */
 
   FT_LOCAL( void )
-  cff_size_done( CFF_Size  size );
+  cff_size_done( FT_Size  size );           /* CFF_Size */
 
   FT_LOCAL( FT_Error )
-  cff_size_reset( CFF_Size  size );
+  cff_size_reset( FT_Size  size,            /* CFF_Size */
+                  FT_UInt  char_width,
+                  FT_UInt  char_height );
+
+  FT_LOCAL( FT_Error )
+  cff_point_size_reset( FT_Size     cffsize,
+                        FT_F26Dot6  char_width,
+                        FT_F26Dot6  char_height,
+                        FT_UInt     horz_resolution,
+                        FT_UInt     vert_resolution );
 
   FT_LOCAL( void )
-  cff_slot_done( CFF_GlyphSlot  slot );
+  cff_slot_done( FT_GlyphSlot  slot );      /* CFF_GlyphSlot */
 
   FT_LOCAL( FT_Error )
-  cff_slot_init( CFF_GlyphSlot   slot );
+  cff_slot_init( FT_GlyphSlot   slot );     /* CFF_GlyphSlot */
 
 
   /*************************************************************************/
@@ -134,13 +143,13 @@ FT_BEGIN_HEADER
   /*                                                                       */
   FT_LOCAL( FT_Error )
   cff_face_init( FT_Stream      stream,
-                 CFF_Face       face,
+                 FT_Face        face,           /* CFF_Face */
                  FT_Int         face_index,
                  FT_Int         num_params,
                  FT_Parameter*  params );
 
   FT_LOCAL( void )
-  cff_face_done( CFF_Face  face );
+  cff_face_done( FT_Face  face );               /* CFF_Face */
 
 
   /*************************************************************************/
@@ -148,10 +157,10 @@ FT_BEGIN_HEADER
   /* Driver functions                                                      */
   /*                                                                       */
   FT_LOCAL( FT_Error )
-  cff_driver_init( CFF_Driver  driver );
+  cff_driver_init( FT_Module  module );
 
   FT_LOCAL( void )
-  cff_driver_done( CFF_Driver  driver );
+  cff_driver_done( FT_Module  module );
 
 
 FT_END_HEADER
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index 3717eeb..cbd0865 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -269,14 +269,16 @@
 
 
   FT_LOCAL_DEF( FT_Error )
-  cid_slot_load_glyph( CID_GlyphSlot  glyph,
-                       CID_Size       size,
-                       FT_Int         glyph_index,
-                       FT_Int32       load_flags )
+  cid_slot_load_glyph( FT_GlyphSlot  cidglyph,      /* CID_GlyphSlot */
+                       FT_Size       cidsize,       /* CID_Size      */
+                       FT_UInt       glyph_index,
+                       FT_Int32      load_flags )
   {
+    CID_GlyphSlot  glyph = (CID_GlyphSlot)cidglyph;
+    CID_Size       size  = (CID_Size)cidsize;
     FT_Error       error;
     T1_DecoderRec  decoder;
-    CID_Face       face = (CID_Face)glyph->root.face;
+    CID_Face       face = (CID_Face)cidglyph->face;
     FT_Bool        hinting;
 
     PSAux_Service  psaux = (PSAux_Service)face->psaux;
@@ -287,22 +289,22 @@
     if ( load_flags & FT_LOAD_NO_RECURSE )
       load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
 
-    glyph->x_scale = size->root.metrics.x_scale;
-    glyph->y_scale = size->root.metrics.y_scale;
+    glyph->x_scale = cidsize->metrics.x_scale;
+    glyph->y_scale = cidsize->metrics.y_scale;
 
-    glyph->root.outline.n_points   = 0;
-    glyph->root.outline.n_contours = 0;
+    cidglyph->outline.n_points   = 0;
+    cidglyph->outline.n_contours = 0;
 
     hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
                        ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
 
-    glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
+    cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
 
     {
       error = psaux->t1_decoder_funcs->init( &decoder,
-                                             (FT_Face)face,
-                                             (FT_Size)size,
-                                             (FT_GlyphSlot)glyph,
+                                             cidglyph->face,
+                                             cidsize,
+                                             cidglyph,
                                              0, /* glyph names -- XXX */
                                              0, /* blend == 0 */
                                              hinting,
@@ -327,18 +329,18 @@
     /* bearing the yMax                                    */
     if ( !error )
     {
-      glyph->root.outline.flags &= FT_OUTLINE_OWNER;
-      glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
+      cidglyph->outline.flags &= FT_OUTLINE_OWNER;
+      cidglyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
 
       /* for composite glyphs, return only left side bearing and */
       /* advance width                                           */
       if ( load_flags & FT_LOAD_NO_RECURSE )
       {
-        FT_Slot_Internal  internal = glyph->root.internal;
+        FT_Slot_Internal  internal = cidglyph->internal;
 
 
-        glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
-        glyph->root.metrics.horiAdvance  = decoder.builder.advance.x;
+        cidglyph->metrics.horiBearingX = decoder.builder.left_bearing.x;
+        cidglyph->metrics.horiAdvance  = decoder.builder.advance.x;
 
         internal->glyph_matrix         = font_matrix;
         internal->glyph_delta          = font_offset;
@@ -347,30 +349,30 @@
       else
       {
         FT_BBox            cbox;
-        FT_Glyph_Metrics*  metrics = &glyph->root.metrics;
+        FT_Glyph_Metrics*  metrics = &cidglyph->metrics;
         FT_Vector          advance;
 
 
         /* copy the _unscaled_ advance width */
-        metrics->horiAdvance          = decoder.builder.advance.x;
-        glyph->root.linearHoriAdvance = decoder.builder.advance.x;
-        glyph->root.internal->glyph_transformed = 0;
+        metrics->horiAdvance                  = decoder.builder.advance.x;
+        cidglyph->linearHoriAdvance           = decoder.builder.advance.x;
+        cidglyph->internal->glyph_transformed = 0;
 
         /* make up vertical metrics */
         metrics->vertBearingX = 0;
         metrics->vertBearingY = 0;
         metrics->vertAdvance  = 0;
 
-        glyph->root.linearVertAdvance = 0;
-        glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
+        cidglyph->linearVertAdvance = 0;
+        cidglyph->format            = FT_GLYPH_FORMAT_OUTLINE;
 
-        if ( size && size->root.metrics.y_ppem < 24 )
-          glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
+        if ( size && cidsize->metrics.y_ppem < 24 )
+          cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
 
         /* apply the font matrix */
-        FT_Outline_Transform( &glyph->root.outline, &font_matrix );
+        FT_Outline_Transform( &cidglyph->outline, &font_matrix );
 
-        FT_Outline_Translate( &glyph->root.outline,
+        FT_Outline_Translate( &cidglyph->outline,
                               font_offset.x,
                               font_offset.y );
 
@@ -401,7 +403,7 @@
               vec->y = FT_MulFix( vec->y, y_scale );
             }
 
-          FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
+          FT_Outline_Get_CBox( &cidglyph->outline, &cbox );
 
           /* Then scale the metrics */
           metrics->horiAdvance  = FT_MulFix( metrics->horiAdvance,  x_scale );
@@ -421,7 +423,7 @@
         }
 
         /* compute the other metrics */
-        FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
+        FT_Outline_Get_CBox( &cidglyph->outline, &cbox );
 
         /* grid fit the bounding box if necessary */
         if ( hinting )
@@ -439,6 +441,7 @@
         metrics->horiBearingY = cbox.yMax;
       }
     }
+
     return error;
   }
 
diff --git a/src/cid/cidgload.h b/src/cid/cidgload.h
index 93858e8..a0a91bf 100644
--- a/src/cid/cidgload.h
+++ b/src/cid/cidgload.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    OpenType Glyph Loader (specification).                               */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002 by                                           */
+/*  Copyright 1996-2001, 2002, 2004 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -37,10 +37,10 @@ FT_BEGIN_HEADER
 #endif /* 0 */
 
   FT_LOCAL( FT_Error )
-  cid_slot_load_glyph( CID_GlyphSlot  glyph,
-                       CID_Size       size,
-                       FT_Int         glyph_index,
-                       FT_Int32       load_flags );
+  cid_slot_load_glyph( FT_GlyphSlot  glyph,         /* CID_Glyph_Slot */
+                       FT_Size       size,          /* CID_Size       */
+                       FT_UInt       glyph_index,
+                       FT_Int32      load_flags );
 
 
 FT_END_HEADER
diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c
index 356d018..691ec17 100644
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -47,20 +47,20 @@
   /*************************************************************************/
 
   FT_LOCAL_DEF( void )
-  cid_slot_done( CID_GlyphSlot  slot )
+  cid_slot_done( FT_GlyphSlot  slot )
   {
-    slot->root.internal->glyph_hints = 0;
+    slot->internal->glyph_hints = 0;
   }
 
 
   FT_LOCAL_DEF( FT_Error )
-  cid_slot_init( CID_GlyphSlot  slot )
+  cid_slot_init( FT_GlyphSlot  slot )
   {
     CID_Face          face;
     PSHinter_Service  pshinter;
 
 
-    face     = (CID_Face)slot->root.face;
+    face     = (CID_Face)slot->face;
     pshinter = (PSHinter_Service)face->pshinter;
 
     if ( pshinter )
@@ -68,7 +68,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 )
       {
@@ -76,7 +76,7 @@
 
 
         funcs = pshinter->get_t1_funcs( module );
-        slot->root.internal->glyph_hints = (void*)funcs;
+        slot->internal->glyph_hints = (void*)funcs;
       }
     }
 
@@ -108,25 +108,29 @@
 
 
   FT_LOCAL_DEF( void )
-  cid_size_done( CID_Size  size )
+  cid_size_done( FT_Size  cidsize )         /* CID_Size */
   {
-    if ( size->root.internal )
+    CID_Size  size = (CID_Size)cidsize;
+
+
+    if ( cidsize->internal )
     {
       PSH_Globals_Funcs  funcs;
 
 
       funcs = cid_size_get_globals_funcs( size );
       if ( funcs )
-        funcs->destroy( (PSH_Globals)size->root.internal );
+        funcs->destroy( (PSH_Globals)cidsize->internal );
 
-      size->root.internal = 0;
+      cidsize->internal = 0;
     }
   }
 
 
   FT_LOCAL_DEF( FT_Error )
-  cid_size_init( CID_Size  size )
+  cid_size_init( FT_Size  cidsize )     /* CID_Size */
   {
+    CID_Size           size  = (CID_Size)cidsize;
     FT_Error           error = 0;
     PSH_Globals_Funcs  funcs = cid_size_get_globals_funcs( size );
 
@@ -134,14 +138,14 @@
     if ( funcs )
     {
       PSH_Globals   globals;
-      CID_Face      face = (CID_Face)size->root.face;
+      CID_Face      face = (CID_Face)cidsize->face;
       CID_FaceDict  dict = face->cid.font_dicts + face->root.face_index;
       PS_Private    priv = &dict->private_dict;
 
 
-      error = funcs->create( size->root.face->memory, priv, &globals );
+      error = funcs->create( cidsize->face->memory, priv, &globals );
       if ( !error )
-        size->root.internal = (FT_Size_Internal)(void*)globals;
+        cidsize->internal = (FT_Size_Internal)(void*)globals;
     }
 
     return error;
@@ -149,21 +153,43 @@
 
 
   FT_LOCAL_DEF( FT_Error )
-  cid_size_reset( CID_Size  size )
+  cid_size_reset( FT_Size  cidsize,             /* CID_Size */
+                  FT_UInt  char_width,
+                  FT_UInt  char_height )
   {
+    CID_Size           size  = (CID_Size)cidsize;
     PSH_Globals_Funcs  funcs = cid_size_get_globals_funcs( size );
     FT_Error           error = 0;
 
+    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)cidsize->internal,
+                                 cidsize->metrics.x_scale,
+                                 cidsize->metrics.y_scale,
                                  0, 0 );
     return error;
   }
 
 
+  FT_LOCAL_DEF( FT_Error )
+  cid_point_size_reset( 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 cid_size_reset( size, 0, 0 );
+  }
+
+
   /*************************************************************************/
   /*                                                                       */
   /*                           FACE  FUNCTIONS                             */
@@ -182,8 +208,9 @@
   /*    face :: A pointer to the face object to destroy.                   */
   /*                                                                       */
   FT_LOCAL_DEF( void )
-  cid_face_done( CID_Face  face )
+  cid_face_done( FT_Face  cidface )         /* CID_Face */
   {
+    CID_Face   face = (CID_Face)cidface;
     FT_Memory  memory;
 
 
@@ -193,7 +220,7 @@
       PS_FontInfo   info = &cid->font_info;
 
 
-      memory = face->root.memory;
+      memory = cidface->memory;
 
       /* release subrs */
       if ( face->subrs )
@@ -232,8 +259,8 @@
       FT_FREE( cid->registry );
       FT_FREE( cid->ordering );
 
-      face->root.family_name = 0;
-      face->root.style_name  = 0;
+      cidface->family_name = 0;
+      cidface->style_name  = 0;
 
       FT_FREE( face->binary_data );
       FT_FREE( face->cid_stream );
@@ -266,11 +293,12 @@
   /*                                                                       */
   FT_LOCAL_DEF( FT_Error )
   cid_face_init( FT_Stream      stream,
-                 CID_Face       face,
+                 FT_Face        cidface,        /* CID_Face */
                  FT_Int         face_index,
                  FT_Int         num_params,
                  FT_Parameter*  params )
   {
+    CID_Face            face = (CID_Face)cidface;
     FT_Error            error;
     FT_Service_PsCMaps  psnames;
     PSAux_Service       psaux;
@@ -281,7 +309,7 @@
     FT_UNUSED( stream );
 
 
-    face->root.num_faces = 1;
+    cidface->num_faces = 1;
 
     FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
 
@@ -329,33 +357,32 @@
 
     /* set up root face fields */
     {
-      FT_Face       root = (FT_Face)&face->root;
       CID_FaceInfo  cid  = &face->cid;
       PS_FontInfo   info = &cid->font_info;
 
 
-      root->num_glyphs   = cid->cid_count;
-      root->num_charmaps = 0;
+      cidface->num_glyphs   = cid->cid_count;
+      cidface->num_charmaps = 0;
 
-      root->face_index = face_index;
-      root->face_flags = FT_FACE_FLAG_SCALABLE;
+      cidface->face_index = face_index;
+      cidface->face_flags = FT_FACE_FLAG_SCALABLE;
 
-      root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
+      cidface->face_flags |= FT_FACE_FLAG_HORIZONTAL;
 
       if ( info->is_fixed_pitch )
-        root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
+        cidface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
 
       /* XXX: TODO: add kerning with .afm support */
 
       /* get style name -- be careful, some broken fonts only */
       /* have a /FontName dictionary entry!                   */
-      root->family_name = info->family_name;
+      cidface->family_name = info->family_name;
       /* assume "Regular" style if we don't know better */
-      root->style_name = (char *)"Regular";
-      if ( root->family_name )
+      cidface->style_name = (char *)"Regular";
+      if ( cidface->family_name )
       {
         char*  full   = info->full_name;
-        char*  family = root->family_name;
+        char*  family = cidface->family_name;
 
 
         if ( full )
@@ -376,7 +403,7 @@
               else
               {
                 if ( !*family )
-                  root->style_name = full;
+                  cidface->style_name = full;
                 break;
               }
             }
@@ -387,42 +414,42 @@
       {
         /* do we have a `/FontName'? */
         if ( cid->cid_font_name )
-          root->family_name = cid->cid_font_name;
+          cidface->family_name = cid->cid_font_name;
       }
 
       /* compute style flags */
-      root->style_flags = 0;
+      cidface->style_flags = 0;
       if ( info->italic_angle )
-        root->style_flags |= FT_STYLE_FLAG_ITALIC;
+        cidface->style_flags |= FT_STYLE_FLAG_ITALIC;
       if ( info->weight )
       {
         if ( !ft_strcmp( info->weight, "Bold"  ) ||
              !ft_strcmp( info->weight, "Black" ) )
-          root->style_flags |= FT_STYLE_FLAG_BOLD;
+          cidface->style_flags |= FT_STYLE_FLAG_BOLD;
       }
 
       /* no embedded bitmap support */
-      root->num_fixed_sizes = 0;
-      root->available_sizes = 0;
+      cidface->num_fixed_sizes = 0;
+      cidface->available_sizes = 0;
 
-      root->bbox.xMin =   cid->font_bbox.xMin             >> 16;
-      root->bbox.yMin =   cid->font_bbox.yMin             >> 16;
-      root->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFFU ) >> 16;
-      root->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFFU ) >> 16;
+      cidface->bbox.xMin =   cid->font_bbox.xMin             >> 16;
+      cidface->bbox.yMin =   cid->font_bbox.yMin             >> 16;
+      cidface->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFFU ) >> 16;
+      cidface->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFFU ) >> 16;
 
-      if ( !root->units_per_EM )
-        root->units_per_EM = 1000;
+      if ( !cidface->units_per_EM )
+        cidface->units_per_EM = 1000;
 
-      root->ascender  = (FT_Short)( root->bbox.yMax );
-      root->descender = (FT_Short)( root->bbox.yMin );
-      root->height    = (FT_Short)(
-        ( ( root->ascender - root->descender ) * 12 ) / 10 );
+      cidface->ascender  = (FT_Short)( cidface->bbox.yMax );
+      cidface->descender = (FT_Short)( cidface->bbox.yMin );
+      cidface->height    = (FT_Short)(
+        ( ( cidface->ascender - cidface->descender ) * 12 ) / 10 );
 
-      root->underline_position  = (FT_Short)info->underline_position;
-      root->underline_thickness = (FT_Short)info->underline_thickness;
+      cidface->underline_position  = (FT_Short)info->underline_position;
+      cidface->underline_thickness = (FT_Short)info->underline_thickness;
 
-      root->internal->max_points   = 0;
-      root->internal->max_contours = 0;
+      cidface->internal->max_points   = 0;
+      cidface->internal->max_contours = 0;
     }
 
   Exit:
@@ -445,7 +472,7 @@
   /*    FreeType error code.  0 means success.                             */
   /*                                                                       */
   FT_LOCAL_DEF( FT_Error )
-  cid_driver_init( CID_Driver  driver )
+  cid_driver_init( FT_Module  driver )
   {
     FT_UNUSED( driver );
 
@@ -465,7 +492,7 @@
   /*    driver :: A handle to the target CID driver.                       */
   /*                                                                       */
   FT_LOCAL_DEF( void )
-  cid_driver_done( CID_Driver  driver )
+  cid_driver_done( FT_Module  driver )
   {
     FT_UNUSED( driver );
   }
diff --git a/src/cid/cidobjs.h b/src/cid/cidobjs.h
index 2d72d73..9d230ba 100644
--- a/src/cid/cidobjs.h
+++ b/src/cid/cidobjs.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    CID objects manager (specification).                                 */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002 by                                           */
+/*  Copyright 1996-2001, 2002, 2004 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -112,42 +112,47 @@ FT_BEGIN_HEADER
 
 
   FT_LOCAL( void )
-  cid_slot_done( CID_GlyphSlot  slot );
+  cid_slot_done( FT_GlyphSlot  slot );
 
   FT_LOCAL( FT_Error )
-  cid_slot_init( CID_GlyphSlot   slot );
+  cid_slot_init( FT_GlyphSlot  slot );
 
 
   FT_LOCAL( void )
-  cid_size_done( CID_Size  size );
-
+  cid_size_done( FT_Size  size );       /* CID_Size */
 
   FT_LOCAL( FT_Error )
-  cid_size_init( CID_Size  size );
+  cid_size_init( FT_Size  size );       /* CID_Size */
 
+  FT_LOCAL( FT_Error )
+  cid_size_reset( FT_Size  size,        /* CID_Size */
+                  FT_UInt  char_width,
+                  FT_UInt  char_height );
 
   FT_LOCAL( FT_Error )
-  cid_size_reset( CID_Size  size );
+  cid_point_size_reset( FT_Size     size,
+                        FT_F26Dot6  char_width,
+                        FT_F26Dot6  char_height,
+                        FT_UInt     horz_resolution,
+                        FT_UInt     vert_resolution );
 
 
   FT_LOCAL( FT_Error )
   cid_face_init( FT_Stream      stream,
-                 CID_Face       face,
+                 FT_Face        face,           /* CID_Face */
                  FT_Int         face_index,
                  FT_Int         num_params,
                  FT_Parameter*  params );
 
-
   FT_LOCAL( void )
-  cid_face_done( CID_Face  face );
+  cid_face_done( FT_Face  face );               /* CID_Face */
 
 
   FT_LOCAL( FT_Error )
-  cid_driver_init( CID_Driver  driver );
-
+  cid_driver_init( FT_Module  driver );
 
   FT_LOCAL( void )
-  cid_driver_done( CID_Driver  driver );
+  cid_driver_done( FT_Module  driver );
 
 
 FT_END_HEADER
diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c
index f5639b9..7d885a8 100644
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    CID driver interface (body).                                         */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2003 by                                     */
+/*  Copyright 1996-2001, 2002, 2003, 2004 by                               */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -97,12 +97,11 @@
   };
 
 
-  static FT_Module_Interface
-  cid_get_interface( FT_Driver         driver,
-                     const FT_String*  cid_interface )
+  FT_CALLBACK_DEF( FT_Module_Interface )
+  cid_get_interface( FT_Module    module,
+                     const char*  cid_interface )
   {
-    FT_UNUSED( driver );
-    FT_UNUSED( cid_interface );
+    FT_UNUSED( module );
 
     return ft_service_list_lookup( cid_services, cid_interface );
   }
@@ -125,9 +124,9 @@
 
       0,
 
-      (FT_Module_Constructor)cid_driver_init,
-      (FT_Module_Destructor) cid_driver_done,
-      (FT_Module_Requester)  cid_get_interface
+      cid_driver_init,
+      cid_driver_done,
+      cid_get_interface
     },
 
     /* then the other font drivers fields */
@@ -135,23 +134,23 @@
     sizeof( CID_SizeRec ),
     sizeof( CID_GlyphSlotRec ),
 
-    (FT_Face_InitFunc)       cid_face_init,
-    (FT_Face_DoneFunc)       cid_face_done,
+    cid_face_init,
+    cid_face_done,
 
-    (FT_Size_InitFunc)       cid_size_init,
-    (FT_Size_DoneFunc)       cid_size_done,
-    (FT_Slot_InitFunc)       cid_slot_init,
-    (FT_Slot_DoneFunc)       cid_slot_done,
+    cid_size_init,
+    cid_size_done,
+    cid_slot_init,
+    cid_slot_done,
 
-    (FT_Size_ResetPointsFunc)cid_size_reset,
-    (FT_Size_ResetPixelsFunc)cid_size_reset,
+    cid_point_size_reset,
+    cid_size_reset,
 
-    (FT_Slot_LoadFunc)       cid_slot_load_glyph,
+    cid_slot_load_glyph,
 
-    (FT_Face_GetKerningFunc) 0,
-    (FT_Face_AttachFunc)     0,
+    0,                      /* FT_Face_GetKerningFunc  */
+    0,                      /* FT_Face_AttachFunc      */
 
-    (FT_Face_GetAdvancesFunc)0,
+    0                       /* FT_Face_GetAdvancesFunc */
   };
 
 
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index 30e5b6f..2594883 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -388,7 +388,7 @@
   };
 
 
-  static FT_Module_Interface
+  FT_CALLBACK_DEF( FT_Module_Interface )
   tt_get_interface( FT_Module    driver,    /* TT_Driver */
                     const char*  tt_interface )
   {
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index e81f4df..7c640de 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -304,15 +304,7 @@
     {
       segment->pairCount = FT_GET_USHORT();
       if ( FT_NEW_ARRAY( segment->correspondence, segment->pairCount ) )
-      {
-        /* Failure.  Free everything we have done so far. */
-
-        for ( j = i - 1; j >= 0; --j )
-          FT_FREE( blend->avar_segment[j].correspondence );
-
-        FT_FREE( blend->avar_segment );
         goto Exit;
-      }
 
       for ( j = 0; j < segment->pairCount; ++j )
       {
@@ -408,7 +400,7 @@
 
     if ( gvar_head.flags & 1 )
     {
-      /* long offsets (one more offset than glyph, to mark size of last) */
+      /* long offsets (one more offset than glyphs, to mark size of last) */
       if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 4L ) )
         goto Exit;
     
@@ -419,9 +411,10 @@
     }
     else
     {
-      /* short offsets (one more offset than glyph, to mark size of last) */
+      /* short offsets (one more offset than glyphs, to mark size of last) */
       if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 2L ) )
         goto Exit;
+
       for ( i = 0; i <= blend->gv_glyphcnt; ++i )
         blend->glyphoffsets[i] = OffsetToData + FT_GET_USHORT() * 2;
                                               /* XXX: Undocumented: `*2'! */
@@ -435,10 +428,8 @@
                          gvar_head.axisCount * blend->tuplecount ) )
         goto Exit;
 
-      if ( FT_STREAM_SEEK( gvar_start + gvar_head.offsetToCoord ) ||
-           FT_FRAME_ENTER( blend->tuplecount
-                           * gvar_head.axisCount
-                           * sizeof ( short ) )                   )
+      if ( FT_STREAM_SEEK( gvar_start + gvar_head.offsetToCoord )       ||
+           FT_FRAME_ENTER( blend->tuplecount * gvar_head.axisCount * 2L )                   )
         goto Exit;
       
       for ( i = 0; i < blend->tuplecount; ++i )
@@ -469,11 +460,11 @@
   /*    tupleIndex      :: A flag saying whether this is an intermediate   */
   /*                       tuple or not.                                   */
   /*                                                                       */
-  /*    tuple_coords    :: The coordiates of the tuple in normalized axis  */
+  /*    tuple_coords    :: The coordinates of the tuple in normalized axis */
   /*                       units.                                          */
   /*                                                                       */
-  /*    im_start_coords :: The initial coordinatess where this tuple       */
-  /*                       starts to apply (for intermediate coordinates). */
+  /*    im_start_coords :: The initial coordinates where this tuple starts */
+  /*                       to apply (for intermediate coordinates).        */
   /*                                                                       */
   /*    im_end_coords   :: The final coordinates after which this tuple no */
   /*                       longer applies (for intermediate coordinates).  */
@@ -621,7 +612,7 @@
 #undef  FT_STRUCTURE
 #define FT_STRUCTURE  GX_FVar_Head
 
-      FT_FRAME_START( 14 ),
+      FT_FRAME_START( 16 ),
         FT_FRAME_LONG  ( version ),
         FT_FRAME_USHORT( offsetToData ),
         FT_FRAME_USHORT( countSizePairs ),
@@ -745,7 +736,7 @@
       ns = mmvar->namedstyle;
       for ( i = 0; i < fvar_head.instanceCount; ++i )
       {
-        if ( FT_FRAME_ENTER( 4 + 4 * fvar_head.axisCount ) )
+        if ( FT_FRAME_ENTER( 4L + 4L * fvar_head.axisCount ) )
           goto Exit;
 
         ns->strid       =    FT_GET_USHORT();
@@ -1304,9 +1295,9 @@
     FT_ULong    OffsetToData;
     FT_ULong    here;
     FT_UInt     i, j;
-    FT_Fixed*   tuple_coords = NULL;
+    FT_Fixed*   tuple_coords    = NULL;
     FT_Fixed*   im_start_coords = NULL;
-    FT_Fixed*   im_end_coords = NULL;
+    FT_Fixed*   im_end_coords   = NULL;
     FT_UInt     point_count, spoint_count = 0;
     FT_UShort*  sharedpoints = NULL;
     FT_UShort*  localpoints;
@@ -1317,8 +1308,9 @@
     if ( !face->doblend || blend == NULL )
       return TT_Err_Invalid_Argument;
 
+    /* to be freed by the caller */
     if ( ( error = FT_NEW_ARRAY( delta_xy, n_points ) ) )
-      goto Fail;
+      goto Exit;
     *deltas = delta_xy;
 
     if ( glyph_index >= blend->gv_glyphcnt      ||
@@ -1329,7 +1321,7 @@
     if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] )   ||
          FT_FRAME_ENTER( blend->glyphoffsets[glyph_index + 1] -
                            blend->glyphoffsets[glyph_index] ) )
-      goto Fail;
+      goto Fail1;
 
     glyph_start = FT_Stream_FTell( stream );
 
@@ -1339,7 +1331,7 @@
     if ( FT_NEW_ARRAY( tuple_coords, blend->num_axis )    ||
          FT_NEW_ARRAY( im_start_coords, blend->num_axis ) ||
          FT_NEW_ARRAY( im_end_coords, blend->num_axis )   )
-      goto Exit;
+      goto Fail2;
 
     tupleCount   = FT_GET_USHORT();
     OffsetToData = glyph_start + FT_GET_USHORT();
@@ -1375,7 +1367,7 @@
       else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
       {
         error = TT_Err_Invalid_Table;
-        goto Fail;
+        goto Fail3;
       }
       else
       {
@@ -1428,7 +1420,7 @@
                                                            : point_count );
 
       if ( points == NULL || deltas_y == NULL || deltas_x == NULL )
-        /* failure, ignore it */;
+        ; /* failure, ignore it */
 
       else if ( points == ALL_POINTS )
       {
@@ -1459,17 +1451,22 @@
       FT_Stream_SeekSet( stream, here );
     }
 
+    FT_FRAME_EXIT();
     goto Exit;
 
-  Fail:
-    FT_FREE( delta_xy );
-    *deltas = NULL;
-
-  Exit:
+  Fail3:
     FT_FREE( tuple_coords );
     FT_FREE( im_start_coords );
     FT_FREE( im_end_coords );
 
+  Fail2:
+    FT_FRAME_EXIT();
+
+  Fail1:
+    FT_FREE( delta_xy );
+    *deltas = NULL;
+
+  Exit:
     return error;
   }
 
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index 89d7c88..3914ba5 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -892,7 +892,7 @@
       driver->context = NULL;
     }
 #else
-    FT_UNUSED( driver );
+    FT_UNUSED( ttdriver );
 #endif
 
   }