Commit d186a361a1f9aab15e9bd2a0597e6fc381f2c17f

David Turner 2000-05-02T17:41:41

various updates to reduce the compilation warnings

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
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
diff --git a/demos/Makefile b/demos/Makefile
index bdcca7f..5a1b905 100644
--- a/demos/Makefile
+++ b/demos/Makefile
@@ -187,6 +187,9 @@ else
   $(OBJ_)ftgrays2.$O: $(SRC_DIR_)ftgrays2.c
 	  $(COMPILE) $T$@ $<
 
+  $(OBJ_)ftrast.$O: $(SRC_DIR_)ftrast.c
+	  $(COMPILE) $T$@ $<
+
   $(OBJ_)fttry.$O: $(SRC_DIR_)fttry.c
 	  $(COMPILE) $T$@ $<
 
@@ -261,7 +264,7 @@ else
 	  $(LINK)
 
 
-  $(BIN_)ftview$E: $(OBJ_)ftview.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ)
+  $(BIN_)ftview$E: $(OBJ_)ftview.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ) $(OBJ_)ftrast.$O
 	  $(GRAPH_LINK)
 
   $(BIN_)ftstring$E: $(OBJ_)ftstring.$O $(FTLIB) $(GRAPH_LIB) $(COMMON_OBJ)
diff --git a/demos/src/ftrast.c b/demos/src/ftrast.c
index 4f5c895..756912e 100644
--- a/demos/src/ftrast.c
+++ b/demos/src/ftrast.c
@@ -20,7 +20,7 @@
  *
  ******************************************************************/
 
-#include "frast.h"
+#include "ftrast.h"
 #include <ftcalc.h>      /* for FT_MulDiv only */
 
   /****************************************************************/
@@ -44,17 +44,20 @@
 /* The default render pool size */
 #define  RASTER_RENDER_POOL   8192
 
+/* XXXXX */
+#define FT_CONFIG_OPTION_GRAY_SCALING
+
 /* The size of the two-lines intermediate bitmap used */
 /* for anti-aliasing                                  */
 #define  RASTER_GRAY_LINES    1024
 
-#define Raster_Err_None              TT_Err_Ok
-#define Raster_Err_Not_Ini           TT_Err_Raster_Not_Initialized
-#define Raster_Err_Overflow          TT_Err_Raster_Pool_Overflow
-#define Raster_Err_Neg_Height        TT_Err_Raster_Negative_Height
-#define Raster_Err_Invalid           TT_Err_Raster_Invalid_Value
-#define Raster_Err_Gray_Unsupported  TT_Err_Raster_Gray_Unsupported
-
+#define Raster_Err_None              0
+#define Raster_Err_Not_Ini           -1
+#define Raster_Err_Overflow          -2
+#define Raster_Err_Neg_Height        -3
+#define Raster_Err_Invalid           -4
+#define Raster_Err_Gray_Unsupported  -5
+#define Raster_Err_Unsupported       -6
 
 /* FMulDiv means "Fast MulDiv", it is uses in case where 'b' is typically */
 /* a small value and the result of (a*b) is known to fit in 32 bits.      */
@@ -86,7 +89,13 @@
 #define NULL  (void*)0
 #endif
 
+#ifndef SUCCESS
+#define SUCCESS 0
+#endif
 
+#ifndef FAILURE
+#define FAILURE 1
+#endif
 
 
 #define MaxBezier  32   /* The maximum number of stacked Bezier curves. */
@@ -148,7 +157,7 @@
   {
     FT_F26Dot6  X;           /* current coordinate during sweep          */
     PProfile    link;        /* link to next profile - various purpose   */
-    PStorage    offset;      /* start of profile's data in render pool   */
+    PLong       offset;      /* start of profile's data in render pool   */
     Int         flow;        /* Profile orientation: Asc/Descending      */
     Long        height;      /* profile's height in scanlines            */
     Long        start;       /* profile's starting scanline              */
@@ -274,11 +283,6 @@
 
     FT_Error  error;
 
-    PByte     flags;                /* current flags table    */
-    PUShort   outs;                 /* current outlines table */
-
-    UShort    nPoints;              /* number of points in current glyph   */
-    Short     nContours;            /* number of contours in current glyph */
     Int       numTurns;             /* number of Y-turns in outline        */
 
     TPoint*   arc;                  /* current Bezier arc pointer */
@@ -302,7 +306,8 @@
                                     /* of impact                         */
     TStates   state;                /* rendering state */
 
-    FT_Bitmap target;          /* description of target bit/pixmap */
+    FT_Bitmap  target;          /* description of target bit/pixmap */
+    FT_Outline outline;
 
     Long      traceOfs;             /* current offset in target bitmap */
     Long      traceG;               /* current offset in target pixmap */
@@ -319,8 +324,6 @@
     Function_Sweep_Span*  Proc_Sweep_Drop;
     Function_Sweep_Step*  Proc_Sweep_Step;
 
-    FT_Vector*  coords;
-
     Byte      dropOutControl;       /* current drop_out control method */
 
     Byte      grays[5];         /* Palette of gray levels used for render */
@@ -348,6 +351,19 @@
 
     Int       count_table[256];     /* Look-up table used to quickly count */
                                     /* set bits in a gray 2x2 cell         */
+
+    void*     memory;
+    
+#if 0
+    PByte     flags;                /* current flags table    */
+    PUShort   outs;                 /* current outlines table */
+    FT_Vector*  coords;
+
+    UShort    nPoints;              /* number of points in current glyph   */
+    Short     nContours;            /* number of contours in current glyph */
+#endif
+
+
   };
 
 
@@ -437,12 +453,12 @@
     switch ( aState )
     {
     case Ascending:
-      ras.cProfile->flow = FT_Flow_Up;
+      ras.cProfile->flow = Flow_Up;
       FT_TRACE7(( "New ascending profile = %lx\n", (long)ras.cProfile ));
       break;
 
     case Descending:
-      ras.cProfile->flow = FT_Flow_Down;
+      ras.cProfile->flow = Flow_Down;
       FT_TRACE7(( "New descending profile = %lx\n", (long)ras.cProfile ));
       break;
 
@@ -541,7 +557,7 @@
   static
   Bool Insert_Y_Turn( RAS_ARGS  Int  y )
   {
-    PStorage  y_turns;
+    PLong     y_turns;
     Int       y2, n;
 
     n       = ras.numTurns-1;
@@ -611,14 +627,14 @@
 
         switch ( p->flow )
         {
-        case FT_Flow_Down:
+        case Flow_Down:
           bottom     = p->start - p->height+1;
           top        = p->start;
           p->start   = bottom;
           p->offset += p->height-1;
           break;
 
-        case FT_Flow_Up:
+        case Flow_Up:
         default:
           bottom = p->start;
           top    = p->start + p->height-1;
@@ -720,35 +736,6 @@
   }
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    Push_Cubic                                                         */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Clears the Bezier stack and pushes a new third-order Bezier arc on */
-  /*    top of it.                                                         */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    p2 :: A pointer to the second (control) point.                     */
-  /*    p3 :: A pointer to the third (control) point.                      */
-  /*    p4 :: A pointer to the fourth (end) point.                         */
-  /*                                                                       */
-  /* <Note>                                                                */
-  /*    The first point is taken as `raster->last', so it doesn't appear   */
-  /*    in the signature.                                                  */
-  /*                                                                       */
-  /*    This is the same as Push_Conic(), except that it deals with        */
-  /*    third-order Beziers.                                               */
-  /*                                                                       */
-  static
-  static void  Push_Cubic( RAS_ARGS Long  x1, Long  y1,
-                                    Long  x2, Long  y2,
-                                    Long  x3, Long  y3,
-                                    Long  x4, Long  y4 )
-  {
-  }
-
 
 /****************************************************************************/
 /*                                                                          */
@@ -772,7 +759,7 @@
     Int   e1, e2, f1, f2, size;     /* XXX: is `Short' sufficient? */
     Long  Ix, Rx, Ax;
 
-    PStorage  top;
+    PLong  top;
 
 
     Dx = x2 - x1;
@@ -913,7 +900,7 @@
     TPoint*  arc;
     TPoint*  start_arc;
 
-    PStorage top;
+    PLong top;
 
 
     arc = ras.arc;
@@ -1138,7 +1125,7 @@
                                   Long  cx,
                                   Long  cy )
   {
-    Long     y1, y2, y3, x3;
+    Long     y1, y2, y3, x3, ymin, ymax;
     TStates  state_bez;
 
 
@@ -1192,18 +1179,18 @@
             goto Fail;
 
           /* create a new profile */
-          if ( New_Profile( RAS_VAR_ state_bez ) )
+          if ( New_Profile( RAS_VARS state_bez ) )
             goto Fail;
         }
 
         /* now call the appropriate routine */
         if ( state_bez == Ascending )
         {
-          if ( Bezier_Up( RAS_VAR_  2, Split_Conic, ras.minY, ras.maxY ) )
+          if ( Bezier_Up( RAS_VARS  2, Split_Conic, ras.minY, ras.maxY ) )
             goto Fail;
         }
         else
-          if ( Bezier_Down( RAS_VAR_  2, Split_Conic, ras.minY, ras.maxY ) )
+          if ( Bezier_Down( RAS_VARS  2, Split_Conic, ras.minY, ras.maxY ) )
             goto Fail;
       }
 
@@ -1213,6 +1200,8 @@
     ras.lastY = y3;
 
     return SUCCESS;
+  Fail:
+    return FAILURE;
   }
 
 /****************************************************************************/
@@ -1226,11 +1215,10 @@
                                   Long  y,
                                   Long  cx1,
                                   Long  cy1,
-                                  Lonc  cx2,
+                                  Long  cx2,
                                   Long  cy2 )
   {
-    TPos     y1, y2, y3, y4, x4, ymin1, ymax1, ymin2, ymax2;
-    Long     y0, y1, y2, y3, x3;
+    Long     y1, y2, y3, y4, x4, ymin1, ymax1, ymin2, ymax2;
     TStates  state_bez;
 
 
@@ -1295,25 +1283,25 @@
                End_Profile( RAS_VAR ) )
             goto Fail;
 
-          if ( New_Profile( RAS_VAR_ state_bez ) )
+          if ( New_Profile( RAS_VARS state_bez ) )
             goto Fail;
         }
 
         /* compute intersections */
         if ( state_bez == Ascending )
         {
-          if ( Bezier_Up ( RAS_VAR_ 3, Split_Cubic, ras.minY, ras.maxY ) )
+          if ( Bezier_Up ( RAS_VARS 3, Split_Cubic, ras.minY, ras.maxY ) )
             goto Fail;
         }
         else
-          if ( Bezier_Down ( RAS_VAR_ 3, Split_Cubic, ras.minY, ras.maxY ) )
+          if ( Bezier_Down ( RAS_VARS 3, Split_Cubic, ras.minY, ras.maxY ) )
             goto Fail;
       }
 
     } while ( ras.arc >= ras.arcs );
 
-    ras.lastX = x4
-    ras.lastY = y4
+    ras.lastX = x4;
+    ras.lastY = y4;
 
     return SUCCESS;
   Fail:
@@ -1356,9 +1344,6 @@
     FT_Vector* limit;
     char*      tags;
 
-    int    n;         /* index of contour in outline     */
-    int    first;     /* index of first point in contour */
-    int    error;
     char   tag;       /* current point's state           */
 
     points = ras.outline.points;
@@ -1377,7 +1362,7 @@
     v_control = v_start;
 
     point = points + first;
-    tags  = ras.outline->tags  + first;
+    tags  = ras.outline.tags  + first;
     tag   = FT_CURVE_TAG( tags[0] );
 
     /* A contour cannot start with a cubic control point! */
@@ -1388,7 +1373,7 @@
     if ( tag == FT_Curve_Tag_Conic )
     {
       /* first point is conic control.  Yes, this happens. */
-      if ( FT_CURVE_TAG( ras.outline->tags[last] ) == FT_Curve_Tag_On )
+      if ( FT_CURVE_TAG( ras.outline.tags[last] ) == FT_Curve_Tag_On )
       {
         /* start at last point if it is on the curve */
         v_start = v_last;
@@ -1515,17 +1500,16 @@
     /* close the contour with a line segment */
     if (Line_To( RAS_VARS v_start.x, v_start.y ))
       goto Fail;
-  }
 
-Close:
-  return SUCCESS;
+  Close:
+    return SUCCESS;
+    
+  Invalid_Outline:
+    ras.error = Raster_Err_Invalid;
   
-Invalid_Outline:
-  ras.error = Raster_Err_Invalid;
-
-Fail:
-  return FAILURE;
-}
+  Fail:
+    return FAILURE;
+  }
   
 /****************************************************************************/
 /*                                                                          */
@@ -1565,15 +1549,15 @@ Fail:
 
     start = 0;
 
-    for ( i = 0; i < ras.nContours; i++ )
+    for ( i = 0; i < ras.outline.n_contours; i++ )
     {
       ras.state    = Unknown;
       ras.gProfile = NULL;
 
-      if ( Decompose_Curve( RAS_VARS  start, ras.outs[i], flipped ) )
+      if ( Decompose_Curve( RAS_VARS  start, ras.outline.contours[i], flipped ) )
         return FAILURE;
 
-      start = ras.outs[i] + 1;
+      start = ras.outline.contours[i] + 1;
 
       /* We must now see if the extreme arcs join or not */
       if ( ( FRAC( ras.lastY ) == 0 &&
@@ -1775,18 +1759,15 @@ Fail:
 
   static void  Vertical_Sweep_Init( RAS_ARGS Short*  min, Short*  max )
   {
-    switch ( ras.target.flow )
-    {
-    case FT_Flow_Up:
-      ras.traceOfs  = *min * ras.target.cols;
-      ras.traceIncr = ras.target.cols;
-      break;
-
-    default:
-      ras.traceOfs  = ( ras.target.rows - 1 - *min ) * ras.target.cols;
-      ras.traceIncr = -ras.target.cols;
-    }
-
+    Long  pitch = ras.target.pitch;
+    
+    (void)max;
+    
+    ras.traceIncr = - pitch;
+    ras.traceOfs  = - *min * pitch;
+    if (ras.traceIncr > 0)
+      ras.traceOfs += (ras.target.rows-1)*pitch;
+  
     ras.gray_min_x = 0;
     ras.gray_max_x = 0;
   }
@@ -1800,9 +1781,12 @@ Fail:
   {
     Long   e1, e2;
     Short  c1, c2;
-    Short  f1, f2;
+    Byte   f1, f2;
     Byte*  target;
 
+    (void)y;
+    (void)left;
+    (void)right;
 
     /* Drop-out control */
 
@@ -1821,25 +1805,32 @@ Fail:
       c1 = (Short)(e1 >> 3);
       c2 = (Short)(e2 >> 3);
 
-      f1 = e1 & 7;
-      f2 = e2 & 7;
+      f1 =  ((unsigned char)0xFF >> (e1 & 7));
+      f2 = ~((unsigned char)0x7F >> (e2 & 7));
 
       if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1;
       if ( ras.gray_max_x < c2 ) ras.gray_max_x = c2;
 
       target = ras.bTarget + ras.traceOfs + c1;
+      c2 -= c1;
 
-      if ( c1 != c2 )
+      if ( c2 > 0 )
       {
-        *target |= LMask[f1];
-
-        if ( c2 > c1 + 1 )
-          MEM_Set( target + 1, 0xFF, c2 - c1 - 1 );
+        target[0] |= f1;
 
-        target[c2 - c1] |= RMask[f2];
+        /* memset() is slower than the following code on many platforms. */
+        /* This is due to the fact that, in the vast majority of cases,  */
+        /* the span length in bytes is relatively small.                 */
+        c2--;
+        while ( c2 > 0 )
+        {
+          *(++target) = 0xFF;
+          c2--;
+        }
+        target[1] |= f2;
       }
       else
-        *target |= ( LMask[f1] & RMask[f2] );
+        *target |= ( f1 & f2 );
     }
   }
 
@@ -1947,7 +1938,7 @@ Fail:
       if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1;
       if ( ras.gray_max_x < c1 ) ras.gray_max_x = c1;
 
-      ras.bTarget[ras.traceOfs + c1] |= (Char)(0x80 >> f1);
+      ras.bTarget[ras.traceOfs + c1] |= (char)(0x80 >> f1);
     }
   }
 
@@ -1970,6 +1961,9 @@ Fail:
   static void  Horizontal_Sweep_Init( RAS_ARGS Short*  min, Short*  max )
   {
     /* nothing, really */
+    (void)raster;
+    (void)min;
+    (void)max;
   }
 
 
@@ -1983,7 +1977,9 @@ Fail:
     PByte bits;
     Byte  f1;
 
-
+    (void)left;
+    (void)right;
+    
     if ( x2-x1 < ras.precision )
     {
       e1 = CEILING( x1 );
@@ -1998,10 +1994,13 @@ Fail:
 
         if ( e1 >= 0 && e1 < ras.target.rows )
         {
-          if ( ras.target.flow == FT_Flow_Down )
-            bits[(ras.target.rows-1 - e1) * ras.target.cols] |= f1;
-          else
-            bits[e1 * ras.target.cols] |= f1;
+          PByte  p;
+
+          p = bits - e1*ras.target.pitch;
+          if (ras.target.pitch > 0)
+            p += (ras.target.rows-1)*ras.target.pitch;
+         
+          p[0] |= f1;
         }
       }
     }
@@ -2009,10 +2008,15 @@ Fail:
       e2 = TRUNC( e2 );
 
       if ( e2 >= 0 && e2 < ras.target.rows )
-        if ( ras.target.flow == FT_Flow_Down )
-          bits[(ras.target.rows-1-e2) * ras.target.cols] |= f1;
-        else
-          bits[e2 * ras.target.cols] |= f1;
+      {
+        PByte  p;
+
+        p = bits - e2*ras.target.pitch;
+        if (ras.target.pitch > 0)
+          p += (ras.target.rows-1)*ras.target.pitch;
+        
+        p[0] |= f1;
+      }
 #endif
   }
 
@@ -2072,10 +2076,9 @@ Fail:
           bits = ras.bTarget + (y >> 3);
           f1   = (Byte)(0x80 >> (y &  7));
 
-          if ( ras.target.flow == FT_Flow_Down )
-            bits += (ras.target.rows-1-e1) * ras.target.cols;
-          else
-            bits += e1 * ras.target.cols;
+          bits -= e1*ras.target.pitch;
+          if (ras.target.pitch > 0)
+            bits += (ras.target.rows-1)*ras.target.pitch;
 
           if ( e1 >= 0              &&
                e1 < ras.target.rows &&
@@ -2104,10 +2107,11 @@ Fail:
 
     if ( e1 >= 0 && e1 < ras.target.rows )
     {
-      if (ras.target.flow==FT_Flow_Down)
-        bits[(ras.target.rows-1-e1) * ras.target.cols] |= f1;
-      else
-        bits[e1 * ras.target.cols] |= f1;
+      bits -= e1*ras.target.pitch;
+      if (ras.target.pitch > 0)
+        bits += (ras.target.rows-1)*ras.target.pitch;
+
+      bits[0] |= f1;
     }
   }
 
@@ -2115,6 +2119,7 @@ Fail:
   static void Horizontal_Sweep_Step( RAS_ARG )
   {
     /* Nothing, really */
+    (void)raster;
   }
 
 
@@ -2139,25 +2144,24 @@ Fail:
 
   static void  Vertical_Gray_Sweep_Init( RAS_ARGS Short*  min, Short*  max )
   {
+    Long  pitch, byte_len;
+    
     *min = *min & -2;
     *max = ( *max + 3 ) & -2;
 
-    ras.traceOfs = 0;
-
-    switch ( ras.target.flow )
+    ras.traceOfs  = 0;
+    pitch         = ras.target.pitch;
+    byte_len      = -pitch;
+    ras.traceIncr = byte_len;
+    ras.traceG    = (*min/2)*byte_len;
+    if (pitch > 0)
     {
-    case FT_Flow_Up:
-      ras.traceG  = (*min / 2) * ras.target.cols;
-      ras.traceIncr = ras.target.cols;
-      break;
-
-    default:
-      ras.traceG    = (ras.target.rows-1 - *min/2) * ras.target.cols;
-      ras.traceIncr = -ras.target.cols;
+      ras.traceG += (ras.target.rows-1)*pitch;
+      byte_len    = -byte_len;
     }
 
-    ras.gray_min_x =  ras.target.cols;
-    ras.gray_max_x = -ras.target.cols;
+    ras.gray_min_x =  byte_len;
+    ras.gray_max_x = -byte_len;
   }
 
 
@@ -2195,10 +2199,10 @@ Fail:
 
           if ( c2 )
           {
-            pix[0] = grays[(c2 & 0xF000) >> 12];
-            pix[1] = grays[(c2 & 0x0F00) >>  8];
-            pix[2] = grays[(c2 & 0x00F0) >>  4];
-            pix[3] = grays[(c2 & 0x000F)      ];
+            pix[0] = grays[(c2 >> 12) & 0x000F];
+            pix[1] = grays[(c2 >> 8 ) & 0x000F];
+            pix[2] = grays[(c2 >> 4 ) & 0x000F];
+            pix[3] = grays[ c2        & 0x000F];
 
             *bit  = 0;
             *bit2 = 0;
@@ -2214,8 +2218,8 @@ Fail:
       ras.traceOfs = 0;
       ras.traceG  += ras.traceIncr;
 
-      ras.gray_min_x =  ras.target.cols;
-      ras.gray_max_x = -ras.target.cols;
+      ras.gray_min_x =  32000;
+      ras.gray_max_x = -32000;
     }
   }
 
@@ -2227,6 +2231,12 @@ Fail:
                                                     PProfile    right )
   {
     /* nothing, really */
+    (void)raster;
+    (void)y;
+    (void)x1;
+    (void)x2;
+    (void)left;
+    (void)right;
   }
 
   static void  Horizontal_Gray_Sweep_Drop( RAS_ARGS Short       y,
@@ -2299,12 +2309,9 @@ Fail:
       e1 = TRUNC( e1 ) / 2;
       if ( e1 < ras.target.rows )
       {
-        if ( ras.target.flow == FT_Flow_Down )
-          pixel = ras.gTarget +
-                  (ras.target.rows - 1 - e1) * ras.target.cols + y / 2;
-        else
-          pixel = ras.gTarget +
-                  e1 * ras.target.cols + y / 2;
+        pixel = ras.gTarget - e1*ras.target.pitch + y/2;
+        if (ras.target.pitch > 0)
+          pixel += (ras.target.rows-1)*ras.target.pitch;
 
         if (pixel[0] == ras.grays[0])
           pixel[0] = color;
@@ -2410,8 +2417,8 @@ Fail:
 
           switch ( P->flow )
           {
-            case FT_Flow_Up:    InsNew( &draw_left,  P ); break;
-            case FT_Flow_Down:  InsNew( &draw_right, P ); break;
+            case Flow_Up:    InsNew( &draw_left,  P ); break;
+            case Flow_Down:  InsNew( &draw_right, P ); break;
           }
         }
 
@@ -2642,40 +2649,14 @@ Scan_DropOuts :
 /****************************************************************************/
 
   LOCAL_FUNC
-  FT_Error  Render_Glyph( RAS_ARGS FT_Outline*     glyph,
-                                   FT_Raster_Map*  target_map )
+  FT_Error  Render_Glyph( RAS_ARG )
   {
     FT_Error  error;
 
-
-    if ( glyph->n_points == 0 || glyph->n_contours <= 0 )
-      return FT_Err_Ok;
-
-    if ( !ras.buff )
-    {
-      ras.error = Raster_Err_Not_Ini;
-      return ras.error;
-    }
-
-    if ( glyph->n_points < glyph->contours[glyph->n_contours - 1] )
-    {
-      ras.error = FT_Err_Too_Many_Points;
-      return ras.error;
-    }
-
-    if ( target_map )
-      ras.target = *target_map;
-
-    ras.outs      = glyph->contours;
-    ras.flags     = glyph->flags;
-    ras.nPoints   = glyph->n_points;
-    ras.nContours = glyph->n_contours;
-    ras.coords    = glyph->points;
-
-    Set_High_Precision( RAS_VARS glyph->high_precision );
+    Set_High_Precision( RAS_VARS ras.outline.flags & ft_outline_high_precision );
     ras.scale_shift    = ras.precision_shift;
-    ras.dropOutControl = glyph->dropout_mode;
-    ras.second_pass    = glyph->second_pass;
+    ras.dropOutControl = 2;
+    ras.second_pass    = !(ras.outline.flags & ft_outline_single_pass);
 
 
     /* Vertical Sweep */
@@ -2689,7 +2670,7 @@ Scan_DropOuts :
     ras.band_stack[0].y_max = ras.target.rows - 1;
 
     ras.bWidth  = ras.target.width;
-    ras.bTarget = (Byte*)ras.target.bitmap;
+    ras.bTarget = (Byte*)ras.target.buffer;
 
     if ( (error = Render_Single_Pass( RAS_VARS 0 )) != 0 )
       return error;
@@ -2715,8 +2696,6 @@ Scan_DropOuts :
   }
 
 
-#ifdef FT_CONFIG_OPTION_GRAY_SCALING
-
 /****************************************************************************/
 /*                                                                          */
 /* Function:    Render_Gray_Glyph                                           */
@@ -2731,28 +2710,12 @@ Scan_DropOuts :
 /****************************************************************************/
 
   LOCAL_FUNC
-  FT_Error  Render_Gray_Glyph( RAS_ARGS  FT_Outline*     glyph,
-                                         FT_Raster_Map*  target_map,
-                                         Byte*           palette )
+  FT_Error  Render_Gray_Glyph( RAS_ARG )
   {
-    Int       i;
+    Long      byte_len;
     FT_Error  error;
 
-    if ( !ras.buff )
-    {
-      ras.error = Raster_Err_Not_Ini;
-      return ras.error;
-    }
-
-    if ( glyph->n_points == 0 || glyph->n_contours <= 0 )
-      return FT_Err_Ok;
-
-    if ( glyph->n_points < glyph->contours[glyph->n_contours - 1] )
-    {
-      ras.error = FT_Err_Too_Many_Points;
-      return ras.error;
-    }
-
+#if 0
     if ( palette )
     {
       for ( i = 0; i < 5; i++ )
@@ -2761,17 +2724,12 @@ Scan_DropOuts :
 
     if ( target_map )
       ras.target = *target_map;
+#endif
 
-    ras.outs      = glyph->contours;
-    ras.flags     = glyph->flags;
-    ras.nPoints   = glyph->n_points;
-    ras.nContours = glyph->n_contours;
-    ras.coords    = glyph->points;
-
-    Set_High_Precision( RAS_VARS glyph->high_precision );
+    Set_High_Precision( RAS_VARS ras.outline.flags & ft_outline_high_precision );
     ras.scale_shift    = ras.precision_shift+1;
-    ras.dropOutControl = glyph->dropout_mode;
-    ras.second_pass    = glyph->second_pass;
+    ras.dropOutControl = 2;
+    ras.second_pass    = !(ras.outline.flags & ft_outline_single_pass);
 
 
     /* Vertical Sweep */
@@ -2781,12 +2739,17 @@ Scan_DropOuts :
     ras.band_stack[0].y_max = 2 * ras.target.rows - 1;
 
     ras.bWidth  = ras.gray_width;
-    if ( ras.bWidth > ras.target.cols/4 )
-      ras.bWidth = ras.target.cols/4;
+    
+    byte_len = ras.target.pitch;
+    if (byte_len < 0)
+      byte_len = -byte_len;
+      
+    if ( ras.bWidth > byte_len/4 )
+      ras.bWidth = byte_len/4;
 
     ras.bWidth  = ras.bWidth * 8;
     ras.bTarget = (Byte*)ras.gray_lines;
-    ras.gTarget = (Byte*)ras.target.bitmap;
+    ras.gTarget = (Byte*)ras.target.buffer;
 
     ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init;
     ras.Proc_Sweep_Span = Vertical_Sweep_Span;
@@ -2818,9 +2781,9 @@ Scan_DropOuts :
     return FT_Err_Ok;
   }
 
-#endif /* FT_CONFIG_OPTION_GRAY_SCALING */
 
 
+#if 0
 /************************************************/
 /*                                              */
 /* InitRasterizer                               */
@@ -2900,6 +2863,131 @@ Scan_DropOuts :
 
     return FT_Err_Ok;
   }
+#endif
+
+  /**** RASTER OBJECT CREATION : in standalone mode, we simply use *****/
+  /****                          a static object ..                *****/
+#ifdef _STANDALONE_
+
+  static
+  int  ft_black_new( void*  memory, FT_Raster *araster )
+  {
+     static FT_RasterRec_  the_raster;
+     *araster = &the_raster;  
+     memset( &the_raster, sizeof(the_raster), 0 );
+     return 0;
+  }
+
+  static
+  void  ft_black_done( FT_Raster  raster )
+  {
+    /* nothing */
+    raster->init = 0;
+  }
+
+#else
+
+#include <ftobjs.h>
+
+  static
+  int  ft_black_new( FT_Memory  memory, TRaster_Instance*  *araster )
+  {
+    FT_Error           error;
+    TRaster_Instance*  raster;
+    
+    *araster = 0;
+    if ( !ALLOC( raster, sizeof(*raster) ))
+    {
+      raster->memory = memory;
+      *araster = raster;
+    }
+      
+    return error;
+  }
+  
+  static
+  void ft_black_done( TRaster_Instance*  raster )
+  {
+    FT_Memory  memory = (FT_Memory)raster->memory;
+    FREE( raster );
+  }
+  
+#endif
+
+
+  static void ft_black_reset( TRaster_Instance* raster,
+                              const char*       pool_base,
+                              long              pool_size )
+  {
+    if ( raster && pool_base && pool_size >= 4096 )
+    {
+      /* save the pool */
+      raster->buff     = (PLong)pool_base;
+      raster->sizeBuff = raster->buff + pool_size / sizeof (Long);
+    }
+  }
+
+
+  static
+  int  ft_black_render( TRaster_Instance*  raster,
+                        FT_Raster_Params*  params )
+  {
+    FT_Outline*  outline    = (FT_Outline*)params->source;
+    FT_Bitmap*   target_map = params->target;
+    
+    if ( !raster || !raster->buff || !raster->sizeBuff )
+      return Raster_Err_Not_Ini;
+
+    if ( !outline || !outline->contours || !outline->points )
+      return Raster_Err_Invalid;
+
+    /* return immediately if the outline is empty */
+    if ( outline->n_points == 0 || outline->n_contours <= 0 )
+      return Raster_Err_None;
+
+    if ( outline->n_points != outline->contours[outline->n_contours - 1] + 1 )
+      return Raster_Err_Invalid;
+
+    if ( !target_map || !target_map->buffer )
+      return Raster_Err_Invalid;
+
+    /* this version of the raster does not support direct rendering, sorry */
+    if ( params->flags & ft_raster_flag_direct )
+      return Raster_Err_Unsupported;
+
+    ras.outline  = *outline;
+    ras.target   = *target_map;
+    
+    return ( params->flags & ft_raster_flag_aa 
+           ? Render_Glyph( raster )
+           : Render_Gray_Glyph( raster ) );
+
+#if 0
+    /* Note that we always use drop-out mode 2, because it seems that */
+    /* it's the only way to do to get results consistent with Windows */
+    /* rendering..                                                    */
+    ras.dropout_mode = 2;
+
+    ras.second_pass  = (outline->flags & ft_outline_single_pass) == 0;
+    SET_High_Precision( (char)((outline->flags & ft_outline_high_precision)!= 0) );
+
+    return ( params->flags & ft_raster_flag_aa
+           ? Raster_Render8( raster )
+           : Raster_Render1( raster ) );
+#endif           
+  }
+
+
+  FT_Raster_Funcs      ft_black_raster =
+  {
+    ft_glyph_format_outline,
+    (FT_Raster_New_Func)       ft_black_new,
+    (FT_Raster_Reset_Func)     ft_black_reset,
+    (FT_Raster_Set_Mode_Func)  0,
+    (FT_Raster_Render_Func)    ft_black_render,
+    (FT_Raster_Done_Func)      ft_black_done
+  };
+
 
 
 /* END */
diff --git a/demos/src/ftview.c b/demos/src/ftview.c
index cc599a7..c66920a 100644
--- a/demos/src/ftview.c
+++ b/demos/src/ftview.c
@@ -267,7 +267,11 @@ $\243^\250*\265\371%!\247:/;.,?<>";
 
     i = first_glyph;
 
+#if 0
+     while ( i < first_glyph+1 )
+#else
      while ( i < num_glyphs )
+#endif
     {
       if ( !(error = LoadChar( i, hinted )) )
       {
diff --git a/src/base/ftgrays.c b/src/base/ftgrays.c
index bfc23f7..927b7a4 100644
--- a/src/base/ftgrays.c
+++ b/src/base/ftgrays.c
@@ -1151,6 +1151,8 @@ int  check_sort( PCell  cells, int count )
     TScan  x, y, cover, area;
     PCell  start, cur, limit;
 
+    (void)target;
+
     cur   = ras.cells;
     limit = cur + ras.num_cells;
 
diff --git a/src/base/ftraster.c b/src/base/ftraster.c
index 601a5f4..bac067b 100644
--- a/src/base/ftraster.c
+++ b/src/base/ftraster.c
@@ -52,10 +52,19 @@
   /*                                                                       */
   /*************************************************************************/
 
+#define OLD
+
+
+#define xxxDEBUG_RAS
+#ifdef DEBUG_RAS
+#include <stdio.h>
+#endif
+
 
 #include <ftraster.h>
 #ifndef _STANDALONE_
 #include <ftconfig.h>
+#include <ftdebug.h>
 #endif
 
 #ifndef EXPORT_FUNC
@@ -117,41 +126,6 @@
 
   /*************************************************************************/
   /*                                                                       */
-  /* FT_RASTER_ANTI_ALIAS_5                                                */
-  /*                                                                       */
-  /*   Define this configuration macro if you want to enable the 5-grays   */
-  /*   anti-aliasing mode.  Ignored if FT_RASTER_OPTION_ANTI_ALIAS isn't   */
-  /*   defined.                                                            */
-  /*                                                                       */
-#define FT_RASTER_ANTI_ALIAS_5
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* FT_RASTER_ANTI_ALIAS_17                                               */
-  /*                                                                       */
-  /*   Define this configuration macro if you want to enable the 17-grays  */
-  /*   anti-aliasing mode.  Ignored if FT_RASTER_OPTION_ANTI_ALIAS isn't   */
-  /*   defined.                                                            */
-  /*                                                                       */
-/* #define FT_RASTER_ANTI_ALIAS_17 */
-
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* FT_RASTER_LITTLE_ENDIAN                                               */
-  /* FT_RASTER_BIG_ENDIAN                                                  */
-  /*                                                                       */
-  /*   The default anti-alias routines are processor-independent, but      */
-  /*   slow.  Define one of these macros to suit your own system, and      */
-  /*   enjoy greatly improved rendering speed.                             */
-  /*                                                                       */
-
-/* #define FT_RASTER_LITTLE_ENDIAN */
-/* #define FT_RASTER_BIG_ENDIAN    */
-
-  /*************************************************************************/
-  /*                                                                       */
   /* FT_RASTER_CONSTANT_PRECISION                                          */
   /*                                                                       */
   /*   Define this configuration macro if you want to use a constant       */
@@ -162,7 +136,7 @@
   /*   This results in a speed boost, but the macro can be undefined if    */
   /*   it results in rendering errors (mainly changed drop-outs)..         */
   /*                                                                       */
-#define FT_RASTER_CONSTANT_PRECISION
+#undef  FT_RASTER_CONSTANT_PRECISION
 
 
   /*************************************************************************/
@@ -188,7 +162,7 @@
   /*   constant, as it speeds things a bit while keeping a very good       */
   /*   accuracy on the bezier intersections..                              */
   /*                                                                       */
-#define FT_DYNAMIC_BEZIER_STEPS
+#undef  FT_DYNAMIC_BEZIER_STEPS
 
 
 #else /* _STANDALONE_ */
@@ -223,16 +197,20 @@
 #define FT_RASTER_BIG_ENDIAN
 #endif
 
-#define FT_RASTER_CONSTANT_PRECISION
-#define FT_DYNAMIC_BEZIER_STEPS
+#undef  FT_RASTER_CONSTANT_PRECISION
+#undef  FT_DYNAMIC_BEZIER_STEPS
 #define FT_PRECISION_BITS    8
 
 #endif /* _STANDALONE_ */
 
 
 /* to keep the compiler happy */
-#ifndef PTRACE2
-#define PTRACE2(x)  /*void*/
+#ifndef FT_TRACE2
+#define FT_TRACE2(x)  /*void*/
+#endif
+
+#ifndef FT_TRACE4
+#define FT_TRACE4(x)  /* void */
 #endif
 
   /*************************************************************************/
@@ -302,6 +280,7 @@
   /* `->'                                                              */
 #define ras       (*raster)
 
+#define           UNUSED_RASTER   (void)raster;
 
   /*************************************************************************/
   /*                                                                       */
@@ -706,7 +685,6 @@
     long  o;
     long  x;
 
-
     x = ras.cursor[-1];
 
     switch ( ras.cur_prof->flow )
@@ -1001,7 +979,7 @@
     int    n;
 
 
-    PTRACE2(( "EXTREMA += %d", y ));
+    FT_TRACE2(( "EXTREMA += %d", y ));
     n       = ras.n_extrema - 1;
     extrema = ras.pool_size - ras.n_extrema;
 
@@ -1069,7 +1047,7 @@
         switch ( p->flow )
         {
           case Flow_Down:
-            PTRACE2(( "FLOW DOWN (start = %d, height = %d)",
+            FT_TRACE2(( "FLOW DOWN (start = %d, height = %d)",
                       p->start, p->height ));
             bottom     = p->start - p->height+1;
             top        = p->start;
@@ -1079,7 +1057,7 @@
 
           case Flow_Up:
           default:
-            PTRACE2(( "FLOW UP (start = %d, height = %d)",
+            FT_TRACE2(( "FLOW UP (start = %d, height = %d)",
                       p->start, p->height ));
             bottom = p->start;
             top    = p->start + p->height-1;
@@ -1099,6 +1077,19 @@
     return SUCCESS;
   }
 
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /****         COMPUTE SCAN-LINE INTERSECTIONS FROM SEGMENTS           ****/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -1154,6 +1145,11 @@
     /* clip to lower scanline when necessary */
     if ( y1 < miny )
     {
+#ifdef OLD
+      x1 += FT_MulDiv( Dx, miny-y1, Dy );
+      e1  = TRUNC( miny );
+      f1  = 0;
+#else    
       TPos  x, y;
 
       /* we use a binary search to compute the lower
@@ -1182,6 +1178,7 @@
 
       e1  = TRUNC( miny );
       f1  = 0;
+#endif      
     }
     else
     {
@@ -1223,6 +1220,22 @@
       return FAILURE;
     }
 
+#ifdef OLD
+    if ( Dx > 0 )
+    {
+      Ix = ( PRECISION*Dx ) / Dy;
+      Rx = ( PRECISION*Dx ) % Dy;
+      Dx = 1;
+    }
+    else
+    {
+      Ix = -( (PRECISION*-Dx) / Dy );
+      Rx =    (PRECISION*-Dx) % Dy;
+      Dx = -1;
+    }
+    
+    Ax = -Dy;
+#else
     /* compute decision variables and push the intersections on top */
     /* of the render pool                                           */
     Dx <<= PRECISION_BITS;
@@ -1237,6 +1250,7 @@
     Ax   = -Dy;
     Rx <<= 1;
     Dy <<= 1;
+#endif
 
     top = ras.cursor;
 
@@ -1251,7 +1265,11 @@
       if ( Ax >= 0 )
       {
         Ax -= Dy;
+#ifdef OLD
+        x1 += Dx;
+#else        
         x1 ++;
+#endif        
       }
       size--;
     }
@@ -1416,10 +1434,18 @@
 
     e2 = FLOOR( y2 );  /* integer end y */
 
+#ifdef OLD
+    if ( e2 > maxy )
+      e2 = maxy;
+      
+    e0 = miny;
+#else    
     if ( e2 > maxy )
       e2 = FLOOR(maxy);
 
     e0 = CEILING(miny);
+#endif
+
 
     if ( y1 < miny )
     {
@@ -1466,6 +1492,7 @@
       return FAILURE;
     }
 
+    
 #ifdef FT_DYNAMIC_BEZIER_STEPS
     /* compute dynamic bezier step threshold */
     threshold = Dynamic_Bezier_Threshold( RAS_VAR_ degree, arc );
@@ -1487,7 +1514,11 @@
       {
         y1 = arc[degree].y;  /* start y of top-most arc */
 
+#ifdef OLD
+        if ( y2-y1 >= PRECISION_STEP )
+#else        
         if ( y2 >= e + PRECISION || y2 - y1 >= threshold )
+#endif        
         {
           /* if the arc's height is too great, split it */
           splitter( arc );
@@ -1573,6 +1604,19 @@
   }
 
 
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /****         SPLITTING CONIC AND CUBIC BEZIERS IN HALF               ****/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+
+
 #ifdef FT_RASTER_CONIC_BEZIERS
 
   /*************************************************************************/
@@ -1608,60 +1652,7 @@
     base[2].y = ( a + b ) / 2;
   }
 
-
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    Push_Conic                                                         */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Clears the Bezier stack and pushes a new arc on top of it.         */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    p2 :: A pointer to the second (control) point.                     */
-  /*    p3 :: A pointer to the third (end) point.                          */
-  /*                                                                       */
-  /* <Note>                                                                */
-  /*    The first point is taken as `raster->last', so it doesn't appear   */
-  /*    in the signature.                                                  */
-  /*                                                                       */
-  static
-  void  Push_Conic( RAS_ARG_ FT_Vector*  p2,
-                             FT_Vector*  p3 )
-  {
-#undef  STORE
-#define STORE( _arc, point )                    \
-          {                                     \
-            TPos  x = SCALED( point->x );       \
-            TPos  y = SCALED( point->y );       \
-                                                \
-                                                \
-            if ( ras.flipped )                  \
-            {                                   \
-              _arc.x = y;                       \
-              _arc.y = x;                       \
-            }                                   \
-            else                                \
-            {                                   \
-              _arc.x = x;                       \
-              _arc.y = y;                       \
-            }                                   \
-          }
-
-    TPoint*  arc;
-
-
-    ras.arc = arc = ras.arcs;
-
-    arc[2] = ras.last;
-    STORE( arc[1], p2 );
-    STORE( arc[0], p3 );
-#undef  STORE
-  }
-
-#endif /* FT_RASTER_CONIC_BEZIERS */
-
-
+#endif
 
 #ifdef FT_RASTER_CUBIC_BEZIERS
 
@@ -1705,63 +1696,21 @@
     base[3].y = ( a + b + 1 ) >> 1;
   }
 
+#endif /* FT_RASTER_CUBIC_BEZIERS */
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    Push_Cubic                                                         */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    Clears the Bezier stack and pushes a new third-order Bezier arc on */
-  /*    top of it.                                                         */
-  /*                                                                       */
-  /* <Input>                                                               */
-  /*    p2 :: A pointer to the second (control) point.                     */
-  /*    p3 :: A pointer to the third (control) point.                      */
-  /*    p4 :: A pointer to the fourth (end) point.                         */
-  /*                                                                       */
-  /* <Note>                                                                */
-  /*    The first point is taken as `raster->last', so it doesn't appear   */
-  /*    in the signature.                                                  */
-  /*                                                                       */
-  /*    This is the same as Push_Conic(), except that it deals with        */
-  /*    third-order Beziers.                                               */
-  /*                                                                       */
-  static
-  void  Push_Cubic( RAS_ARG_ FT_Vector*  p2,
-                             FT_Vector*  p3,
-                             FT_Vector*  p4 )
-  {
-#undef  STORE
-#define STORE( _arc, point )                    \
-          {                                     \
-            TPos  x = SCALED( point->x );       \
-            TPos  y = SCALED( point->y );       \
-                                                \
-            if ( ras.flipped )                  \
-            {                                   \
-              _arc.x = y;                       \
-              _arc.y = x;                       \
-            }                                   \
-            else                                \
-            {                                   \
-              _arc.x = x;                       \
-              _arc.y = y;                       \
-            }                                   \
-          }
-
-    TPoint*  arc;
-    ras.arc = arc = ras.arcs;
-
-    arc[3] = ras.last;
-    STORE( arc[2], p2 );
-    STORE( arc[1], p3 );
-    STORE( arc[0], p4 );
 
-#undef STORE
-  }
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /****                   PROCESSING OUTLINE SEGMENTS                   ****/
+  /****                                                                 ****/
+  /****                                                                 ****/
+  /*************************************************************************/
+  /*************************************************************************/
+  /*************************************************************************/
 
-#endif /* FT_RASTER_CUBIC_BEZIERS */
 
 
   /*************************************************************************/
@@ -1945,6 +1894,56 @@
 
 #ifdef FT_RASTER_CONIC_BEZIERS
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    Push_Conic                                                         */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Clears the Bezier stack and pushes a new arc on top of it.         */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    p2 :: A pointer to the second (control) point.                     */
+  /*    p3 :: A pointer to the third (end) point.                          */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    The first point is taken as `raster->last', so it doesn't appear   */
+  /*    in the signature.                                                  */
+  /*                                                                       */
+  static
+  void  Push_Conic( RAS_ARG_ FT_Vector*  p2,
+                             FT_Vector*  p3 )
+  {
+#undef  STORE
+#define STORE( _arc, point )                    \
+          {                                     \
+            TPos  x = SCALED( point->x );       \
+            TPos  y = SCALED( point->y );       \
+                                                \
+                                                \
+            if ( ras.flipped )                  \
+            {                                   \
+              _arc.x = y;                       \
+              _arc.y = x;                       \
+            }                                   \
+            else                                \
+            {                                   \
+              _arc.x = x;                       \
+              _arc.y = y;                       \
+            }                                   \
+          }
+
+    TPoint*  arc;
+
+
+    ras.arc = arc = ras.arcs;
+
+    arc[2] = ras.last;
+    STORE( arc[1], p2 );
+    STORE( arc[0], p3 );
+#undef  STORE
+  }
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -2063,12 +2062,66 @@
     return ErrRaster_Invalid_Outline;
   }
 
-
 #endif /* FT_RASTER_CONIC_BEZIERS */
 
 
 #ifdef FT_RASTER_CUBIC_BEZIERS
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    Push_Cubic                                                         */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Clears the Bezier stack and pushes a new third-order Bezier arc on */
+  /*    top of it.                                                         */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    p2 :: A pointer to the second (control) point.                     */
+  /*    p3 :: A pointer to the third (control) point.                      */
+  /*    p4 :: A pointer to the fourth (end) point.                         */
+  /*                                                                       */
+  /* <Note>                                                                */
+  /*    The first point is taken as `raster->last', so it doesn't appear   */
+  /*    in the signature.                                                  */
+  /*                                                                       */
+  /*    This is the same as Push_Conic(), except that it deals with        */
+  /*    third-order Beziers.                                               */
+  /*                                                                       */
+  static
+  void  Push_Cubic( RAS_ARG_ FT_Vector*  p2,
+                             FT_Vector*  p3,
+                             FT_Vector*  p4 )
+  {
+#undef  STORE
+#define STORE( _arc, point )                    \
+          {                                     \
+            TPos  x = SCALED( point->x );       \
+            TPos  y = SCALED( point->y );       \
+                                                \
+            if ( ras.flipped )                  \
+            {                                   \
+              _arc.x = y;                       \
+              _arc.y = x;                       \
+            }                                   \
+            else                                \
+            {                                   \
+              _arc.x = x;                       \
+              _arc.y = y;                       \
+            }                                   \
+          }
+
+    TPoint*  arc;
+    ras.arc = arc = ras.arcs;
+
+    arc[3] = ras.last;
+    STORE( arc[2], p2 );
+    STORE( arc[1], p3 );
+    STORE( arc[0], p4 );
+
+#undef STORE
+  }
+
 
   /*************************************************************************/
   /*                                                                       */
@@ -2480,12 +2533,17 @@
 
     /* Drop-out control */
     e1 = TRUNC( CEILING( x1 ) );
+    
     if ( x2 - x1 - PRECISION <= PRECISION_JITTER )
       e2 = e1;
     else
       e2 = TRUNC( FLOOR( x2 ) );
 
+#ifdef OLD
+    if ( e2 >= 0 && e1 < ras.bit_width )
+#else
     if ( e1 <= e2 && e2 >= 0 && e1 < ras.bit_width )
+#endif    
     {
       if ( e1 < 0 )              e1 = 0;
       if ( e2 >= ras.bit_width ) e2 = ras.bit_width - 1;
@@ -2916,6 +2974,7 @@
   int  Vertical_Gray_Test_Pixel( RAS_ARG_ TScan  y,
                                           int    x )
   {
+    UNUSED_RASTER
     UNUSED( y );
 
 #if 0
@@ -3163,6 +3222,7 @@
     return ( x >= 0 && x < ras.target.rows &&
             *pixel >= 64 );
 #else
+    UNUSED_RASTER
     UNUSED(y);
     UNUSED(x);
     return 0;
@@ -3321,6 +3381,9 @@
     TProfileList  wait;
     TProfileList  draw;
 
+    #ifdef DEBUG_RAS
+    int   y_set = 0;
+    #endif
 
     /* Init empty linked lists */
     Init_Linked( &wait );
@@ -3355,9 +3418,9 @@
     }
 
     /* Now inits the sweep */
-    PTRACE2(( "draw_sweep: initialize sweep\n" ));
+    FT_TRACE2(( "draw_sweep: initialize sweep\n" ));
     ras.render.init( RAS_VAR_  &min_Y, &max_Y );
-    PTRACE2(( "  init min_y = %d, max_y = %d\n", min_Y, max_Y ));
+    FT_TRACE2(( "  init min_y = %d, max_y = %d\n", min_Y, max_Y ));
 
     /* Then compute the distance of each profile from min_Y */
     P = wait;
@@ -3375,7 +3438,7 @@
          ras.pool_size[-ras.n_extrema] == min_Y )
       ras.n_extrema--;
 
-    PTRACE2(( "starting loop with n_extrema = %d", ras.n_extrema ));
+    FT_TRACE2(( "starting loop with n_extrema = %d", ras.n_extrema ));
     while ( ras.n_extrema > 0 )
     {
       PProfile  prof = wait;
@@ -3404,7 +3467,7 @@
       y_change = ras.pool_size[-ras.n_extrema--];
       y_height = y_change - y;
 
-      PTRACE2(( ">>> y = %d, y_change = %d, y_height = %d",
+      FT_TRACE2(( ">>> y = %d, y_change = %d, y_height = %d",
                 y, y_change, y_height ));
 
       while ( y < y_change )
@@ -3423,7 +3486,7 @@
         window = left->flow;
         prof   = left->link;
 
-        PTRACE2(( ">>>  line y = %d", y ));
+        FT_TRACE2(( ">>>  line y = %d", y ));
 
         while ( prof )
         {
@@ -3463,7 +3526,15 @@
               }
             }
 
-            PTRACE2(( "drawing span ( y=%d, x1=%d, x2=%d )", y, x1, x2 ));
+            FT_TRACE2(( "drawing span ( y=%d, x1=%d, x2=%d )", y, x1, x2 ));
+            #ifdef DEBUG_RAS
+            if (!y_set)
+            {
+              y_set = 1;
+              fprintf( stderr, "%3d", y );
+            }
+            fprintf( stderr, " [%.2f-%.2f]", x1*1.0/PRECISION, x2*1.0/PRECISION );
+            #endif
             ras.render.span( RAS_VAR_  y, x1, x2 );
 
    Skip_To_Next:
@@ -3482,16 +3553,23 @@
         ras.render.step( RAS_VAR );
 
         y++;
+        #ifdef DEBUG_RAS
+        if (y_set)
+        {
+          fprintf( stderr, "\n" );
+          y_set = 0;
+        }
+        #endif
 
         if ( y < y_change )
           Sort( &draw );
 
-        PTRACE2(( "line sorted for next operation" ));
+        FT_TRACE4(( "line sorted for next operation" ));
       }
 
       /* Now finalize the profiles that needs it */
 
-      PTRACE2(( "finalizing profiles..." ));
+      FT_TRACE2(( "finalizing profiles..." ));
       {
         PProfile  prof, next;
 
@@ -3505,7 +3583,7 @@
         }
       }
 
-      PTRACE2(( "profiles finalized for this run" ));
+      FT_TRACE2(( "profiles finalized for this run" ));
     }
 
     /* for gray-scaling, flushes the bitmap scanline cache */
@@ -3543,9 +3621,18 @@ Scan_DropOuts :
       left  = ( ras.flipped ? P_Right : P_Left  );
       right = ( ras.flipped ? P_Left  : P_Right );
 
-      PTRACE2(( "performing drop-out control ( x1= %d, x2 = %d )",
+      FT_TRACE2(( "performing drop-out control ( x1= %d, x2 = %d )",
                 x1, x2 ));
 
+      #ifdef DEBUG_RAS
+      if (!y_set)
+      {
+        y_set = 1;
+        fprintf( stderr, "%3d", y );
+      }
+      fprintf( stderr, " <%.2f-%.2f>", P_Left->X*1.0/PRECISION, P_Right->X*1.0/PRECISION );
+      #endif
+      
       e1 = CEILING( x1 );
       e2 = FLOOR  ( x2 );
 
@@ -3611,7 +3698,7 @@ Scan_DropOuts :
           goto Next_Dropout;
       }
 
-      PTRACE2(( "  -> setting pixel" ));
+      FT_TRACE2(( "  -> setting pixel" ));
       ras.render.set_pixel( RAS_VAR_ y,
                             TRUNC( e1 ),
                             (x2 - x1) >> ras.scale_shift );
@@ -3647,7 +3734,7 @@ Scan_DropOuts :
 
     band = ras.band_stack;
 
-    PTRACE2(( "raster: entering render_single_pass (flipped = %d)\n",
+    FT_TRACE2(( "raster: entering render_single_pass (flipped = %d)\n",
               flipped ));
 
     while ( band >= ras.band_stack )
@@ -3658,7 +3745,7 @@ Scan_DropOuts :
       ras.cursor = ras.pool;
       ras.error  = 0;
 
-      PTRACE2(( "raster: band = [ %d, %d ]\n",
+      FT_TRACE2(( "raster: band = [ %d, %d ]\n",
                 band[0].y_min,
                 band[0].y_max ));
 
@@ -3671,7 +3758,7 @@ Scan_DropOuts :
           return FAILURE;
         ras.error = ErrRaster_Ok;
 
-        PTRACE2(( "conversion failure, performing sub-banding\n" ));
+        FT_TRACE2(( "conversion failure, performing sub-banding\n" ));
 
         /* sub-banding */
 
@@ -3698,7 +3785,7 @@ Scan_DropOuts :
       }
       else
       {
-        PTRACE2(( "conversion succeeded, span drawing sweep\n" ));
+        FT_TRACE2(( "conversion succeeded, span drawing sweep\n" ));
 #if 1  /* for debugging */
         if ( ras.start_prof )
           if ( Draw_Sweep( RAS_VAR ) )
@@ -3708,7 +3795,7 @@ Scan_DropOuts :
       }
     }
 
-    PTRACE2(( "raster: exiting render_single_pass\n" ));
+    FT_TRACE2(( "raster: exiting render_single_pass\n" ));
 
     return SUCCESS;  /* success */
   }
diff --git a/src/base/ftstream.h b/src/base/ftstream.h
index 0148af3..dc6017e 100644
--- a/src/base/ftstream.h
+++ b/src/base/ftstream.h
@@ -68,6 +68,9 @@ typedef struct FT_Frame_Field_
 
 #define FT_MAKE_EMPTY_FIELD( frame_op )  { frame_op, 0, 0 }
 
+#define FT_FRAME_START(s)    { ft_frame_start, 0, s }
+#define FT_FRAME_END         { ft_frame_end, 0, 0 }
+
 #define FT_FRAME_LONG(s,f)   FT_FRAME_FIELD( ft_frame_long_be, s, f )
 #define FT_FRAME_ULONG(s,f)  FT_FRAME_FIELD( ft_frame_ulong_be, s, f )
 #define FT_FRAME_SHORT(s,f)  FT_FRAME_FIELD( ft_frame_short_be, s, f )
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 07d7993..211ee4a 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -151,10 +151,10 @@
     
 #ifdef READ_FIELDS
     const FT_Frame_Field  ttc_header_fields[] = {
-           { ft_frame_start, 0, 8 },   /* frame of 8 bytes */
+           FT_FRAME_START(8),  /* frame of 8 bytes */
              FT_FRAME_LONG( TTC_Header, version  ),
              FT_FRAME_LONG( TTC_Header, DirCount ),
-           { ft_frame_end, 0, 0 } };
+           FT_FRAME_END };
 #endif
 
     FT_TRACE2(( "TT_Load_Format_Tag(%08lx, %ld )\n",
@@ -256,12 +256,12 @@
     FT_Memory  memory = stream->memory;
 #ifdef READ_FIELDS
     const FT_Frame_Field table_dir_fields[] = {
-           { ft_frame_start, 0, 8 },
+           FT_FRAME_START(8),
              FT_FRAME_USHORT( TT_TableDir, numTables ),
              FT_FRAME_USHORT( TT_TableDir, searchRange ),
              FT_FRAME_USHORT( TT_TableDir, entrySelector ),
              FT_FRAME_USHORT( TT_TableDir, rangeShift ),
-           { ft_frame_end, 0 , 0 } };
+           FT_FRAME_END };
 #endif
 
     TT_TableDir  tableDir;
@@ -438,8 +438,8 @@
     TT_Error    error;
     TT_Header*  header;
 #ifdef READ_FIELDS
-    const FT_Frame_Field  header_fields[] = {
-            { ft_frame_start, 0, 54 },
+    static const FT_Frame_Field  header_fields[] = {
+            FT_FRAME_START(54),
               FT_FRAME_ULONG(  TT_Header, Table_Version ),
               FT_FRAME_ULONG(  TT_Header, Font_Revision ),
               FT_FRAME_LONG(   TT_Header, CheckSum_Adjust ),
@@ -459,7 +459,7 @@
               FT_FRAME_SHORT(  TT_Header, Font_Direction ),
               FT_FRAME_SHORT(  TT_Header, Index_To_Loc_Format ),
               FT_FRAME_SHORT(  TT_Header, Glyph_Data_Format ),
-            { ft_frame_end } };
+            FT_FRAME_END };
 #endif
 
     FT_TRACE2(( "Load_TT_Header( %08lx )\n", (TT_Long)face ));
@@ -539,7 +539,7 @@
     TT_MaxProfile*  maxProfile = &face->max_profile;
 #ifdef READ_FIELDS
     const FT_Frame_Field  maxp_fields[] = {
-              { ft_frame_start, 0, 32 },
+              FT_FRAME_START(32),
                 FT_FRAME_ULONG(  TT_MaxProfile, version ),
                 FT_FRAME_USHORT( TT_MaxProfile, numGlyphs ),
                 FT_FRAME_USHORT( TT_MaxProfile, maxPoints ),
@@ -555,7 +555,7 @@
                 FT_FRAME_USHORT( TT_MaxProfile, maxSizeOfInstructions ),
                 FT_FRAME_USHORT( TT_MaxProfile, maxComponentElements ),
                 FT_FRAME_USHORT( TT_MaxProfile, maxComponentDepth ),
-              { ft_frame_end } };
+              FT_FRAME_END };
 #endif
 
     FT_TRACE2(( "Load_TT_MaxProfile( %08lx )\n", (TT_Long)face ));
@@ -785,7 +785,7 @@
     TT_HoriHeader*  header;
 #ifdef READ_FIELDS
     const FT_Frame_Field  metrics_header_fields[] = {
-              { ft_frame_start, 0, 36 },
+              FT_FRAME_START(36),
                 FT_FRAME_ULONG(  TT_HoriHeader, Version ),
                 FT_FRAME_SHORT(  TT_HoriHeader, Ascender ),
                 FT_FRAME_SHORT(  TT_HoriHeader, Descender ),
@@ -803,7 +803,7 @@
                 FT_FRAME_SHORT(  TT_HoriHeader, Reserved[4] ),
                 FT_FRAME_SHORT(  TT_HoriHeader, metric_Data_Format ),
                 FT_FRAME_USHORT( TT_HoriHeader, number_Of_HMetrics ),
-              { ft_frame_end } };
+              FT_FRAME_END };
 #endif
     FT_TRACE2(( vertical ? "Vertical header " : "Horizontal header " ));
 
@@ -909,11 +909,11 @@
     TT_NameTable*  names;
 #ifdef READ_FIELDS
     const FT_Frame_Field  name_table_fields[] = {
-              { ft_frame_start, 0, 6 },
+              FT_FRAME_START(6),
                 FT_FRAME_USHORT( TT_NameTable, format ),
                 FT_FRAME_USHORT( TT_NameTable, numNameRecords ),
                 FT_FRAME_USHORT( TT_NameTable, storageOffset ),
-              { ft_frame_end } };
+              FT_FRAME_END };
 
     const FT_Frame_Field  name_record_fields[] = {
                 FT_FRAME_USHORT( TT_NameRec, platformID ),
@@ -922,7 +922,7 @@
                 FT_FRAME_USHORT( TT_NameRec, nameID ),
                 FT_FRAME_USHORT( TT_NameRec, stringLength ),
                 FT_FRAME_USHORT( TT_NameRec, stringOffset ),
-              { ft_frame_end } };
+              FT_FRAME_END };
 #endif
 
 
@@ -1103,17 +1103,17 @@
 
 #ifdef READ_FIELDS
     const FT_Frame_Field  cmap_fields[] = {
-              { ft_frame_start, 0, 4 },
+              FT_FRAME_START(4),
                 FT_FRAME_USHORT( TT_CMapDir, tableVersionNumber ),
                 FT_FRAME_USHORT( TT_CMapDir, numCMaps ),
-              { ft_frame_end } };
+              FT_FRAME_END };
 
     const FT_Frame_Field  cmap_rec_fields[] = {
-              { ft_frame_start, 0, 6 },
+              FT_FRAME_START(6),
                 FT_FRAME_USHORT( TT_CMapTable, format ),
                 FT_FRAME_USHORT( TT_CMapTable, length ),
                 FT_FRAME_USHORT( TT_CMapTable, version ),
-              { ft_frame_end } };
+              FT_FRAME_END };
 #endif
 
     FT_TRACE2(( "CMaps " ));
@@ -1219,7 +1219,7 @@
     TT_OS2*   os2;
 #ifdef READ_FIELDS
     const FT_Frame_Field  os2_fields[] = {
-              { ft_frame_start, 0, 78 },
+              FT_FRAME_START(78),
                 FT_FRAME_USHORT( TT_OS2, version ),
                 FT_FRAME_SHORT(  TT_OS2, xAvgCharWidth ),
                 FT_FRAME_USHORT( TT_OS2, usWeightClass ),
@@ -1263,22 +1263,22 @@
                 FT_FRAME_SHORT(  TT_OS2, sTypoLineGap ),
                 FT_FRAME_USHORT( TT_OS2, usWinAscent ),
                 FT_FRAME_USHORT( TT_OS2, usWinDescent ),
-              { ft_frame_end } };
+              FT_FRAME_END };
               
     const FT_Frame_Field  os2_fields_extra[] = {
-              { ft_frame_start, 0, 8 },
+              FT_FRAME_START(8),
                 FT_FRAME_ULONG( TT_OS2, ulCodePageRange1 ),
                 FT_FRAME_ULONG( TT_OS2, ulCodePageRange2 ),
-              { ft_frame_end } };
+              FT_FRAME_END };
 
     const FT_Frame_Field  os2_fields_extra2[] = {
-              { ft_frame_start, 0, 10 },
+              FT_FRAME_START(10),
                 FT_FRAME_SHORT( TT_OS2,  sxHeight ),
                 FT_FRAME_SHORT( TT_OS2,  sCapHeight ),
                 FT_FRAME_USHORT( TT_OS2, usDefaultChar ),
                 FT_FRAME_USHORT( TT_OS2, usBreakChar ),
                 FT_FRAME_USHORT( TT_OS2, usMaxContext ),
-              { ft_frame_end } };
+              FT_FRAME_END };
 #else
     TT_Int    j;
 #endif
@@ -1414,7 +1414,7 @@
     TT_Postscript*  post = &face->postscript;
 #ifdef READ_FIELDS
     const FT_Frame_Field  post_fields[] = {
-              { ft_frame_start, 0, 32 },
+              FT_FRAME_START(32),
                 FT_FRAME_ULONG( TT_Postscript, FormatType ),
                 FT_FRAME_ULONG( TT_Postscript, italicAngle ),
                 FT_FRAME_SHORT( TT_Postscript, underlinePosition ),
@@ -1424,7 +1424,7 @@
                 FT_FRAME_ULONG( TT_Postscript, maxMemType42 ),
                 FT_FRAME_ULONG( TT_Postscript, minMemType1 ),
                 FT_FRAME_ULONG( TT_Postscript, maxMemType1 ),
-              { ft_frame_end } };
+              FT_FRAME_END };
 #endif
 
     FT_TRACE2(( "PostScript " ));
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index f6377ff..7673f6a 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -621,11 +621,12 @@
     
     switch (tag)
     {
-      case ft_sfnt_head: table = &face->header;
-      case ft_sfnt_hhea: table = &face->horizontal;
-      case ft_sfnt_vhea: table = (face->vertical_info ? &face->vertical : 0 );
-      case ft_sfnt_os2:  table = (face->os2.version == 0xFFFF ? 0 : &face->os2 );
-      case ft_sfnt_post: table = &face->postscript;
+      case ft_sfnt_head: table = &face->header; break;
+      case ft_sfnt_hhea: table = &face->horizontal; break;
+      case ft_sfnt_vhea: table = (face->vertical_info ? &face->vertical : 0 ); break;
+      case ft_sfnt_os2:  table = (face->os2.version == 0xFFFF ? 0 : &face->os2 ); break;
+      case ft_sfnt_post: table = &face->postscript; break;
+      case ft_sfnt_maxp: table = &face->max_profile; break;
       
       default:
         table = 0;
@@ -637,6 +638,8 @@
   static
   FTDriver_Interface  tt_get_interface( TT_Driver  driver, const char* interface )
   {
+    (void)driver;
+    
     if (strcmp(interface,"get_sfnt")==0)
       return (FTDriver_Interface)tt_get_sfnt_table;
       
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index b09e098..8f84abd 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -718,6 +718,7 @@
     exec->callTop = 0;
 
 #if 1
+    (void)debug;
     return exec->face->interpreter( exec );
 #else
     if ( !debug )
@@ -2151,6 +2152,8 @@
     TT_F26Dot6  W;
     TT_Bool     S1, S2;
 
+    UNUSED_EXEC;
+    
     if ( ABS( Vx ) < 0x10000L && ABS( Vy ) < 0x10000L )
     {
       Vx *= 0x100;
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index ab27fd1..23e8d03 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -58,6 +58,8 @@
   FTDriver_Interface  Get_Interface( FT_Driver         driver,
                                      const FT_String*  interface )
   {
+    UNUSED(driver);
+    
     if ( strcmp( (const char*)interface, "attach_file" ) == 0 )
       return (FTDriver_Interface)T1_Read_AFM;
       
@@ -141,6 +143,7 @@
                             T1_UInt      vert_resolution )
   {
     UNUSED(char_width);
+    UNUSED(char_height);
     UNUSED(horz_resolution);
     UNUSED(vert_resolution);
 
diff --git a/src/type1z/t1driver.c b/src/type1z/t1driver.c
index 9d2fdd9..5a3ddd2 100644
--- a/src/type1z/t1driver.c
+++ b/src/type1z/t1driver.c
@@ -58,6 +58,8 @@
   FTDriver_Interface  Get_Interface( FT_Driver         driver,
                                      const FT_String*  interface )
   {
+    UNUSED(driver);
+    
     if ( strcmp( (const char*)interface, "attach_file" ) == 0 )
       return (FTDriver_Interface)T1_Read_AFM;
       
@@ -141,6 +143,7 @@
                             T1_UInt      vert_resolution )
   {
     UNUSED(char_width);
+    UNUSED(char_height);
     UNUSED(horz_resolution);
     UNUSED(vert_resolution);
 
diff --git a/src/type1z/t1load.c b/src/type1z/t1load.c
index 5877b86..447894c 100644
--- a/src/type1z/t1load.c
+++ b/src/type1z/t1load.c
@@ -651,6 +651,8 @@
   static
   void t1_init_loader( T1_Loader* loader, T1_Face  face )
   {
+    UNUSED(face);
+    
     MEM_Set( loader, 0, sizeof(*loader) );
     loader->num_glyphs = 0;
     loader->num_chars  = 0;
diff --git a/src/type1z/t1objs.c b/src/type1z/t1objs.c
index 860f7f4..32c7cbf 100644
--- a/src/type1z/t1objs.c
+++ b/src/type1z/t1objs.c
@@ -167,8 +167,9 @@
     T1_Error      error;
     PSNames_Interface*  psnames;
 
-    (void)face_index;
-    (void)face;
+    UNUSED(face_index);
+    UNUSED(face);
+    UNUSED(stream);
 
     face->root.num_faces = 1;
 
diff --git a/src/type1z/t1parse.c b/src/type1z/t1parse.c
index 997631b..a1f4be9 100644
--- a/src/type1z/t1parse.c
+++ b/src/type1z/t1parse.c
@@ -212,7 +212,7 @@
   {
     FT_Memory  memory = table->memory;
     
-    if (table->init == 0xdeadbeef)
+    if (table->init == (FT_Long)0xdeadbeef)
     {
       FREE( table->block );
       FREE( table->elements );