File: OGLFT.h

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (2363 lines) | stat: -rw-r--r-- 92,812 bytes parent folder | download | duplicates (3)
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
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
// -*- c++ -*-
/*
 * OGLFT: A library for drawing text with OpenGL using the FreeType library
 * Copyright (C) 2002 lignum Computing, Inc. <oglft@lignumcomputing.com>
 * $Id: OGLFT.h.cmake 107 2008-04-25 09:29:24Z brevilo $
 *
 *
 * Contains small modifications by Mario Kleiner. Search for text "MK" for
 * comments on the minimal changes needed to provide Unicode support while
 * removing dependencies on the QT toolkit.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
#ifndef OGLFT_H
#define OGLFT_H

// CMake activates these definitions.
/* #undef ENABLE_QT */
/* #undef ENABLE_GLE */
/* #undef GLU_TESS_CALLBACK_TRIPLEDOT */
/* #undef HAVE_OPENGL_DIR */
// Convert to our old options.
#if !defined(ENABLE_QT)
#define ENABLE_QT
#endif
#if !defined(ENABLE_GLE)
#define OGLFT_NO_SOLID
#endif

#include <cmath>
#include <map>
#include <list>
#include <vector>

#ifdef WIN32
#include <windows.h>
#endif

#ifdef HAVE_OPENGL_DIR
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif

#ifndef OGLFT_NO_SOLID
#ifdef HAVE_OPENGL_DIR
#include <OpenGL/gle.h>
#else
#include <GL/gle.h>
#endif
#endif

#ifndef OGLFT_NO_QT
// MK changed to OGLFT_QT_VERSION 0
#define OGLFT_QT_VERSION 0
#if OGLFT_QT_VERSION == 3
#include <qstring.h>
#include <qcolor.h>
#elif OGLFT_QT_VERSION == 4
#include <QString>
#include <QColor>
// MK changed to include qstringqcharemulation.h on OGLFT_QT_VERSION == 0
#elif OGLFT_QT_VERSION == 0
#include "qstringqcharemulation.h"
#endif
#endif

#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_OUTLINE_H
#include FT_TRIGONOMETRY_H
#include FT_BITMAP_H

//#ifdef _MSC_VER
#if 0
#ifdef OGLFT_BUILD
#define OGLFT_API __declspec(dllexport)
#else
#define OGLFT_API __declspec(dllimport)
#endif
#else
#define OGLFT_API
#endif

//! All of OGLFT C++ objects are in this namespace.

namespace OGLFT {

  //! Thanks to DesCartes, I'd consider these manifest constants.
  enum Coordinates {
    X, //!< The X component of space
    Y, //!< The Y component of space
    Z, //!< The Z component of space
    W  //!< The projection component of space
  };

  //! Who to credit? Newton? I'd consider these manifest constants.
  enum ColorSpace {
    R, //!< The Red component of a color
    G, //!< The Green component of a color
    B, //!< The Blue component of a color
    A, //!< The Alpha (or transparency) of a color
  };

  //! Callback from GLU tessellation routines.
#ifdef GLU_TESS_CALLBACK_TRIPLEDOT
  typedef GLvoid (*GLUTessCallback)(...);
#else
  typedef GLvoid (*GLUTessCallback)();
#endif

  //! The FreeType library instance.
  /*!
   * The FreeType library has a single, global instance of a library
   * handle.  This reference is used to load font faces. This detail
   * is generally hidden from the user of OGLFT, however, it
   * can be useful to get the FT_Library instance if you want to open
   * a font file yourself, either from disk or embedded in the program.
   */
  class Library {
  public:
    /*!
     * The FreeType library's library handle is only available through this
     * accessor method.
     * \return the global OGLFT FreeType library handle.
     */
    static OGLFT_API FT_Library& instance ( void );

  protected:
    /*!
     * The constructor for this class is automatically called when
     * this library is loaded. Access the instance through the instance()
     * method.
     */
    OGLFT_API Library ( void );
    /*!
     * This destructor is automatically called when the program exits.
     */
    OGLFT_API ~Library( void );

  private:
    static Library library;
    static FT_Library library_;
  };

  //! Advance describes the "advance" of a glyph, namely the distance in
  //! model space at which the NEXT glyph should be drawn. This class exists
  //! to assist the computation of string metrics.
  struct OGLFT_API Advance {
    float dx_;  //!< Advance increment in the X direction.
    float dy_;  //!< Advance increment in the Y direction.

    //! Default constructor. An otherwise uninitialized Advance contains zeros.
    Advance ( float dx = 0, float dy = 0 ) : dx_( dx ), dy_( dy )
    {}

    //! Initialize an advance from a FreeType advance member.
    Advance ( FT_Vector v )
    {
      dx_ = v.x / 64.f;
      dy_ = v.y / 64.f;
    }

    //! Increment Advance with a FreeType advance member.
    //! \return a reference to oneself.
    Advance& operator+= ( const FT_Vector v )
    {
      dx_ += v.x / 64.f;
      dy_ += v.y / 64.f;
      return *this;
    }
  };

  //! Describe the metrics of a glyph or string relative to the origin
  //! of the first character
  struct OGLFT_API BBox {
    float x_min_;     //!< The left-most position at which "ink" appears.
    float y_min_;     //!< the bottom-most position at which "ink" appears.
    float x_max_;     //!< The right-most position at which "ink" appears.
    float y_max_;     //!< The top-most position at which "ink" appears.
    Advance advance_; //!< The (total) advancement

    //! Default constructor is all zeros.
    BBox () : x_min_( 0 ), y_min_( 0 ), x_max_( 0 ), y_max_( 0 )
    {}

    /*!
     *(Partially) initialize a BBox from a FreeType bounding box member.
     *(The advancement is initialized to zero by its default constructor).
     * \param ft_bbox a FreeType bounding box as retrieved from
     * \c FT_Glyph_Get_CBox.
     */
    BBox ( FT_BBox ft_bbox )
    {
      x_min_ = ft_bbox.xMin / 64.f;
      y_min_ = ft_bbox.yMin / 64.f;
      x_max_ = ft_bbox.xMax / 64.f;
      y_max_ = ft_bbox.yMax / 64.f;
    }

    //! Scale the bounding box by a constant.
    //! \param k a constant to scale the bounding box by.
    //! \return a reference to oneself.
    BBox& operator*= ( float k )
    {
      x_min_ *= k;
      y_min_ *= k;
      x_max_ *= k;
      y_max_ *= k;
      advance_.dx_ *= k;
      advance_.dy_ *= k;

      return *this;
    }

    /*!
     * Merge a bounding box into the current one (not really addition).
     * Each time a BBox is "added", the current BBox is expanded to include
     * the metrics of the new BBox. May only work for horizontal fonts, though.
     * \param b the bounding box to merge.
     * \return a reference to oneself.
     */
    BBox& operator+= ( const BBox& b )
    {
      float new_value;

      new_value = b.x_min_ + advance_.dx_;
      if ( new_value < x_min_ ) x_min_ = new_value;

      new_value = b.y_min_ + advance_.dy_;
      if ( new_value < y_min_ ) y_min_ = new_value;

      new_value = b.x_max_ + advance_.dx_;
      if ( new_value > x_max_ ) x_max_ = new_value;

      new_value = b.y_max_ + advance_.dy_;
      if ( new_value > y_max_ ) y_max_ = new_value;

      advance_.dx_ += b.advance_.dx_;
      advance_.dy_ += b.advance_.dy_;

      return *this;
    }
  };

  //! During tesselation of a polygonal Face (outline, filled or solid),
  //! an object which implements this interface can be used to compute a
  //! different color for each vertex.
  class OGLFT_API ColorTess {
  public:
    virtual ~ColorTess ( void ) {}
    //! Compute a color for this position. Note that the position is
    //! in the glyph's local coordinate system.
    //! \param p vertex position in glyph's local coordinate system. Argument is
    //! a GLdouble[3].
    //! \return GLfloat[4] (RGBA) color specification.
    virtual GLfloat* color ( GLdouble* p ) = 0;
  };

  //! During tesselation of a polygonal Face (outline, filled or solid),
  //! an object which implements this interface can be used to compute a
  //! different texture coordinate for each vertex.
  class OGLFT_API TextureTess {
  public:
    virtual ~TextureTess ( void ) {}
    //! Compute a texture coordinate for this position. Note that the
    //! position is in the glyph's local coordinate system.
    //! \param p vertex position in glyph's local coordinate system. Argument is
    //! a GLdouble[3].
    //! \return GLfloat[2] (s,t) texture coordinates.
    virtual GLfloat* texCoord ( GLdouble* p ) = 0;
  };

  //! The argument to setCharacterDisplayLists is an STL vector of
  //! OpenGL display list names (GLuints).
  typedef std::vector<GLuint> DisplayLists;

  //! A convenience definition of an iterator for display list vectors.
  typedef DisplayLists::const_iterator DLCI;

  //! A convenience definition of an iterator for display list vectors.
  typedef DisplayLists::iterator DLI;

  //! A face (aka font) used to render text with OpenGL.
  /*!
   * This is an abstract class, but it does define most the functions that
   * you are likely to call to manipulate the rendering of the text.
   */
  class Face {
  public:
    //! Thanks to the standard formerly known as PHIGS. Horizontal text
    //! justification constants.
    enum OGLFT_API HorizontalJustification {
      LEFT,   //!< Left justified justification of text
      ORIGIN, //!< Natural origin alignment of text (default)
      CENTER, //!< Center justified alignment of text
      RIGHT   //!< Right justified alignment of text
    };

    //! Thanks to the standard formerly known as PHIGS. Vertical text
    //! justification constants.
    enum OGLFT_API VerticalJustification {
      BOTTOM,   //!< Descender alignment of text
      BASELINE, //!< Baseline alignment of text (default)
      MIDDLE,   //!< Centered alignment of text
      TOP       //!< Ascender justification of text
    };

    //! Control how OpenGL display lists are created for individual glyphs.
    //! The default mode is to create display lists for each glyph as it
    //! is requested. Therefore, the Face drawing routines cannot themselves
    //! be called from within an open display list. In IMMEDIATE mode,
    //! cached glyphs will be drawn if available, otherwise the FreeType
    //! data for a glyph is re-rendered each time.
    enum OGLFT_API GlyphCompileMode {
      COMPILE,    //!< Compile new glyphs when seen for the first time.
      IMMEDIATE   //!< Do not \em create display lists for glyphs.
    };

  private:
    //! We allow a Face to be constructed either from a file name
    //! or passed in as an already opened FreeType FT_Face. In the case
    //! of the later (already opened), we don't close the FT_Face on
    //! destruction. This way you can share FT_Faces between related
    //! OGLFT faces. Also, we're experimenting with being able to use
    //! multiple FT_Faces in a single OGLFT Face, so this is represented
    //! as a data structure.
    struct FaceData {
      FT_Face face_;
      bool free_on_exit_;
      FaceData ( FT_Face face, bool free_on_exit = true )
	: face_( face ), free_on_exit_( free_on_exit )
      {}
    };
  protected:
    //! The FreeType face - experimentally, this is now an array of
    //! faces so that we can handle a wider range of UNICODE points
    //! in case a face doesn't cover the points of interest.
    std::vector< FaceData > faces_;

    //! Did a font load OK?
    bool valid_;

    //! Glyph display list creation mode.
    enum GlyphCompileMode compile_mode_;

    //! Nominal point size.
    float point_size_;

    //! Display resolution in pixels per inch.
    FT_UInt resolution_;

    //! Does rendering text affect the MODELVIEW matrix?
    bool advance_;

    //! Foreground color (I really wanted to avoid this, but not really
    //! possible without state queries, which you can't put into
    //! display lists. Anyway, you'll be able to get even more fancy
    //! by passing in a function to map the color with, so why balk at
    //! this?)
    GLfloat foreground_color_[4];

    //! Background color (what modes would use this?)
    GLfloat background_color_[4];

    //! PHIGS-like horizontal positioning of text.
    enum HorizontalJustification horizontal_justification_;

    //! PHIGS-like vertical positioning of text.
    enum VerticalJustification vertical_justification_;

    //! Rotate an entire string in the Z plane
    GLfloat string_rotation_;

    //! Let the user decide which character to use as the rotation reference.
    //! Use "o" by default, I suppose.
    FT_UInt rotation_reference_glyph_;

    //! The rotation reference character could be in any face.
    FT_Face rotation_reference_face_;

    //! These are the translation offsets provided by the rotation reference
    //! character; for whom, we've discovered, only the Y position is relevant.
    GLfloat rotation_offset_y_;

    bool do_draw_underline_;

    //! Type of the cache of defined glyph to display list mapping.
    typedef std::map< FT_UInt, GLuint > GlyphDLists;

    //! A convenience definition of the iterator over the glyph to display
    //! list map.
    typedef GlyphDLists::const_iterator GDLCI;

    //! A convenience definition of the iterator over the glyph to display
    //! list map.
    typedef GlyphDLists::iterator GDLI;

    //! Cache of defined glyph display lists
    GlyphDLists glyph_dlists_;

    //! The user can supply an array of display list which are invoked
    //! before each glyph is rendered.
    DisplayLists character_display_lists_;

  public:
    /*!
     * Construct a Face by loading a font from the given file.
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    Face ( const char* filename, float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * Construct a Face by loading a font from the given memory location.
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    Face ( const FT_Byte* data_base, const FT_Long data_size,
	   float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * Alternatively, the user may have already opened a face and just
     * wants to draw with it. This is useful for Multiple Master fonts or
     * combining multiple files to increase UNICODE point coverage.
     * \param face open Freetype FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    Face ( FT_Face face, float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * Deleting a Face frees its FreeType face (and anything else it's
     * styles have allocated).
     */
    virtual ~Face ( void );

    /*!
     * Let the user test to see if the font was loaded OK.
     * \return true if the FT_Face was successfully created.
     */
    bool isValid ( void ) const { return valid_; }

    /*!
     * Add another FT_Face to the OGLFT Face. Generally used to add more
     * coverage of UNICODE points (at least that's the plan). This
     * routine takes a filename and takes ownership of the FT_Face.
     * \param filename name of file containing font face data.
     * \return true if face was successfully added.
     */
    bool addAuxiliaryFace ( const char* filename );

    /*!
     * Add another FT_Face to the OGLFT Face. Generally used to add more
     * coverage of UNICODE points (at least that's the plan). This
     * routine takes a memory location and takes ownership of the FT_Face.
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \return true if face was successfully added.
     */
    bool addAuxiliaryFace ( const FT_Byte* data_base, const FT_Long data_size );

    /*!
     * Add another FT_Face to the OGLFT Face. Generally used to add more
     * coverage of UNICODE points (at least that's the plan). This
     * routine takes an already open FT_Face. The user is responsible
     * for clean up.
     * \param face open FreeType FT_Face
     * \return true if face was successfully added.
     */
    bool addAuxiliaryFace ( FT_Face face );

    /*!
     * By default, each time a new character is seen, its glyph is rendered
     * into a display list. This means that a display list cannot already
     * be open (since OpenGL doesn't allow nested display list creation).
     * Rendering can be set into immediate mode in which case glyphs are
     * rendered from display lists if available, but are otherwise generated
     * anew each time.
     * \param compile_mode the new compile mode.
     */
    void setCompileMode ( enum GlyphCompileMode compile_mode )
    {
      compile_mode_ = compile_mode;
    }

    /*!
     * \return the current glyph compile mode.
     */
    enum GlyphCompileMode compileMode ( void ) const { return compile_mode_; }

    /*!
     * For the rasterized styles (Monochrome, Grayscale, Translucent, Texture),
     * glyphs are rendered at the pixel size given by:
     *
     * point_size [pts] * / 72 [pts/in] * resolution [dots/in] = [dots].
     *
     * For the polygon styles (Outline, Filled, Solid), the "nominal" size of
     * the glyphs is:
     *
     * point_size[pts] / 72 [pts/in] * resolution [dots/in]
     * / units_per_EM [font unit/EM] = [dots * EM].
     *
     * If the MODELVIEW and PROJECTION matrices are such that one screen pixel
     * corresponds to one modeling unit, then polygonal Faces will
     * be the same size as raster Faces.
     *
     * Note that changing the point size after Face creation will invalidate
     * the cache of OpenGL display lists and any other information which
     * the individual styles have cached.
     * \param point_size the new point size in points (1/72-th inch).
     */
    void setPointSize ( float point_size );

    /*!
     * \return the current point size.
     */
    float pointSize ( void ) { return point_size_; }

    /*!
     * For the rasterized styles (Monochrome, Grayscale,
     * Translucent, Texture), the exact rendered size of the glyphs depends on
     * the resolution of the display (as opposed to the polygon styles
     * whose size is controlled by the viewing matrices). The Texture
     * style is slightly different because the glyphs are texture-mapped
     * onto an arbitrary rectangle; here, the resolution only controls
     * how accurately the glyph is rendered.
     * \param resolution the resolution in DPI (dots per inch).
     */
    void setResolution ( FT_UInt resolution );

    /*!
     * \return the current raster resolution.
     */
    FT_UInt resolution ( void ) { return resolution_; }

    /*!
     * If advance is true, then the changes made to the MODELVIEW matrix
     * to render a string are allowed to remain. Otherwise, the library
     * pushes the current MODELVIEW matrix onto the matrix stack, renders
     * the string and then pops it off again. Rendering a character always
     * modifies the MODELVIEW matrix.
     * \param advance whether or not the MODELVIEW matrix should be left
     * translated by the advancement of a rendered string.
     */
    void setAdvance ( bool advance ) { advance_ = advance; }

    /*!
     * \return the advance value.
     */
    bool advance ( void ) const { return advance_; }

    /*!
     * This is the nominal color of the glyphs. A lot of other things
     * can alter what you actually see! Note that changing the foreground
     * color invalidates the glyph cache.
     * \param red the red component of the foreground color.
     * \param green the green component of the foreground color.
     * \param blue the blue component of the foreground color.
     * \param alpha the alpha component of the foreground color.
     */
    void setForegroundColor ( GLfloat red = 0.0,
			      GLfloat green = 0.0,
			      GLfloat blue = 0.0,
			      GLfloat alpha = 1.0 );

    /*!
     * This is the nominal color of the glyphs. A lot of other things
     * can alter what you actually see! Note that changing the foreground
     * color invalidates the glyph cache.
     * \param foreground_color an array of 4 values corresponding to the
     * red, green, blue and alpha components of the foreground color.
     */
    void setForegroundColor ( const GLfloat foreground_color[4] );
#ifndef OGLFT_NO_QT
    /*!
     * This is the nominal color of the glyphs. A lot of other things
     * can alter what you actually see! Note that changing the foreground
     * color invalidates the glyph cache.
     * \param foreground_color the foreground color as an unsigned int.
     */
    void setForegroundColor ( const QRgb foreground_color );
#endif /* OGLFT_NO_QT */
    /*!
     * \return the red component of the foreground color
     */
    GLfloat foregroundRed ( void ) const { return foreground_color_[R]; }
    /*!
     * \return the green component of the foreground color
     */
    GLfloat foregroundGreen ( void ) const { return foreground_color_[G]; }
    /*!
     * \return the blue component of the foreground color
     */
    GLfloat foregroundBlue ( void ) const { return foreground_color_[B]; }
    /*!
     * \return the alpha component of the foreground color
     */
    GLfloat foregroundAlpha ( void ) const { return foreground_color_[A]; }

    /*!
     * This is the nominal background color of the glyphs. A lot of other things
     * can alter what you actually see! Note that changing the background
     * color invalidates the glyph cache.
     * \param red the red component of the background color.
     * \param green the green component of the background color.
     * \param blue the blue component of the background color.
     * \param alpha the alpha component of the background color.
     */
    void setBackgroundColor ( GLfloat red = 1.0,
			      GLfloat green = 1.0,
			      GLfloat blue = 1.0,
			      GLfloat alpha = 0.0 );

    /*!
     * This is the nominal background color of the glyphs. A lot of other things
     * can alter what you actually see! Note that changing the background
     * color invalidates the glyph cache.
     * \param background_color an array of 4 values corresponding to the
     * red, green, blue and alpha components of the background color.
     */
    void setBackgroundColor ( const GLfloat background_color[4] );
#ifndef OGLFT_NO_QT
    /*!
     * This is the nominal background color of the glyphs. A lot of other things
     * can alter what you actually see! Note that changing the background
     * color invalidates the glyph cache.
     * \param background_color the background color as an unsigned int.
     */
    void setBackgroundColor ( const QRgb background_color );
#endif /* OGLFT_NO_QT */
    /*!
     * \return the red component of the background color
     */
    GLfloat backgroundRed ( void ) const { return background_color_[R]; }
    /*!
     * \return the green component of the background color
     */
    GLfloat backgroundGreen ( void ) const { return background_color_[G]; }
    /*!
     * \return the blue component of the background color
     */
    GLfloat backgroundBlue ( void ) const { return background_color_[B]; }
    /*!
     * \return the alpha component of the background color
     */
    GLfloat backgroundAlpha ( void ) const { return background_color_[A]; }

    /*!
     * Set the individual character rotation in the Z direction.
     * \param character_rotation_z angle in degrees of z rotation.
     */
    virtual void setCharacterRotationZ ( GLfloat character_rotation_z ) = 0;

    /*!
     * \return the character rotation in the Z direction.
     */
    virtual GLfloat characterRotationZ ( void ) const = 0;

    /*!
     * The z rotation angle needs a center. Nominate a character whose
     * center is to be the center of rotation. By default, use "o".
     * \param c rotation reference character.
     */
    void setCharacterRotationReference ( unsigned char c );

    /*!
     * Rotate an entire string through the given angle (in the Z plane only).
     * (Somewhat pointless for the vector styles since you can do mostly
     * the same thing with the MODELVIEW transform, however, for what its
     * worth, this routine uses the FreeType rotation function to compute
     * the "proper" metrics for glyph advance.)
     * \param string_rotation angle in degrees of z rotation.
     */
    void setStringRotation ( GLfloat string_rotation );

    /*!
     * \return the (Z plane) string rotation angle.
     */
    GLfloat stringRotation ( void ) const { return string_rotation_; }

    /*!
     * Set the horizontal justification.
     * \param horizontal_justification the new horizontal justification.
     */
    void setHorizontalJustification ( enum HorizontalJustification
				      horizontal_justification )
    {
      horizontal_justification_ = horizontal_justification;
    }

    /*!
     * \return the horizontal justification.
     */
    enum HorizontalJustification horizontalJustification ( void ) const
    { return horizontal_justification_; }

    /*!
     * Set the vertical justification.
     * \param vertical_justification the new vertical justification
     */
    void setVerticalJustification ( enum VerticalJustification
				    vertical_justification )
    {
      vertical_justification_ = vertical_justification;
    }

    /*!
     * \return the vertical justification.
     */
    enum VerticalJustification verticaljustification ( void )
      const { return vertical_justification_; }

    /*!
     * Specify an OpenGL display list to be invoked before
     * each character in a string. Face makes a copy of the argument. Pass
     * an empty DisplayLists to disable this feature.
     * \param character_display_lists STL vector<GLuint> containing a display
     * list to invoke before each glyph in a string is drawn.
     */
    void setCharacterDisplayLists ( const DisplayLists& character_display_lists )
    {
      character_display_lists_ = character_display_lists;
    }

    /*!
     * \return a reference to the array of character display lists. This is
     * the live list as stored in the Face.
     */
    DisplayLists& characterDisplayLists ( void )
    { return character_display_lists_; }

    /*!
     * \return the height (i.e., line spacing) at the current character size.
     */
    virtual double height ( void ) const = 0;

    /*!
     * \return The position, in font units, of the underline line for this
     * face. It is the center of the underlining stem.  Only relevant for
     * scalable formats.
     */
    virtual double underline_position ( void ) const = 0;

    /*!
     * \return The thickness, in font units, of the underline for this face.
     * Only relevant for scalable formats.
     */
    virtual double underline_thickness ( void ) const = 0;

    /*!
     * This sets whether glyphs are drawn with underline or not. Note that
     * changing the background color invalidates the glyph cache.
     */
    void setDoUnderLine(const bool do_draw_underline);

    /*!
     * Compute the bounding box info for a character.
     * \param c the (latin1) character to measure.
     * \return the bounding box of c.
     */
    virtual BBox measure ( unsigned char c ) = 0;
#ifndef OGLFT_NO_QT
    /*!
     * Compute the bounding box info for a character.
     * \param c the (UNICODE) character to measure.
     * \return the bounding box of c.
     */
    virtual BBox measure ( const QChar c ) = 0;
#endif /* OGLFT_NO_QT */
    /*!
     * Compute the bounding box info for a string.
     * \param s the (latin1) string to measure.
     * \return the bounding box of s.
     */
    virtual BBox measure ( const char* s );
    /*!
     * Compute the bounding box info for a string without conversion
     * to modeling coordinates.
     * \param s the (latin1) string to measure.
     * \return the bounding box of s.
     */
    virtual BBox measureRaw ( const char* s );
#ifndef OGLFT_NO_QT
    /*!
     * Compute the bounding box info for a string.
     * \param s the (UNICODE) string to measure.
     * \return the bounding box of s.
     */
    virtual BBox measure ( const QString& s );
    /*!
     * Compute the bounding box info for a real number formatted as specified.
     * \param format (see draw for valid formats)
     * \param number real number.
     * \return the bounding box of the formatted number.
     */
    virtual BBox measure ( const QString& format, double number );
    /*!
     * Compute the bounding box info for a string without conversion
     * to modeling coordinates.
     * \param s the (UNICODE) string to measure.
     * \return the bounding box of s.
     */
    virtual BBox measureRaw ( const QString& s );
#endif /* OGLFT_NO_QT */
    /*!
     * Compile a string into an OpenGL display list for later
     * rendering.  Essentially, the string is rendered at the origin
     * of the current MODELVIEW. Note: no other display lists should
     * be open when this routine is called. Also, the Face does not
     * keep track of these lists, so you must delete them in order
     * to recover the memory.
     * \param s the (latin1) string to compile.
     * \return the display list name for the string.
     */
    GLuint compile ( const char* s );
#ifndef OGLFT_NO_QT
    /*!
     * Compile a string into an OpenGL display list for later
     * rendering.  Essentially, the string is rendered at the origin
     * of the current MODELVIEW. Note: no other display lists should
     * be open when this routine is called. Also, the Face does not
     * keep track of these lists, so you must delete them in order
     * to recover the memory.
     * \param s the (UNICODE) string to compile.
     * \return the display list name for the string.
     */
    GLuint compile ( const QString& s );
#endif /* OGLFT_NO_QT */
    /*!
     * Compile a single character (glyph) into an OpenGL display list
     * for later rendering. The Face \em does keep track of these
     * display lists, so do not delete them.
     * \param c the (latin1) character to compile.
     * \return the display list name for the character.
     */
    GLuint compile ( unsigned char c );
#ifndef OGLFT_NO_QT
    /*!
     * Compile a single character (glyph) into an OpenGL display list
     * for later rendering. The Face \em does keep track of these
     * display lists, so do not delete them.
     * \param c the (UNICODE) character to compile.
     * \return the display list name for the character.
     */
    GLuint compile ( const QChar c );
#endif /* OGLFT_NO_QT */
    /*!
     * Draw a (latin1) string using the current MODELVIEW matrix. If
     * advance is true, then the final glyph advance changes to the
     * MODELVIEW matrix are left in place.
     * \param s the (latin1) string to draw.
     */
    void draw ( const char* s );
#ifndef OGLFT_NO_QT
    /*!
     * Draw a (UNICODE) string using the current MODELVIEW
     * matrix. If advance is true, then the final glyph advance
     * changes to the MODELVIEW matrix are left in place.
     * \param s the (UNICODE) string to draw.
     */
    void draw ( const QString& s );
#endif /* OGLFT_NO_QT */
    /*!
     * Draw the character using the current MODELVIEW matrix. Note that
     * the MODELVIEW matrix is modified by the glyph advance. Draw a
     * string if you don't want the MODELVIEW matrix changed.
     * \param c the (latin1) character to draw.
     */
    void draw ( unsigned char c );

#ifndef OGLFT_NO_QT
    /*!
     * Draw the character using the current MODELVIEW matrix. Note that
     * the MODELVIEW matrix is modified by the glyph advance. Draw a
     * string if you don't want the MODELVIEW matrix changed.
     * \param c the (UNICODE) character to draw.
     */
    void draw ( const QChar c );
#endif /* OGLFT_NO_QT */
    /*!
     * Draw the (latin1) character at the given 2D point. Note that
     * the MODELVIEW matrix is modified by the glyph advance. Draw
     * a string if you don't want the MODELVIEW matrix changed.
     * \param x the X position.
     * \param y the Y position.
     * \param c the (latin1) character to draw.
     */
    void draw ( GLfloat x, GLfloat y, unsigned char c );
    /*!
     * Draw the (latin1) character at the given 3D point. Note that
     * the MODELVIEW matrix is modified by the glyph advance. Draw
     * a string if you don't want the MODELVIEW matrix changed.
     * \param x the X position.
     * \param y the Y position.
     * \param z the Z position.
     * \param c the (latin1) character to draw.
     */
    void draw ( GLfloat x, GLfloat y, GLfloat z, unsigned char c );
#ifndef OGLFT_NO_QT
    /*!
     * Draw the (UNICODE) character at the given 2D point. Note that
     * the MODELVIEW matrix is modified by the glyph advance. Draw
     * a string if you don't want the MODELVIEW matrix changed.
     * \param x the X position.
     * \param y the Y position.
     * \param c the (UNICODE) character to draw.
     */
    void draw ( GLfloat x, GLfloat y, QChar c );
    /*!
     * Draw the (UNICODE) character at the given 3D point. Note that
     * the MODELVIEW matrix is modified by the glyph advance. Draw
     * a string if you don't want the MODELVIEW matrix changed.
     * \param x the X position.
     * \param y the Y position.
     * \param z the Z position.
     * \param c the (UNICODE) character to draw.
     */
    void draw ( GLfloat x, GLfloat y, GLfloat z, QChar c );
#endif /* OGLFT_NO_QT */
    /*!
     * Draw a string at the given 2D point.
     * \param x the X position.
     * \param y the Y position.
     * \param s the (latin1) string to draw.
     */
    void draw ( GLfloat x, GLfloat y, const char* s );
    /*!
     * Draw a string at the given 3D point.
     * \param x the X position.
     * \param y the Y position.
     * \param z the Z position.
     * \param s the (latin1) string to draw.
     */
    void draw ( GLfloat x, GLfloat y, GLfloat z, const char* s );
#ifndef OGLFT_NO_QT
    /*!
     * Draw a string at the given 2D point.
     * \param x the X position.
     * \param y the Y position.
     * \param s the (UNICODE) string to draw.
     */
    void draw ( GLfloat x, GLfloat y, const QString& s );
    /*!
     * Draw a string at the given 3D point.
     * \param x the X position.
     * \param y the Y position.
     * \param z the Z position.
     * \param s the (UNICODE) string to draw.
     */
    void draw ( GLfloat x, GLfloat y, GLfloat z, const QString& s );
    /*!
     * Draw a real number per the given format at the given 2D point.
     * \param x the X position.
     * \param y the Y position.
     * \param format Like a typical printf format. Regular text is printed
     * while a '%' introduces the real number's format. Includes the
     * following format flags:
     * \li %%x.yf - floating point in field width x and precision y
     * \li %%x.ye - scientific notation in field width x and precision y
     * \li %%x.yg - pick best floating or scientific in field width x and
     *  precision y
     * \li %%p - draw as a proper fraction, e.g. 1 1/2. Note: this currently
     * requires a special font which encodes glyphs to be drawn for the
     * numerator and demoninator in the UNICODE Private Area (0xE000).
     *
     * \param number the numeric value.
     */
    void draw ( GLfloat x, GLfloat y, const QString& format, double number );
    /*!
     * Draw a real number per the given format at the given 3D point.
     * \param x the X position.
     * \param y the Y position.
     * \param z the Z position.
     * \param format Like a typical printf format. Regular text is printed
     * while a '%' introduces the real number's format. Includes the
     * following format flags:
     * \li %%x.yf - floating point in field width x and precision y
     * \li %%x.ye - scientific notation in field width x and precision y
     * \li %%x.yg - pick best floating or scientific in field width x and
     *  precision y
     * \li %%p - draw as a proper fraction, e.g. 1 1/2. Note: this currently
     * requires a special font which encodes glyphs to be drawn for the
     * numerator and demoninator in the UNICODE Private Area (0xE000).
     *
     * \param number the numeric value.
     */
    void draw ( GLfloat x, GLfloat y, GLfloat z, const QString& format,
		double number );
#endif /* OGLFT_NO_QT */
    /*!
     * \return the face ascender, in point units.
     */
    int ascender ( void );

    /*!
     * \return the face descender, in point units.
     */
    int descender ( void );

  protected:
    // The various styles override these routines

    //! Some styles, in particular the Texture, need specialized steps
    //! to compile a glyph into an OpenGL display list.
    //! \param face the FT_Face containing the glyph.
    //! \param glyph_index the index of the glyph in face.
    //! \return the display list of the compiled glyph.
    virtual GLuint compileGlyph ( FT_Face face, FT_UInt glyph_index ) = 0;

    //! Each style implements its own glyph rendering routine.
    //! \param face the FT_Face containing the glyph.
    //! \param glyph_index the index of the glyph in face.
    virtual void renderGlyph ( FT_Face face, FT_UInt glyph_index ) = 0;

    //! There is a slight different between the way in which the polygonal
    //! and raster styles select the character size for FreeType to generate.
    virtual void setCharSize ( void ) = 0;

    //! The different styles have different caching needs (well, really only
    //! the texture style currently has more than the display list cache).
    virtual void clearCaches ( void ) = 0;

    //! The polygonal and raster styles compute different values for the
    //! Z rotation offset. (It's in integer pixels for the raster styles and
    //! in floating point pixels for the polygonal styles.)
    virtual void setRotationOffset ( void ) = 0;

  private:
    void init ( void );
    BBox measure_nominal ( const char* s );
#ifndef OGLFT_NO_QT
    BBox measure_nominal ( const QString& s );
    QString format_number ( const QString& format, double number );
#endif /* OGLFT_NO_QT */
  };

  //! This is the base class of the polygonal styles: outline, filled and solid.
  /*!
   * In the polygonal styles, the detailed geometric outlines of the glyphs
   * are extracted from the font file and rendered as polygons.
   */
  class Polygonal : public Face {
  protected:
    //! Angle of rotation of characters relative to text orientation.
    struct {
      bool active_;
      GLfloat x_, y_, z_;
    } character_rotation_;

    //! The tessellation of curves is pretty crude; regardless of length,
    //! use the same number of increments (and as near as I can tell, this
    //! is more than sufficient unless the glyph takes up the whole screen).
    unsigned int tessellation_steps_;

    //! When curves are tessellated, we use the forward difference algorithm
    //! from Foley and van Dam for parametric curves (pg. 511 of 2nd Ed. in C).
    //! So, the step size, delta, is in the parametric variable which is always
    //! on the interval [0,1]. Therefore, delta = 1/tessellation_steps
    double delta_, delta2_, delta3_;

    //! For vector rendition modes, FreeType is allowed to generate the
    //! lines and arcs at the original face definition resolution. To
    //! get to the proper glyph size, the vertices are scaled before
    //! they're passed to the GLU tessellation routines.
    float vector_scale_;

    //! Callbacks for FreeType glyph decomposition into outlines
    FT_Outline_Funcs interface_;

    //! Default number of steps to break TrueType and Type1 arcs into.
    //! (Note: this looks good to me, anyway)
    static const unsigned int DEFAULT_TESSELLATION_STEPS = 4;

    /*!
     * VertexInfo is a private class which is used by the decomposition and
     * tessellation routines to store the vertices and other data of the glyph's
     * outline.  Because of the "impedance mismatch" between the crazy
     * 26.6 fixed point format of the FreeType library (well, don't
     * blame them; look at what they have to work with) and OpenGL's preference
     * for double precision, this simple vector has two constructors: one
     * for 26.6 format and one for direct floating point.
     *
     * VertexInfo also contains (optional) pointers to objects which
     * implement the ColorTess and TextureTess interfaces.
     */
    struct VertexInfo {
      double v_[3]; //!< Why is this double precision? Because the second
		    //!< argument to the routine gluTessVertex is a pointer
		    //!< to an array of doubles. Otherwise, we could use
		    //!< single precision everywhere.

      //! The user can provide a ColorTess object which computes a color
      //! for each tesselated vertex.
      ColorTess* color_tess_;

      //! The user can provide a TextureTess object which computes texture
      //! coordinates for each tesselated vertex.
      TextureTess* texture_tess_;

      //! Default constructor just initializes Vertex to zero.
      //! \param color_tess optional color tesselation object.
      //! \param texture_tess optional texture tesselation object.
      VertexInfo ( ColorTess* color_tess = 0, TextureTess* texture_tess = 0 )
	: color_tess_( color_tess ), texture_tess_( texture_tess )
      {
	v_[X] = v_[Y] = v_[Z] = 0.;
      }

      /*!
       * Construct a Vertex from a point in a FreeType contour.
       * \param ft_v a FreeType FT_Vector, normally passed into the
       * the decomposition callbacks.
       * \param color_tess optional color tesselation object.
       * \param texture_tess optional texture tesselation object.
       */
      VertexInfo ( FT_Vector* ft_v, ColorTess* color_tess = 0,
		   TextureTess* texture_tess = 0 )
	: color_tess_( color_tess ), texture_tess_( texture_tess )
      {
	v_[X] = (double)( ft_v->x / 64 ) + (double)( ft_v->x % 64 ) / 64.;
	v_[Y] = (double)( ft_v->y / 64 ) + (double)( ft_v->y % 64 ) / 64.;
	v_[Z] = 0.;
      }

      /*!
       * Construct a Vertex from a 2D point.
       * \param p 2D array of doubles.
       * \param color_tess optional color tesselation object.
       * \param texture_tess optional texture tesselation object.
       */
      VertexInfo ( double p[2], ColorTess* color_tess = 0,
		   TextureTess* texture_tess = 0 )
	: color_tess_( color_tess ), texture_tess_( texture_tess )
      {
	v_[X] = p[X];
	v_[Y] = p[Y];
	v_[Z] = 0.;
      }

      /*!
       * Construct a Vertex from a 2D point.
       * \param x the X coordinate.
       * \param y the Y coordinate.
       * \param color_tess optional color tesselation object.
       * \param texture_tess optional texture tesselation object.
       */
      VertexInfo ( double x, double y, ColorTess* color_tess = 0,
		   TextureTess* texture_tess = 0 )
	: color_tess_( color_tess ), texture_tess_( texture_tess )
      {
	v_[X] = x;
	v_[Y] = y;
	v_[Z] = 0.;
      }

      //! Treat the Vertex like a vector: Normalize its length in the
      //! usual way.
      void normalize ( void )
      {
	double length = sqrt( v_[X] * v_[X] + v_[Y] * v_[Y] + v_[Z] * v_[Z] );
	v_[X] /= length;
	v_[Y] /= length;
	v_[Z] /= length;
      }
    };

    /*!
     * Buffers the last control point as the outline of a glyph is
     * decomposed.
     */
    VertexInfo last_vertex_;

    //! Normally, we will consider a list of vertices.
    typedef std::list< VertexInfo* > VertexInfoList;

    //! A convenience definition of the iterator over the list of vertices.
    typedef VertexInfoList::const_iterator VILCI;

    //! A convenience definition of the iterator over the list of vertices.
    typedef VertexInfoList::iterator VILI;

    /*!
     * As curves are decomposed out of the glyph, their vertices are passed
     * along to the GLU tessellation functions. These vertices have to
     * hang around until gluTessContourEnd is called.
     */
    VertexInfoList vertices_;

    //! As GLU tessellation proceeds, new contours open with every call
    //! to moveTo.
    bool contour_open_;

    //! The user can provide a ColorTess object which computes a color
    //! for each tesselated vertex.
    ColorTess* color_tess_;

    //! The user can provide a TextureTess object which computes texture
    //! coordinates for each tesselated vertex.
    TextureTess* texture_tess_;

  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Polygonal ( const char* filename, float point_size = 12,
			  FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Polygonal ( const FT_Byte* data_base, const FT_Long data_size,
			  float point_size = 12, FT_UInt resolution = 100);

    /*!
     * \param face open Freetype FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Polygonal ( FT_Face face, float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * The Polygonal destructor doesn't do anything in particular.
     */
    OGLFT_API virtual ~Polygonal ( void );

    /*!
     * TrueType and Type1 files describe the boundaries of glyphs with
     * quadratic and cubic curves, respectively. Since OpenGL can only really
     * draw straight lines, these curves have to be tessellated. The
     * number of steps used is fixed for all glyphs in the face,
     * but can be changed through this method. Other notes: This value is
     * only applicable for Outline, Filled and Solid styles. Changing this value
     * invalidates any cached display lists for glyphs in this face.
     *
     * \param tessellation_steps the number of steps to tessellate each curved
     * segment of a glyph outline.
     */
    OGLFT_API void setTessellationSteps ( unsigned int tessellation_steps );

    /*!
     * \return the number of steps used to tessellate curves in the
     * polygonal font types.
     */
    OGLFT_API unsigned int tessellationSteps ( void ) const { return tessellation_steps_; }

    /*!
     * Set the individual character rotation in the X direction.
     * \param character_rotation_x angle in degrees of the X rotation.
     */
    OGLFT_API void setCharacterRotationX ( GLfloat character_rotation_x );

    /*!
     * Set the individual character rotation in the Y direction.
     * \param character_rotation_y angle in degrees of the Y rotation.
     */
    OGLFT_API void setCharacterRotationY ( GLfloat character_rotation_y );

    /*!
     * Set the individual character rotation in the Z direction.
     * \param character_rotation_z angle in degrees of the Z rotation.
     */
    OGLFT_API void setCharacterRotationZ ( GLfloat character_rotation_z );

    /*!
     * \return the character rotation in the X direction.
     */
    OGLFT_API GLfloat characterRotationX ( void ) const { return character_rotation_.x_; }

    /*!
     * \return the character rotation in the Y direction.
     */
    OGLFT_API GLfloat characterRotationY ( void ) const { return character_rotation_.y_; }

    /*!
     * \return the character rotation in the Z direction.
     */
    OGLFT_API GLfloat characterRotationZ ( void ) const { return character_rotation_.z_; }

    /*!
     * Set an optional color tesselation object. Each tesselated vertex
     * is passed to this object, which returns a color for that position
     * in space.
     * \param color_tess the color tesselation object.
     */
    OGLFT_API void setColorTess ( ColorTess* color_tess );
    /*!
     * \return the color tesselation object.
     */
    OGLFT_API ColorTess* colorTess ( void ) const { return color_tess_; }
    /*!
     * Set an optional texture coordinate tesselation object. Each
     * tessellated vertex is passed to this object, which returns
     * texture coordinates for that position in space.
     * \param texture_tess the texture coordinate tesselation object.
     */
    OGLFT_API void setTextureTess ( TextureTess* texture_tess );
    /*!
     * \return the texture coordinate tesselation object.
     */
    OGLFT_API TextureTess* textureTess ( void ) const { return texture_tess_; }

    /*!
     * \return the height (i.e., line spacing) at the current character size.
     */
    OGLFT_API double height ( void ) const;
    
    OGLFT_API double underline_position ( void ) const;
    OGLFT_API double underline_thickness ( void ) const;

    /*!
     * Implement measuring a character in a polygonal face.
     * \param c the (latin1) character to measure
     * \return the bounding box of c.
     */
    OGLFT_API BBox measure ( unsigned char c );
#ifndef OGLFT_NO_QT
    /*!
     * Implement measuring a character in a polygonal face.
     * \param c the (UNICODE) character to measure
     * \return the bounding box of c.
     */
    OGLFT_API BBox measure ( const QChar c );
#endif /* OGLFT_NO_QT */
    /*!
     * Measure a string of characters. Note: currently, this merely
     * calls Face's measure routine.
     * \param s string of (latin1) characters to measure
     * \return the bounding box of s.
     */
    OGLFT_API BBox measure ( const char* s ) { return Face::measure( s ); }
#ifndef OGLFT_NO_QT
    /*!
     * Implement measuring a formatted number
     * \param format the format string
     * \param number to value to format
     * \return the bounding box of the formatted number
     */
    OGLFT_API BBox measure ( const QString& format, double number )
    { return Face::measure( format, number ); }
#endif /* OGLFT_NO_QT */

  private:
    void init ( void );
    void setCharSize ( void );
    void setRotationOffset ( void );
    GLuint compileGlyph ( FT_Face face, FT_UInt glyph_index );
  protected:
    void clearCaches ( void );
  };

  //! Render text as a polygon outline.
  /*!
   * \image html outline_class.png
   * Text is drawn as an outline of each glyph. The contours are extracted
   * from the font file through FreeType. FreeType is used to scale the
   * contours to a given size. Usually the outline is drawn in the foreground
   * color, however, you can specify a ColorTess object to provide a color
   * for each vertex individually. You can also use
   * the per-glyph display list functionality to alter the attributes
   * of each glyph.
   *
   * The only complexity to this style is selecting the point size. Since
   * the outlines are drawn as a polygon, they are subject to the MODELVIEW
   * transformation. The point size is nominally chosen to be the same as a
   * raster image generated at the given resolution. Some experimentation
   * with point size and resolution may be necessary to achieve the desired
   * results.
   */
  class Outline : public Polygonal {
  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Outline ( const char* filename, float point_size = 12,
			FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Outline ( const FT_Byte* data_base, const FT_Long data_size,
			float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param face open FreeType FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Outline ( FT_Face face, float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * The destructor doesn't do anything in particular.
     */
    ~Outline ( void );
  private:
    void init ( void );
    void renderGlyph ( FT_Face face, FT_UInt glyph_index );
    static int moveToCallback ( FT_Vector* to, Outline* outline );
    static int lineToCallback ( FT_Vector* to, Outline* outline );
    static int conicToCallback ( FT_Vector* control, FT_Vector* to, Outline* outline );
    static int cubicToCallback ( FT_Vector* control1, FT_Vector* control2,
				 FT_Vector* to, Outline* outline );
  };

  //! Render text as a filled polygons.
  /*!
   * \image html filled_class.png
   * Each glyph is drawn as a filled polygon. The contours are extracted
   * from the font file through FreeType. FreeType is used to scale the
   * contours to the given size. Then the GLU tessellation routines are used
   * to tessellate the contours into polygons (well, triangles). By default,
   * these are drawn in GL_FILL polygon mode, but any other polygon mode
   * can be specified.
   *
   * Usually, the polygons are drawn only in the
   * foreground color, however, you may supply ColorTess and TextureTess
   * objects which can alter the color or texture coordinates of each
   * vertex individually. You can also use
   * the per-glyph display list functionality to alter the attributes
   * of each glyph.
   *
   * The only complexity to this style is selecting the point size. Since
   * the glyphs are drawn as polygons, they are subject to the viewing and
   * modeling transformations. The point size is nominally chosen to be the same
   * as a raster image generated at the given resolution. Some experimentation
   * with point size and resolution may be necessary to achieve the desired
   * results.
   */
  class Filled : public Polygonal {
    //! 3D tessellation of glyphs is accomplished through the standard GLU
    //! routines
    GLUtesselator* tess_obj_;

    //! A place to store any extra vertices generated by the Combine callback
    VertexInfoList extra_vertices_;

  protected:
    //! Offset the glyph in the Z direction. Solely for the Solid subclass.
    //! Until I can figure out how to shift the glyph outside the context
    //! of this class, I guess this has got to stay (but it is redundant
    //! to extrusion_.depth_)
    GLfloat depth_offset_;

  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Filled ( const char* filename, float point_size = 12,
		       FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Filled ( const FT_Byte* data_base, const FT_Long data_size,
		       float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param face open FreeType FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Filled ( FT_Face face, float point_size = 12, FT_UInt resolution = 100 );
    /*!
     * The destructor deletes the GLU tessellation object allocated in
     * in the constructor.
     */
    OGLFT_API virtual ~Filled ( void );

    /*!
     * \return the list of extra vertices created by the GLU tessellation
     * combine callback.
     */
    OGLFT_API VertexInfoList& extraVertices ( void ) { return extra_vertices_; }

  protected:
    void renderGlyph ( FT_Face face, FT_UInt glyph_index );
  private:
    void init ( void );
    static int moveToCallback ( FT_Vector* to, Filled* filled );
    static int lineToCallback ( FT_Vector* to, Filled* filled );
    static int conicToCallback ( FT_Vector* control, FT_Vector* to, Filled* filled);
    static int cubicToCallback ( FT_Vector* control1, FT_Vector* control2,
				 FT_Vector* to, Filled* filled );
    static void vertexCallback ( VertexInfo* vertex );
    static void beginCallback ( GLenum which );
    static void endCallback ( void );
    static void combineCallback ( GLdouble coords[3], void* vertex_data[4],
				  GLfloat weight[4], void** out_data,
				  Filled* filled );
    static void errorCallback ( GLenum error_code );
  };

#ifndef OGLFT_NO_SOLID
  //! Render text as solid letters.
  /*!
   * \image html solid_class.png
   * Each glyph is drawn as a closed solid. The contours are extracted
   * from the font file through FreeType. FreeType is used to scale the
   * contours to the given size. The contours are passed to the GLE
   * tubing and extrusion library to create the sides of the solid.
   * Then the GLU tessellation routines are used
   * to tessellate the contours into polygons which are used to cap the sides.
   *
   * Currently, the solids are drawn only in the foreground color. However,
   * proper surface normals are computed so that the solids may be lighted.
   * Eventually, you'll be able to supply a color/texture
   * coordinate function to make glyphs more interesting. Note that you can use
   * the per-glyph display list functionality to alter each glyph individually.
   *
   * Another TODO item is to improve the interaction with GLE. Currently,
   * you can only create block solids. Eventually, we'll have the capability
   * add bevels and rounds to the edges of the solids and maybe even more
   * general extrusions (like, for example, the swooshing letters in the title
   * sequence of the Salkind's 1978 "Superman" movie).
   *
   * The only complexity to this style is selecting the point size. Since
   * the glyphs are drawn as a collection of polygons, they are subject to the
   * viewing and modeling transformations. The point size is nominally chosen
   * to be the same as a raster image generated at the given resolution.
   * Some experimentation with point size and resolution may be necessary to
   * achieve the desired results.
   */
  class Solid : public Filled {
  private:

    //! Callbacks for FreeType glyph decomposition into outlines (note: this
    //! has the same name as the variable in Polygonal, but it is distinct since
    //! the routines for the GLE contouring are different from the Filled
    //! GLU tessellation routines. This may be too confusing?)
    FT_Outline_Funcs interface_;

    //! For now, you can only get block extruded solids
    static const unsigned int N_POLYLINE_PTS = 4;

    //! Data for the gleExtrusion routine
    struct glePoint2D {
      double p_[2];
      glePoint2D ( double p[2] ) { p_[X] = p[X]; p_[Y] = p[Y]; }
      glePoint2D ( double x, double y ) { p_[X] = x; p_[Y] = y; }
      glePoint2D ( const VertexInfo& v ) { p_[X] = v.v_[X]; p_[Y] = v.v_[Y]; }
    };

    //! Collect all the output from GLE in one of these structures.
    struct {
      double depth_;
      struct {
	int x_, y_;
      } normal_sign_;
      std::vector< glePoint2D > contour_;
      std::vector< glePoint2D > contour_normals_;
      gleDouble up_[3];
      int n_polyline_pts_;
      gleDouble point_array_[N_POLYLINE_PTS][3];
    } extrusion_;

  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Solid ( const char* filename, float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Solid ( const FT_Byte* data_base, const FT_Long data_size,
		      float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param face open FreeType FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Solid ( FT_Face face, float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * The destructor doesn't do anything in particular.
     */
    OGLFT_API ~Solid ( void );
    /*!
     * Set the thickness of the solid
     * \param depth thickness of the solid in model units.
     */
    OGLFT_API void setDepth ( double depth );

    /*!
     * \return the solid extrusion depth.
     */
    OGLFT_API double depth ( void ) const { return extrusion_.depth_; }

  private:
    // It would be nice if C/C++ had real matrix notation (like Perl!)
    void assign ( gleDouble a[3], double x, double y, double z )
    {
      a[X] = x;
      a[Y] = y;
      a[Z] = z;
    }

    void init ( void );
    void renderGlyph ( FT_Face face, FT_UInt glyph_index );
    static int moveToCallback ( FT_Vector* to, Solid* solid );
    static int lineToCallback ( FT_Vector* to, Solid* solid );
    static int conicToCallback ( FT_Vector* control, FT_Vector* to, Solid* solid );
    static int cubicToCallback ( FT_Vector* control1, FT_Vector* control2,
				 FT_Vector* to, Solid* solid );
  };
#endif /* OGLFT_NO_SOLID */
  //! This is the base class of the raster styles: bitmap, grayscale and
  //! translucent.
  /*!
   * In the raster styles, FreeType's rasterizer is used to generate raster
   * images of each glyph.
   */
  class Raster : public Face {
  protected:
    //! Raster glyph can be rotated in the Z plane (in addition to the string
    //! rotation).
    GLfloat character_rotation_z_;
  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Raster ( const char* filename, float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Raster ( const FT_Byte* data_base, const FT_Long data_size,
		       float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param face open FreeType FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Raster ( FT_Face face, float point_size = 12, FT_UInt resolution = 100 );
    /*!
     * The destructor doesn't do anything in particular.
     */
    OGLFT_API virtual ~Raster ( void );
    /*!
     * Set the individual character rotation in the Z direction.
     * \param character_rotation_z angle in degrees of Z rotation.
     */
    OGLFT_API void setCharacterRotationZ ( GLfloat character_rotation_z );
    /*!
     * \return the character rotation in the Z direction.
     */
    OGLFT_API GLfloat characterRotationZ ( void ) const { return character_rotation_z_; }

    /*!
     * \return the height (i.e., line spacing) at the current character size.
     */
    OGLFT_API double height ( void ) const;
    
    OGLFT_API double underline_position ( void ) const;
    OGLFT_API double underline_thickness ( void ) const;

    /*!
     * Implement measuring a character in a raster face.
     * \param c the (latin1) character to measure
     * \return the bounding box of c.
     */
    OGLFT_API BBox measure ( unsigned char c );
#ifndef OGLFT_NO_QT
    /*!
     * Implement measuring a character in a raster face.
     * \param c the (UNICODE) character to measure
     * \return the bounding box of c.
     */
    OGLFT_API BBox measure ( const QChar c );
#endif /* OGLFT_NO_QT */
    /*!
     * Measure a string of characters. Note: currently, this merely
     * calls Face's measure routine.
     * \param s string of (latin1) characters to measure
     * \return the bounding box of s.
     */
    OGLFT_API BBox measure ( const char* s ) { return Face::measure( s ); }
#ifndef OGLFT_NO_QT
    /*!
     * Implement measuring a formatted number
     * \param format the format string
     * \param number to value to format
     * \return the bounding box of the formatted number
     */
    OGLFT_API BBox measure ( const QString& format, double number );
#endif /* OGLFT_NO_QT */

  private:
    void init ( void );
    GLuint compileGlyph ( FT_Face face, FT_UInt glyph_index );
    void setCharSize ( void );
    void setRotationOffset ( void );
    void clearCaches ( void );
  };

  //! Render text as a monochrome raster image.
  /*!
   * \image html monochrome_class.png
   * This is more or less the standard way in which text is intended to
   * be rendered in OpenGL. It uses the \c glBitmap call to draw a sequence
   * of monochrome bitmaps. Since FreeType is capable of rotating glyphs
   * created from faces based on vector outlines, you can rotate (in the Z plane)
   * both the text string as well as the individual characters in the string.
   *
   * Note: you \em must call
   * \code
   * glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
   * \endcode
   * before drawing in order for monochrome glyphs to be rendered properly.
   *
   * Another note: It is helpful to have the option
   * \c GL_RASTER_POSITION_UNCLIPPED_IBM available if you intend to draw text
   * at MODELVIEW based positions, otherwise if the initial text position is off
   * the screen, the entire image is clipped.
   */
  class Monochrome : public Raster {
  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Monochrome ( const char* filename, float point_size = 12,
			   FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Monochrome ( const FT_Byte* data_base, const FT_Long data_size,
			   float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param font open FreeType FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Monochrome ( FT_Face face, float point_size = 12, FT_UInt resolution = 100 );
    /*!
     * The destructor doesn't do anything in particular.
     */
    OGLFT_API ~Monochrome ( void );
  private:
    GLubyte* invertBitmap ( const FT_Bitmap& bitmap );
    void renderGlyph ( FT_Face face, FT_UInt glyph_index );
  };

  //! Render text as a grayscale raster image.
  /*!
   * \image html grayscale_class.png
   * The Grayscale style is similar to the Monochrome style. FreeType is used
   * to rasterize a glyph and this is then drawn on the screen using
   * \c glDrawPixels. The FreeType rasterization is done in anti-aliased mode.
   * When Grayscale draws the glyph image, the resulting text is blended
   * smoothly from the foreground color to the background color. The background
   * of the glyph is opaque, so this style works best over a solid background.
   *
   * Note: you \em must call
   * \code
   * glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
   * \endcode
   * before drawing in order for grayscale glyphs to be rendered properly.
   *
   * Another note: It is helpful to have the option
   * \c GL_RASTER_POSITION_UNCLIPPED_IBM available if you intend to draw text
   * at MODELVIEW based positions, otherwise if the initial text position is off
   * the screen, the entire image is clipped.
   */
  class Grayscale : public Raster {
  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Grayscale ( const char* filename, float point_size = 12,
			  FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Grayscale ( const FT_Byte* data_base, const FT_Long data_size,
			  float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param face open FreeType FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Grayscale ( FT_Face face, float point_size = 12, FT_UInt resolution = 100 );
    /*!
     * The destructor doesn't do anything in particular.
     */
    OGLFT_API ~Grayscale ( void );
  private:
    GLubyte* invertPixmap ( const FT_Bitmap& bitmap );
    void renderGlyph ( FT_Face face, FT_UInt glyph_index );
  };

  //! Render text as a translucent raster image.
  /*!
   * \image html translucent_class.png
   * The Translucent style is similar to the Grayscale style. FreeType is used
   * to rasterize a glyph and this is then drawn on the screen using
   * \c glDrawPixels. The FreeType rasterization is done in anti-aliased mode.
   * When Translucent draws the glyph image, the grayscale levels provided
   * by FreeType are used as Alpha values in the raster image. This allows
   * the glyphs to be smoothly blended into complicated backgrounds.
   *
   * Note: you \em must call
   * \code
   * glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
   * \endcode
   * before drawing in order for translucent glyphs to be rendered properly.
   * Additionally, you need to activate blending in order to achieve the
   * translucent effect:
   * \code
   * glEnable( GL_BLEND );
   * glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
   * \endcode
   *
   * Another note: It is helpful to have the option
   * \c GL_RASTER_POSITION_UNCLIPPED_IBM available if you intend to draw text
   * at MODELVIEW based positions, otherwise if the initial text position is off
   * the screen, the entire image is clipped.
   */
  class Translucent : public Raster {
  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Translucent ( const char* filename, float point_size = 12,
			    FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Translucent ( const FT_Byte* data_base, const FT_Long data_size,
			    float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param face open FreeType FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Translucent ( FT_Face face, float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * The destructor doesn't do anything in particular.
     */
    OGLFT_API ~Translucent ( void );

  private:
    GLubyte* invertPixmapWithAlpha ( const FT_Bitmap& bitmap );
    void renderGlyph ( FT_Face face, FT_UInt glyph_index );
  };

  //! This is the base class of the texture style.
  class Texture : public Face {
  protected:
    //! Angle of rotation of characters relative to text orientation.
    struct {
      bool active_; //!< Is character rotation non-zero? (faster than checking all
		    //!< the other values.)
      GLfloat x_,   //!< Angle of rotation in the X direction.
	y_,	    //!< Angle of rotation in the Y direction.
	z_;	    //!< Angle of rotation in the Z direction.
    } character_rotation_;

    /*!
     * The textured glyphs need a little bit more infrastructure to draw
     * since we have to remember the size of the texture object itself
     * (at least implicitly). Also, we don't want to create any more
     * texture objects than we have to, so they are always cached.
     */
    struct TextureInfo {
      GLuint texture_name_;  //!< A bound texture name is an integer in OpenGL.
      FT_Int left_bearing_,  //!< The left bearing of the transformed glyph.
	bottom_bearing_;     //!< The bottom bearing of the transformed glyph.
      int width_,	     //!< The 2**l width of the texture.
	height_;	     //!< The 2**m height of the texture.
      GLfloat texture_s_,    //!< The fraction of the texture width occupied
			     //!< by the glyph.
	texture_t_;	     //!< The fraction of the texture height occupied
                             //!< by the glyph.
      FT_Vector advance_;    //!< The advance vector of the transformed glyph.
    };

    //! Type of the cache of defined glyph to texture objects mapping.
    typedef std::map< FT_UInt, TextureInfo > GlyphTexObjs;

    //! A convenience definition of the iterator over the glyph to texture
    //! object map.
    typedef GlyphTexObjs::const_iterator GTOCI;

    //! A convenience definition of the iterator over the glyph to texture
    //! object map.
    typedef GlyphTexObjs::iterator GTOI;

    //! Cache of defined glyph texture objects.
    GlyphTexObjs glyph_texobjs_;

  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Texture ( const char* filename, float point_size = 12,
			FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Texture ( const FT_Byte* data_base, const FT_Long data_size,
			float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param face open FreeType FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API Texture ( FT_Face face, float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * The texture destructor doesn't really do anything.
     */
    OGLFT_API virtual ~Texture ( void );
    /*!
     * Set the individual character rotation in the X direction.
     * \param character_rotation_x angle in degrees of X rotation.
     */
    OGLFT_API void setCharacterRotationX ( GLfloat character_rotation_x );

    /*!
     * Set the individual character rotation in the Y direction.
     * \param character_rotation_y angle in degrees of Y rotation.
     */
    OGLFT_API void setCharacterRotationY ( GLfloat character_rotation_y );

    /*!
     * Set the individual character rotation in the Z direction.
     * \param character_rotation_z angle in degrees of Z rotation.
     */
    OGLFT_API void setCharacterRotationZ ( GLfloat character_rotation_z );

    /*!
     * \return the character rotation in the X direction.
     */
    OGLFT_API GLfloat characterRotationX ( void ) const { return character_rotation_.x_; }

    /*!
     * \return the character rotation in the Y direction.
     */
    OGLFT_API GLfloat characterRotationY ( void ) const { return character_rotation_.y_; }

    /*!
     * \return the character rotation in the Z direction.
     */
    OGLFT_API GLfloat characterRotationZ ( void ) const { return character_rotation_.z_; }

    /*!
     * \return the height (i.e., line spacing) at the current character size.
     */
    OGLFT_API double height ( void ) const;

    OGLFT_API double underline_position ( void ) const;
    OGLFT_API double underline_thickness ( void ) const;
    

    /*!
     * Implement measuring a character in a texture face.
     * \param c the (latin1) character to measure
     * \return the bounding box of c.
     */
    OGLFT_API BBox measure ( unsigned char c );
#ifndef OGLFT_NO_QT
    /*!
     * Implement measuring a character in a texture face.
     * \param c the (UNICODE) character to measure
     * \return the bounding box of c.
     */
    OGLFT_API BBox measure ( const QChar c );
#endif /* OGLFT_NO_QT */
    /*!
     * Measure a string of characters. Note: currently, this merely
     * calls Face's measure routine.
     * \param s string of (latin1) characters to measure
     * \return the bounding box of s.
     */
    OGLFT_API BBox measure ( const char* s ) { return Face::measure( s ); }
#ifndef OGLFT_NO_QT
    OGLFT_API BBox measure ( const QString& s )
    { return Face::measure( s ); }

    /*!
     * Implement measuring a formatted number
     * \param format the format string
     * \param number to value to format
     * \return the bounding box of the formatted number
     */
    OGLFT_API BBox measure ( const QString& format, double number )
    { return Face::measure( format, number ); }
#endif /* OGLFT_NO_QT */

  protected:
    /*!
     * OpenGL texture maps have to be a power of 2 in width and height (including
     * apparently 1 = 2**0 ). This function returns the next higher power of
     * 2 of the argument. If the argument is already a power of 2, you just
     * get that back.
     * \param a width or height of an image.
     * \return value of a rounded to nearest, higher power of 2.
     */
    unsigned int nearestPowerCeil ( unsigned int a );
    /*!
     * This is all that distinguishes the various texture styles. Each subclass
     * defines this method as appropriate. Once the texture is bound, it
     * is rendered the same in all cases.
     * \param face FT_Face containing the glyph to render.
     * \param glyph_index index of glyph in face.
     */
    virtual void bindTexture ( FT_Face face, FT_UInt glyph_index ) = 0;

  private:
    void init ( void );
    void setCharSize ( void );
    void setRotationOffset ( void );
    GLuint compileGlyph ( FT_Face face, FT_UInt glyph_index );
    void renderGlyph ( FT_Face face, FT_UInt glyph_index );
    void clearCaches ( void );
  };

  //! Render text as texture mapped monochrome quads.
  /*!
   * \image html texture_monochrome_class.png
   * This style is similar to the Monochrome raster style, except instead
   * of using \c glBitmap to draw the raster image, the image is used
   * as a texture map on a quad. If drawing is confined to the Z plane,
   * then you will see no difference between this style and Monochrome.
   * However, because the quad is a 3D object, it can be transformed
   * by the usual modeling operations; so, texture mapped glyphs can be
   * rotated in the X and Y directions as well as Z direction. Also,
   * if the viewing (or modeling) transformation has a non-unity scale or
   * shear, the glyphs will also be scaled or sheared (unlike the raster
   * styles). Also, there is no problem with clipping glyphs which lie
   * off the screen; texture mapped quads are properly clipped to the
   * screen boundary.
   *
   * If this is not convincing enough, the performance of texture mapped
   * glyphs is generally as good as or better than the equivalent
   * raster style (especially with hardware texture acceleration). However,
   * they do take up more memory space.
   *
   * Note: you \em must call
   * \code
   * glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
   * \endcode
   * before drawing in order for textured glyphs to be rendered properly.
   */
  class MonochromeTexture : public Texture {
  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API MonochromeTexture ( const char* filename, float point_size = 12,
				  FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API MonochromeTexture ( const FT_Byte* data_base, const FT_Long data_size,
				  float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param face open FreeType FT_Face
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API MonochromeTexture ( FT_Face face, float point_size = 12,
				  FT_UInt resolution = 100 );
    /*!
     * The monochrome texture destructor doesn't really do anything.
     */
    OGLFT_API ~MonochromeTexture ( void );
  private:
    GLubyte* invertBitmap ( const FT_Bitmap& bitmap, int* width, int* height );
    void bindTexture ( FT_Face face, FT_UInt glyph_index );
  };

  //! Render text as texture mapped grayscale quads.
  /*!
   * \image html texture_grayscale_class.png
   * This style is similar to the Grayscale raster style, except instead
   * of using \c glDrawPixels to draw the raster image, the image is used
   * as a texture map on a quad. If drawing is confined to the Z plane,
   * then you will see no difference between this style and Grayscale.
   * However, because the quad is a 3D object, it can be transformed
   * by the usual modeling operations; so, texture mapped glyphs can be
   * rotated in the X and Y directions as well as Z direction. Also,
   * if the viewing (or modeling) transformation has a non-unity scale or
   * shear, the glyphs will also be scaled or sheared (unlike the raster
   * styles). Also, there is no problem with clipping glyphs which lie
   * off the screen; texture mapped quads are properly clipped to the
   * screen boundary.
   *
   * If this is not convincing enough, the performance of texture mapped
   * glyphs is generally as good as or better than the equivalent
   * raster style (especially with hardware texture acceleration). However,
   * they do consume more memory space.
   *
   * Note: you \em must call
   * \code
   * glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
   * \endcode
   * before drawing in order for textured glyphs to be rendered properly.
   */
  class GrayscaleTexture : public Texture {
  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API GrayscaleTexture ( const char* filename, float point_size = 12,
				 FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API GrayscaleTexture ( const FT_Byte* data_base, const FT_Long data_size,
				 float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param face open FreeType FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API GrayscaleTexture ( FT_Face face, float point_size = 12,
				 FT_UInt resolution = 100 );
    /*!
     * The grayscale texture destructor doesn't really do anything.
     */
    OGLFT_API ~GrayscaleTexture ( void );
  private:
    GLubyte* invertPixmap ( const FT_Bitmap& bitmap, int* width, int* height );
    void bindTexture ( FT_Face face, FT_UInt glyph_index );
  };

  //! Render text as texture mapped translucent quads.
  /*!
   * \image html texture_translucent_class.png
   * This style is similar to the Translucent raster style, except instead
   * of using \c glDrawPixels to draw the raster image, the image is used
   * as a texture map on a quad. If drawing is confined to the Z plane,
   * then you will see no difference between this style and Translucent.
   * However, because the quad is a 3D object, it can be transformed
   * by the usual modeling operations; so, texture mapped glyphs can be
   * rotated in the X and Y directions as well as Z direction. Also,
   * if the viewing (or modeling) transformation has a non-unity scale or
   * shear, the glyphs will also be scaled or sheared (unlike the raster
   * styles). Also, there is no problem with clipping glyphs which lie
   * off the screen; texture mapped quads are properly clipped to the
   * screen boundary.
   *
   * If this is not convincing enough, the performance of texture mapped
   * glyphs is generally as good as or better than the equivalent
   * raster style (especially with hardware texture acceleration). However,
   * they do consume more memory space.
   *
   * Note: you \em must call
   * \code
   * glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
   * \endcode
   * before drawing in order for textured glyphs to be rendered properly.
   * Additionally, you need to activate blending in order to achieve the
   * translucent effect:
   * \code
   * glEnable( GL_BLEND );
   * glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
   * \endcode
   */
  class TranslucentTexture : public Texture {
  public:
    /*!
     * \param filename the filename which contains the font face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API TranslucentTexture ( const char* filename, float point_size = 12,
				   FT_UInt resolution = 100 );

    /*!
     * \param data_base the memory location (base pointer) which contains the font face.
     * \param data_size the size (in bytes) of the font data found at \ref data_base.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API TranslucentTexture ( const FT_Byte* data_base, const FT_Long data_size,
				   float point_size = 12, FT_UInt resolution = 100 );

    /*!
     * \param face open FreeType FT_Face.
     * \param point_size the initial point size of the font to generate. A point
     * is essentially 1/72th of an inch. Defaults to 12.
     * \param resolution the pixel density of the display in dots per inch (DPI).
     * Defaults to 100 DPI.
     */
    OGLFT_API TranslucentTexture ( FT_Face face, float point_size = 12,
				   FT_UInt resolution = 100 );
    /*!
     * The translucent texture destructor doesn't really do anything.
     */
    OGLFT_API ~TranslucentTexture ( void );
  private:
    GLubyte* invertPixmap ( const FT_Bitmap& bitmap, int* width, int* height );
    void bindTexture ( FT_Face face, FT_UInt glyph_index );
  };
} // Close OGLFT namespace
#endif /* OGLFT_H */