* include/freetype/ftmm.h, include/freetype/ftmodule.h, include/freetype/tttables.h, include/freetype/config/ftconfig.h, include/freetype/internal/ftobjs.h, include/freetype/internal/ftserv.h, include/freetype/internal/internal.h, include/freetype/internal/sfnt.h, include/freetype/internal/tttypes.h, include/freetype/internal/services/bdf.h, include/freetype/internal/services/glyfdict.h, include/freetype/internal/services/multmast.h, include/freetype/internal/services/postname.h, include/freetype/internal/services/sfnt.h, include/freetype/internal/services/xf86name.h, src/base/ftbdf.c, src/base/ftmm.c, src/base/ftobjs.c, src/base/ftxf86.c, src/bdf/bdfdrivr.c, src/cff/cffdrivr.c, src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/sfnt/sfdriver.c, src/truetype/ttdriver.c, src/type1/t1driver.c, src/type42/t42drivr.c: heavy internal modifications to introduce the concept of "module services". This is the first step towards a massive simplification of the engine's internals, in order to get rid of various numbers of hacks. Note that this changes will break source & binary compatibility for authors of external font drivers. Maybe 2.1.6 will be called 2.2.0 after all :-)
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
diff --git a/ChangeLog b/ChangeLog
index 8e76621..889870a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2003-09-11 David Turner <david@freetype.org>
+
+ * include/freetype/ftmm.h, include/freetype/ftmodule.h,
+ include/freetype/tttables.h, include/freetype/config/ftconfig.h,
+ include/freetype/internal/ftobjs.h,
+ include/freetype/internal/ftserv.h,
+ include/freetype/internal/internal.h,
+ include/freetype/internal/sfnt.h,
+ include/freetype/internal/tttypes.h,
+ include/freetype/internal/services/bdf.h,
+ include/freetype/internal/services/glyfdict.h,
+ include/freetype/internal/services/multmast.h,
+ include/freetype/internal/services/postname.h,
+ include/freetype/internal/services/sfnt.h,
+ include/freetype/internal/services/xf86name.h,
+ src/base/ftbdf.c, src/base/ftmm.c, src/base/ftobjs.c,
+ src/base/ftxf86.c, src/bdf/bdfdrivr.c, src/cff/cffdrivr.c,
+ src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/sfnt/sfdriver.c,
+ src/truetype/ttdriver.c, src/type1/t1driver.c, src/type42/t42drivr.c:
+
+ heavy internal modifications to introduce the concept of
+ "module services". This is the first step towards a massive
+ simplification of the engine's internals, in order to
+ get rid of various numbers of hacks.
+
+ Note that this changes will break source & binary compatibility
+ for authors of external font drivers.
+
+ Maybe 2.1.6 will be called 2.2.0 after all :-)
+
+
+
2003-09-09 David Turner <david@freetype.org>
* src/base/ftpfr.c, src/pfr/pfrtypes.h, src/pfr/pfrload.c,
diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h
index 4f5d7fe..44f7665 100644
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -192,6 +192,10 @@ FT_BEGIN_HEADER
#endif /* FT_SIZEOF_LONG == 8 */
+#define FT_BEGIN_STMNT do {
+#define FT_END_STMNT } while (0)
+#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
+
/*************************************************************************/
/* */
/* A 64-bit data type will create compilation problems if you compile */
diff --git a/include/freetype/ftmm.h b/include/freetype/ftmm.h
index 5e681b2..7f565be 100644
--- a/include/freetype/ftmm.h
+++ b/include/freetype/ftmm.h
@@ -100,21 +100,6 @@ FT_BEGIN_HEADER
/* */
- typedef FT_Error
- (*FT_Get_MM_Func)( FT_Face face,
- FT_Multi_Master* master );
-
- typedef FT_Error
- (*FT_Set_MM_Design_Func)( FT_Face face,
- FT_UInt num_coords,
- FT_Long* coords );
-
- typedef FT_Error
- (*FT_Set_MM_Blend_Func)( FT_Face face,
- FT_UInt num_coords,
- FT_Long* coords );
-
-
/*************************************************************************/
/* */
/* <Function> */
diff --git a/include/freetype/ftmodule.h b/include/freetype/ftmodule.h
index caf081d..8c70036 100644
--- a/include/freetype/ftmodule.h
+++ b/include/freetype/ftmodule.h
@@ -69,9 +69,7 @@ FT_BEGIN_HEADER
#define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES
#define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER
-
- typedef void
- (*FT_Module_Interface)( void );
+ typedef FT_Pointer FT_Module_Interface;
typedef FT_Error
(*FT_Module_Constructor)( FT_Module module );
@@ -79,7 +77,7 @@ FT_BEGIN_HEADER
typedef void
(*FT_Module_Destructor)( FT_Module module );
- typedef FT_Module_Interface
+ typedef FT_Module_Interface
(*FT_Module_Requester)( FT_Module module,
const char* name );
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 79319e8..2a7117c 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -34,7 +34,7 @@
#include FT_INTERNAL_GLYPH_LOADER_H
#include FT_INTERNAL_DRIVER_H
#include FT_INTERNAL_AUTOHINT_H
-#include FT_INTERNAL_OBJECT_H
+#include FT_INTERNAL_SERVICE_H
#ifdef FT_CONFIG_OPTION_INCREMENTAL
#include FT_INCREMENTAL_H
@@ -296,8 +296,6 @@ FT_BEGIN_HEADER
/* transform_flags :: Some flags used to classify the transform. */
/* Only used by the convenience functions. */
/* */
- /* postscript_name :: Postscript font name for this face. */
- /* */
/* incremental_interface :: */
/* If non-null, the interface through */
/* which glyph data and metrics are loaded */
@@ -315,7 +313,7 @@ FT_BEGIN_HEADER
FT_Vector transform_delta;
FT_Int transform_flags;
- const char* postscript_name;
+ FT_ServiceCacheRec services;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Incremental_InterfaceRec* incremental_interface;
@@ -754,8 +752,6 @@ FT_BEGIN_HEADER
FT_DebugHook_Func debug_hooks[4];
- FT_MetaClassRec meta_class;
-
} FT_LibraryRec;
diff --git a/include/freetype/internal/ftserv.h b/include/freetype/internal/ftserv.h
new file mode 100644
index 0000000..5e2c32f
--- /dev/null
+++ b/include/freetype/internal/ftserv.h
@@ -0,0 +1,139 @@
+#ifndef __FT_SERVICE_H__
+#define __FT_SERVICE_H__
+
+ /*
+ * each module can export one or more 'services'. Each service is
+ * identified by a constant string, and modeled by a pointer, which
+ * generally corresponds to a structure containing function pointers.
+ *
+ * note that a service's data cannot be a mere function
+ * pointer. that's because in C, function pointers might be implemented
+ * differently than data pointers (e.g. 48 bits instead of 32)
+ */
+
+ /* this macro is used to lookup a service from a face's driver module
+ *
+ * ptr :: variable that receives the service pointer. will be NULL
+ * if not found
+ *
+ * id :: a string describing the service. the list of valid service
+ * identifiers is below
+ *
+ * face :: the source face handle
+ */
+#define FT_FACE_FIND_SERVICE(ptr,face,id) \
+ FT_BEGIN_STMNT \
+ FT_Module module = FT_MODULE(FT_FACE(face)->driver); \
+ \
+ (ptr) = NULL; \
+ if ( module->clazz->get_interface ) \
+ (ptr) = module->clazz->get_interface( module, id ); \
+ FT_END_STMNT
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** S E R V I C E D E S C R I P T O R S *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* the following structure is used to _describe_ a given service
+ * to the library. this is useful to build simple static service lists..
+ */
+ typedef struct FT_ServiceDescRec_
+ {
+ const char* serv_id; /* service name */
+ const void* serv_data; /* service pointer/data */
+
+ } FT_ServiceDescRec;
+
+ typedef const FT_ServiceDescRec* FT_ServiceDesc;
+
+
+ /* parse a list of FT_ServiceDescRec descriptors and look for
+ * a specific service by id. Note that the last element in the
+ * array must be { NULL, NULL }, and that the function should
+ * return NULL if the service isn't available
+ *
+ * this function can be used by modules to implement their "get_service"
+ * method
+ */
+ FT_BASE( FT_Pointer )
+ ft_service_list_lookup( FT_ServiceDesc service_descriptors,
+ const char* service_id );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** S E R V I C E S C A C H E *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* this structure is used to store a cache for several often-used
+ * services. It is the type of 'face->internal->services'. You
+ * should only use FT_FACE_LOOKUP_SERVICE to access it
+ *
+ * all fields should have the type FT_Pointer to relax compilation
+ * dependencies. We assume the developer isn't completely stupid
+ *
+ *
+ */
+ typedef struct FT_ServiceCacheRec_
+ {
+ FT_Pointer postscript_name;
+ FT_Pointer multi_masters;
+ FT_Pointer glyph_dict;
+
+ } FT_ServiceCacheRec, *FT_ServiceCache;
+
+ /* a magic number used within the services cache
+ */
+#define FT_SERVICE_UNAVAILABLE ((FT_Pointer)-2) /* magic number */
+
+ /* this macro is used to lookup a service from a face's driver module
+ * using its cache.
+ *
+ * ptr :: variable receiving the service data. NULL if not available
+ * face :: source face handle containing the cache
+ * field :: field name in cache
+ * id :: service id
+ *
+ */
+#define FT_FACE_LOOKUP_SERVICE(face,ptr,field,id) \
+ FT_BEGIN_STMNT \
+ (ptr) = FT_FACE(face)->internal->services. field ; \
+ if ( (ptr) == FT_SERVICE_UNAVAILABLE ) \
+ (ptr) = NULL; \
+ else if ( (ptr) == NULL ) \
+ { \
+ FT_FACE_FIND_SERVICE( ptr, face, id ); \
+ \
+ FT_FACE(face)->internal->services. field = \
+ (FT_Pointer)( (ptr) != NULL \
+ ? (ptr) \
+ : FT_SERVICE_UNAVAILABLE ); \
+ } \
+ FT_END_STMNT
+
+
+ /* A macro used to define new service structure types
+ */
+
+#define FT_DEFINE_SERVICE( name ) \
+ typedef struct FT_Service_ ## name ## Rec_ FT_Service_ ## name ## Rec; \
+ typedef struct FT_Service_ ## name ## Rec_ const * FT_Service_ ## name ; \
+ struct FT_Service_ ## name ## Rec_
+
+ /* */
+
+#define FT_SERVICE_MULTIPLE_MASTERS_H <freetype/internal/services/multmast.h>
+#define FT_SERVICE_POSTSCRIPT_NAME_H <freetype/internal/services/postname.h>
+#define FT_SERVICE_GLYPH_DICT_H <freetype/internal/services/glyfdict.h>
+#define FT_SERVICE_BDF_H <freetype/internal/services/bdf.h>
+#define FT_SERVICE_XFREE86_NAME_H <freetype/internal/services/xf86name.h>
+
+#endif /* __FT_SERVICE_H__ */
diff --git a/include/freetype/internal/internal.h b/include/freetype/internal/internal.h
index 872f6ac..4037866 100644
--- a/include/freetype/internal/internal.h
+++ b/include/freetype/internal/internal.h
@@ -27,16 +27,13 @@
#define FT_INTERNAL_OBJECTS_H <freetype/internal/ftobjs.h>
#define FT_INTERNAL_STREAM_H <freetype/internal/ftstream.h>
#define FT_INTERNAL_MEMORY_H <freetype/internal/ftmemory.h>
-#define FT_INTERNAL_EXTENSION_H <freetype/internal/ftextend.h>
#define FT_INTERNAL_DEBUG_H <freetype/internal/ftdebug.h>
#define FT_INTERNAL_CALC_H <freetype/internal/ftcalc.h>
#define FT_INTERNAL_DRIVER_H <freetype/internal/ftdriver.h>
-#define FT_INTERNAL_EXTEND_H <freetype/internal/ftextend.h>
#define FT_INTERNAL_TRACE_H <freetype/internal/fttrace.h>
#define FT_INTERNAL_GLYPH_LOADER_H <freetype/internal/ftgloadr.h>
#define FT_INTERNAL_SFNT_H <freetype/internal/sfnt.h>
-#define FT_INTERNAL_HASH_H <freetype/internal/fthash.h>
-#define FT_INTERNAL_OBJECT_H <freetype/internal/ftobject.h>
+#define FT_INTERNAL_SERVICE_H <freetype/internal/ftserv.h>
#define FT_INTERNAL_TRUETYPE_TYPES_H <freetype/internal/tttypes.h>
#define FT_INTERNAL_TYPE1_TYPES_H <freetype/internal/t1types.h>
diff --git a/include/freetype/internal/services/bdf.h b/include/freetype/internal/services/bdf.h
new file mode 100644
index 0000000..6ea4573
--- /dev/null
+++ b/include/freetype/internal/services/bdf.h
@@ -0,0 +1,30 @@
+#ifndef __FT_SERVICE_BDF_H__
+#define __FT_SERVICE_BDF_H__
+
+#include FT_INTERNAL_SERVICE_H
+
+FT_BEGIN_HEADER
+
+#define FT_SERVICE_ID_BDF "bdf"
+
+ typedef FT_Error (*FT_BDF_GetCharsetIdFunc)
+ ( FT_Face face,
+ const char* *acharset_encoding,
+ const char* *acharset_registry );
+
+ typedef FT_Error (*FT_BDF_GetPropertyFunc)
+ ( FT_Face face,
+ const char* prop_name,
+ BDF_PropertyRec *aproperty );
+
+ FT_DEFINE_SERVICE( BDF )
+ {
+ FT_BDF_GetCharsetIdFunc get_charset_id;
+ FT_BDF_GetPropertyFunc get_property;
+ };
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* __FT_SERVICE_BDF_H__ */
diff --git a/include/freetype/internal/services/glyfdict.h b/include/freetype/internal/services/glyfdict.h
new file mode 100644
index 0000000..b292e90
--- /dev/null
+++ b/include/freetype/internal/services/glyfdict.h
@@ -0,0 +1,36 @@
+#ifndef __FT_SERVICE_GLYPH_DICT_H__
+#define __FT_SERVICE_GLYPH_DICT_H__
+
+#include FT_INTERNAL_SERVICE_H
+
+FT_BEGIN_HEADER
+
+ /*
+ * a service used to retrieve glyph names, as well as to find the
+ * index of a given glyph name in a font.
+ *
+ */
+
+#define FT_SERVICE_ID_GLYPH_DICT "glyph-dict"
+
+ typedef FT_Error (*FT_GlyphDict_GetNameFunc)
+ ( FT_Face face,
+ FT_UInt glyph_index,
+ FT_Pointer buffer,
+ FT_UInt buffer_max );
+
+ typedef FT_UInt (*FT_GlyphDict_NameIndexFunc)
+ ( FT_Face face,
+ FT_String* glyph_name );
+
+ FT_DEFINE_SERVICE( GlyphDict )
+ {
+ FT_GlyphDict_GetNameFunc get_name;
+ FT_GlyphDict_NameIndexFunc name_index; /* optional */
+ };
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* __FT_SERVICE_GLYPH_DICT_H__ */
diff --git a/include/freetype/internal/services/multmast.h b/include/freetype/internal/services/multmast.h
new file mode 100644
index 0000000..6371d31
--- /dev/null
+++ b/include/freetype/internal/services/multmast.h
@@ -0,0 +1,37 @@
+#ifndef __FT_SERVICE_MULTIPLE_MASTERS_H__
+#define __FT_SERVICE_MULTIPLE_MASTERS_H__
+
+#include FT_INTERNAL_SERVICE_H
+
+ /*
+ * a service used to manage multiple-masters data in a given face
+ *
+ * see the related APIs in "ftmm.h" / FT_MULTIPLE_MASTERS_H
+ *
+ */
+
+
+ typedef FT_Error
+ (*FT_Get_MM_Func)( FT_Face face,
+ FT_Multi_Master* master );
+
+ typedef FT_Error
+ (*FT_Set_MM_Design_Func)( FT_Face face,
+ FT_UInt num_coords,
+ FT_Long* coords );
+
+ typedef FT_Error
+ (*FT_Set_MM_Blend_Func)( FT_Face face,
+ FT_UInt num_coords,
+ FT_Long* coords );
+
+#define FT_SERVICE_ID_MULTI_MASTERS "multi-masters"
+
+ FT_DEFINE_SERVICE( MultiMasters )
+ {
+ FT_Get_MM_Func get_mm;
+ FT_Set_MM_Design_Func set_mm_design;
+ FT_Set_MM_Blend_Func set_mm_blend;
+ };
+
+#endif /* __FT_SERVICE_MULTIPLE_MASTERS_H__ */
diff --git a/include/freetype/internal/services/postname.h b/include/freetype/internal/services/postname.h
new file mode 100644
index 0000000..2bc740f
--- /dev/null
+++ b/include/freetype/internal/services/postname.h
@@ -0,0 +1,30 @@
+#ifndef __FT_SERVICE_POSTSCRIPT_NAME_H__
+#define __FT_SERVICE_POSTSCRIPT_NAME_H__
+
+#include FT_INTERNAL_SERVICE_H
+
+FT_BEGIN_HEADER
+
+ /*
+ * a trivial service used to retrieve the Postscript name of a given
+ * font when available. The "get_name" field should never be NULL
+ *
+ * the correponding function can return NULL to indicate that the
+ * Postscript name is not available.
+ *
+ * the name is owned by the face and will be destroyed with it
+ *
+ */
+
+#define FT_SERVICE_ID_POSTSCRIPT_NAME "postscript-name"
+
+ typedef const char* (*FT_PsName_GetFunc)( FT_Face face );
+
+ FT_DEFINE_SERVICE( PsName )
+ {
+ FT_PsName_GetFunc get_ps_name;
+ };
+
+FT_END_HEADER
+
+#endif /* __FT_SERVICE_POSTSCRIPT_NAME_H__ */
diff --git a/include/freetype/internal/services/sfnt.h b/include/freetype/internal/services/sfnt.h
new file mode 100644
index 0000000..82cdead
--- /dev/null
+++ b/include/freetype/internal/services/sfnt.h
@@ -0,0 +1,42 @@
+#ifndef __FT_SERVICE_SFNT_H__
+#define __FT_SERVICE_SFNT_H__
+
+#include FT_INTERNAL_SERVICE_H
+#include FT_TRUETYPE_TABLES_H
+
+FT_BEGIN_HEADER
+
+ /*
+ * SFNT table loading service
+ *
+ */
+
+#define FT_SERVICE_ID_SFNT_TABLE "sfnt-table"
+
+ /* used to implement FT_Load_Sfnt_Table()
+ */
+ typedef FT_Error
+ (*FT_SFNT_TableLoadFunc)( FT_Face face,
+ FT_ULong tag,
+ FT_Long offset,
+ FT_Byte* buffer,
+ FT_ULong* length );
+
+ /* used to implement FT_Get_Sfnt_Table()
+ */
+ typedef void*
+ (*FT_SFNT_TableGetFunc)( FT_Face face,
+ FT_Sfnt_Tag tag );
+
+
+ FT_DEFINE_SERVICE( SFNT_Table )
+ {
+ FT_SFNT_TableLoadFunc load_table;
+ FT_SFNT_TableGetFunc get_table;
+ };
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* __FT_SERVICE_SFNT_H__ */
diff --git a/include/freetype/internal/services/xf86name.h b/include/freetype/internal/services/xf86name.h
new file mode 100644
index 0000000..a9a3010
--- /dev/null
+++ b/include/freetype/internal/services/xf86name.h
@@ -0,0 +1,31 @@
+#ifndef __FT_SERVICE_XF86_NAME_H__
+#define __FT_SERVICE_XF86_NAME_H__
+
+#include FT_INTERNAL_SERVICE_H
+
+FT_BEGIN_HEADER
+
+ /*
+ * a trivial service used to return the name of a face's font driver,
+ * according to the XFree86 nomenclature. Note that the service data
+ * is a simple constant string pointer
+ *
+ */
+
+#define FT_SERVICE_ID_XF86_NAME "xf86-driver-name"
+
+#define FT_XF86_FORMAT_TRUETYPE "TrueType"
+#define FT_XF86_FORMAT_TYPE_1 "Type 1"
+#define FT_XF86_FORMAT_BDF "BDF"
+#define FT_XF86_FORMAT_PCF "PCF"
+#define FT_XF86_FORMAT_TYPE_42 "Type 42"
+#define FT_XF86_FORMAT_CID "CID Type 1"
+#define FT_XF86_FORMAT_CFF "CFF"
+#define FT_XF86_FORMAT_PFR "PFR"
+#define FT_XF86_FORMAT_WINFNT "Windows FNT"
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* __FT_SERVICE_XF86_NAME_H__ */
diff --git a/include/freetype/internal/sfnt.h b/include/freetype/internal/sfnt.h
index 10b2275..b89132b 100644
--- a/include/freetype/internal/sfnt.h
+++ b/include/freetype/internal/sfnt.h
@@ -125,10 +125,6 @@ FT_BEGIN_HEADER
(*TT_Done_Face_Func)( TT_Face face );
- typedef FT_Module_Interface
- (*SFNT_Get_Interface_Func)( FT_Module module,
- const char* func_interface );
-
/*************************************************************************/
/* */
@@ -457,21 +453,6 @@ FT_BEGIN_HEADER
(*TT_Free_Table_Func)( TT_Face face );
- /*************************************************************************/
- /* */
- /* <FuncType> */
- /* SFNT_Load_Table_Func */
- /* */
- /* <Description> */
- /* Loads a given SFNT table into memory. */
- /* */
- typedef FT_Error
- (*SFNT_Load_Table_Func)( FT_Face face,
- FT_ULong tag,
- FT_Long offset,
- FT_Byte* buffer,
- FT_ULong* length );
-
/*************************************************************************/
/* */
@@ -492,7 +473,7 @@ FT_BEGIN_HEADER
TT_Init_Face_Func init_face;
TT_Load_Face_Func load_face;
TT_Done_Face_Func done_face;
- SFNT_Get_Interface_Func get_interface;
+ FT_Module_Requester get_interface;
TT_Load_Any_Func load_any;
TT_Load_SFNT_HeaderRec_Func load_sfnt_header;
diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h
index 736d907..d002703 100644
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -1576,6 +1576,8 @@ FT_BEGIN_HEADER
FT_Generic extra;
+ const char* postscript_name;
+
} TT_FaceRec;
diff --git a/include/freetype/tttables.h b/include/freetype/tttables.h
index 2d2e63c..8c67447 100644
--- a/include/freetype/tttables.h
+++ b/include/freetype/tttables.h
@@ -566,11 +566,6 @@ FT_BEGIN_HEADER
/* */
- /* internal use only */
- typedef void*
- (*FT_Get_Sfnt_Table_Func)( FT_Face face,
- FT_Sfnt_Tag tag );
-
/*************************************************************************/
/* */
diff --git a/src/base/ftbdf.c b/src/base/ftbdf.c
index 63e3071..df6091e 100644
--- a/src/base/ftbdf.c
+++ b/src/base/ftbdf.c
@@ -19,25 +19,7 @@
#include <ft2build.h>
#include FT_INTERNAL_BDF_TYPES_H
#include FT_INTERNAL_OBJECTS_H
-
-
- static FT_Bool
- test_font_type( FT_Face face,
- const char* name )
- {
- if ( face && face->driver )
- {
- FT_Module driver = (FT_Module)face->driver;
-
-
- if ( driver->clazz && driver->clazz->module_name )
- {
- if ( ft_strcmp( driver->clazz->module_name, name ) == 0 )
- return 1;
- }
- }
- return 0;
- }
+#include FT_SERVICE_BDF_H
FT_EXPORT_DEF( FT_Error )
@@ -52,19 +34,18 @@
error = FT_Err_Invalid_Argument;
- if ( test_font_type( face, "bdf" ) )
+ if ( face )
{
- BDF_Public_Face bdf_face = (BDF_Public_Face)face;
-
-
- encoding = (const char*) bdf_face->charset_encoding;
- registry = (const char*) bdf_face->charset_registry;
- error = 0;
+ FT_Service_BDF service;
+
+ FT_FACE_FIND_SERVICE( service, face, FT_SERVICE_ID_BDF );
+
+ if ( service && service->get_charset_id )
+ error = service->get_charset_id( face, &encoding, ®istry );
}
-
if ( acharset_encoding )
*acharset_encoding = encoding;
-
+
if ( acharset_registry )
*acharset_registry = registry;
@@ -84,22 +65,16 @@
aproperty->type = BDF_PROPERTY_TYPE_NONE;
- if ( face != NULL && face->driver != NULL )
+ if ( face )
{
- FT_Driver driver = face->driver;
- BDF_GetPropertyFunc func;
-
-
- if ( driver->root.clazz->get_interface )
- {
- func = (BDF_GetPropertyFunc)driver->root.clazz->get_interface(
- FT_MODULE( driver ), "get_bdf_property" );
- if ( func )
- error = func( face, prop_name, aproperty );
- }
+ FT_Service_BDF service;
+
+ FT_FACE_FIND_SERVICE( service, face, FT_SERVICE_ID_BDF );
+
+ if ( service && service->get_property )
+ error = service->get_property( face, prop_name, aproperty );
}
-
- return error;
+ return error;
}
diff --git a/src/base/ftmm.c b/src/base/ftmm.c
index 229a043..a717e55 100644
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -19,6 +19,7 @@
#include <ft2build.h>
#include FT_MULTIPLE_MASTERS_H
#include FT_INTERNAL_OBJECTS_H
+#include FT_SERVICE_MULTIPLE_MASTERS_H
/*************************************************************************/
@@ -30,33 +31,46 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_mm
-
- /* documentation is in ftmm.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_Multi_Master( FT_Face face,
- FT_Multi_Master *amaster )
+ static FT_Error
+ ft_face_get_mm_service( FT_Face face,
+ FT_Service_MultiMasters *aservice )
{
FT_Error error;
-
-
+
+ *aservice = NULL;
+
if ( !face )
return FT_Err_Invalid_Face_Handle;
-
+
error = FT_Err_Invalid_Argument;
-
+
if ( FT_HAS_MULTIPLE_MASTERS( face ) )
{
- FT_Driver driver = face->driver;
- FT_Get_MM_Func func;
+ FT_FACE_LOOKUP_SERVICE( face, *aservice,
+ multi_masters,
+ FT_SERVICE_ID_MULTI_MASTERS );
+ }
+ return error;
+ }
- func = (FT_Get_MM_Func)driver->root.clazz->get_interface(
- FT_MODULE( driver ), "get_mm" );
- if ( func )
- error = func( face, amaster );
- }
+ /* documentation is in ftmm.h */
+ FT_EXPORT_DEF( FT_Error )
+ FT_Get_Multi_Master( FT_Face face,
+ FT_Multi_Master *amaster )
+ {
+ FT_Error error;
+ FT_Service_MultiMasters service;
+
+ error = ft_face_get_mm_service( face, &service );
+ if ( !error )
+ {
+ error = FT_Err_Invalid_Argument;
+ if ( service->get_mm )
+ error = service->get_mm( face, amaster );
+ }
+
return error;
}
@@ -68,26 +82,16 @@
FT_UInt num_coords,
FT_Long* coords )
{
- FT_Error error;
+ FT_Error error;
+ FT_Service_MultiMasters service;
-
- if ( !face )
- return FT_Err_Invalid_Face_Handle;
-
- error = FT_Err_Invalid_Argument;
-
- if ( FT_HAS_MULTIPLE_MASTERS( face ) )
+ error = ft_face_get_mm_service( face, &service );
+ if ( !error )
{
- FT_Driver driver = face->driver;
- FT_Set_MM_Design_Func func;
-
-
- func = (FT_Set_MM_Design_Func)driver->root.clazz->get_interface(
- FT_MODULE( driver ), "set_mm_design" );
- if ( func )
- error = func( face, num_coords, coords );
+ error = FT_Err_Invalid_Argument;
+ if ( service->set_mm_design )
+ error = service->set_mm_design( face, num_coords, coords );
}
-
return error;
}
@@ -99,28 +103,17 @@
FT_UInt num_coords,
FT_Fixed* coords )
{
- FT_Error error;
+ FT_Error error;
+ FT_Service_MultiMasters service;
-
- if ( !face )
- return FT_Err_Invalid_Face_Handle;
-
- error = FT_Err_Invalid_Argument;
-
- if ( FT_HAS_MULTIPLE_MASTERS( face ) )
+ error = ft_face_get_mm_service( face, &service );
+ if ( !error )
{
- FT_Driver driver = face->driver;
- FT_Set_MM_Blend_Func func;
-
-
- func = (FT_Set_MM_Blend_Func)driver->root.clazz->get_interface(
- FT_MODULE( driver ), "set_mm_blend" );
- if ( func )
- error = func( face, num_coords, coords );
+ error = FT_Err_Invalid_Argument;
+ if ( service->set_mm_blend )
+ error = service->set_mm_blend( face, num_coords, coords );
}
-
return error;
}
-
/* END */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 8fdcc88..e50011f 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -27,6 +27,29 @@
#include FT_TRUETYPE_IDS_H
#include FT_OUTLINE_H
+#include FT_SERVICE_POSTSCRIPT_NAME_H
+#include FT_SERVICE_GLYPH_DICT_H
+
+ FT_BASE_DEF( FT_Pointer )
+ ft_service_list_lookup( FT_ServiceDesc service_descriptors,
+ const char* service_id )
+ {
+ FT_Pointer result = NULL;
+ FT_ServiceDesc desc = service_descriptors;
+
+ if ( desc && service_id )
+ {
+ for ( ; desc->serv_id != NULL; desc++ )
+ {
+ if ( ft_strcmp( desc->serv_id, service_id ) == 0 )
+ {
+ result = (FT_Pointer) desc->serv_data;
+ break;
+ }
+ }
+ }
+ return result;
+ }
FT_BASE_DEF( void )
ft_validator_init( FT_Validator valid,
@@ -704,7 +727,6 @@
/* get rid of it */
if ( face->internal )
{
- FT_FREE( face->internal->postscript_name );
FT_FREE( face->internal );
}
FT_FREE( face );
@@ -1154,14 +1176,14 @@
if ( FT_ALLOC( pfb_data, (FT_Long)pfb_len + 2 ) )
goto Exit;
- pfb_pos = 0;
- pfb_data[pfb_pos++] = 0x80;
- pfb_data[pfb_pos++] = 1; /* Ascii section */
- pfb_lenpos = pfb_pos;
- pfb_data[pfb_pos++] = 0; /* 4-byte length, fill in later */
- pfb_data[pfb_pos++] = 0;
- pfb_data[pfb_pos++] = 0;
- pfb_data[pfb_pos++] = 0;
+ pfb_data[0] = 0x80;
+ pfb_data[1] = 1; /* Ascii section */
+ pfb_data[2] = 0; /* 4-byte length, fill in later */
+ pfb_data[3] = 0;
+ pfb_data[4] = 0;
+ pfb_data[5] = 0;
+ pfb_pos = 7;
+ pfb_lenpos = 2;
len = 0;
type = 1;
@@ -1179,10 +1201,10 @@
len += rlen;
else
{
- pfb_data[pfb_lenpos ] = len & 0xFF;
- pfb_data[pfb_lenpos + 1] = ( len >> 8 ) & 0xFF;
- pfb_data[pfb_lenpos + 2] = ( len >> 16 ) & 0xFF;
- pfb_data[pfb_lenpos + 3] = ( len >> 24 ) & 0xFF;
+ pfb_data[pfb_lenpos ] = (FT_Byte)( len );
+ pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 );
+ pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 );
+ pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 );
if ( ( flags >> 8 ) == 5 ) /* End of font mark */
break;
@@ -1192,8 +1214,8 @@
type = flags >> 8;
len = rlen;
- pfb_data[pfb_pos++] = type;
- pfb_lenpos = pfb_pos;
+ pfb_data[pfb_pos++] = (FT_Byte) type;
+ pfb_lenpos = (FT_Byte) pfb_pos;
pfb_data[pfb_pos++] = 0; /* 4-byte length, fill in later */
pfb_data[pfb_pos++] = 0;
pfb_data[pfb_pos++] = 0;
@@ -1207,10 +1229,10 @@
pfb_data[pfb_pos++] = 0x80;
pfb_data[pfb_pos++] = 3;
- pfb_data[pfb_lenpos ] = len & 0xFF;
- pfb_data[pfb_lenpos + 1] = ( len >> 8 ) & 0xFF;
- pfb_data[pfb_lenpos + 2] = ( len >> 16 ) & 0xFF;
- pfb_data[pfb_lenpos + 3] = ( len >> 24 ) & 0xFF;
+ pfb_data[pfb_lenpos ] = (FT_Byte)( len );
+ pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 );
+ pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 );
+ pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 );
return open_face_from_buffer( library,
pfb_data,
@@ -1320,7 +1342,8 @@
unsigned char head[16], head2[16];
FT_Long rdata_pos, map_pos, rdata_len, map_len;
int allzeros, allmatch, i, cnt, subcnt;
- FT_Long type_list, tag, rpos, junk;
+ FT_Long type_list, rpos, junk;
+ FT_ULong tag;
error = FT_Stream_Seek( stream, resource_offset );
@@ -1354,7 +1377,7 @@
if ( error )
goto Exit;
- head2[15] = head[15] + 1; /* make it be different */
+ head2[15] = (FT_Byte)(head[15] + 1); /* make it be different */
error = FT_Stream_Read( stream, (FT_Byte*)head2, 16 );
if ( error )
@@ -2368,23 +2391,33 @@
if ( face && FT_HAS_GLYPH_NAMES( face ) )
{
- /* now, lookup for glyph name */
- FT_Driver driver = face->driver;
- FT_Module_Class* clazz = FT_MODULE_CLASS( driver );
-
-
- if ( clazz->get_interface )
- {
- FT_Face_GetGlyphNameIndexFunc requester;
+ FT_Service_GlyphDict service;
+#if 0
+ FT_FACE_LOOKUP_SERVICE( face, service,
+ glyph_dict,
+ FT_SERVICE_ID_GLYPH_DICT );
+#else
+ service = face->internal->services . glyph_dict;
+ if ( service == FT_SERVICE_UNAVAILABLE )
+ service = NULL;
+ else if ( service == NULL )
+ {
+ FT_Module module = FT_MODULE(face->driver);
+
+ if ( module->clazz->get_interface )
+ service = module->clazz->get_interface( module,
+ FT_SERVICE_ID_GLYPH_DICT );
+
+ face->internal->services . glyph_dict = service != NULL
+ ? service
+ : FT_SERVICE_UNAVAILABLE;
+ }
- requester = (FT_Face_GetGlyphNameIndexFunc)clazz->get_interface(
- FT_MODULE( driver ), "name_index" );
- if ( requester )
- result = requester( face, glyph_name );
+#endif
+ if ( service && service->name_index )
+ result = service->name_index( face, glyph_name );
}
- }
-
return result;
}
@@ -2408,20 +2441,15 @@
glyph_index <= (FT_UInt)face->num_glyphs &&
FT_HAS_GLYPH_NAMES( face ) )
{
- /* now, lookup for glyph name */
- FT_Driver driver = face->driver;
- FT_Module_Class* clazz = FT_MODULE_CLASS( driver );
+ FT_Service_GlyphDict service;
+ FT_FACE_LOOKUP_SERVICE( face, service,
+ glyph_dict,
+ FT_SERVICE_ID_GLYPH_DICT );
- if ( clazz->get_interface )
+ if ( service && service->get_name )
{
- FT_Face_GetGlyphNameFunc requester;
-
-
- requester = (FT_Face_GetGlyphNameFunc)clazz->get_interface(
- FT_MODULE( driver ), "glyph_name" );
- if ( requester )
- error = requester( face, glyph_index, buffer, buffer_max );
+ error = service->get_name( face, glyph_index, buffer, buffer_max );
}
}
@@ -2440,24 +2468,16 @@
if ( !face )
goto Exit;
- result = face->internal->postscript_name;
if ( !result )
{
- /* now, look up glyph name */
- FT_Driver driver = face->driver;
- FT_Module_Class* clazz = FT_MODULE_CLASS( driver );
+ FT_Service_PsName service;
+ FT_FACE_LOOKUP_SERVICE( face, service,
+ postscript_name,
+ FT_SERVICE_ID_POSTSCRIPT_NAME );
- if ( clazz->get_interface )
- {
- FT_Face_GetPostscriptNameFunc requester;
-
-
- requester = (FT_Face_GetPostscriptNameFunc)clazz->get_interface(
- FT_MODULE( driver ), "postscript_name" );
- if ( requester )
- result = requester( face );
- }
+ if ( service && service->get_ps_name )
+ result = service->get_ps_name( face );
}
Exit:
return result;
@@ -2471,20 +2491,15 @@
FT_Sfnt_Tag tag )
{
void* table = 0;
- FT_Get_Sfnt_Table_Func func;
- FT_Driver driver;
-
-
- if ( !face || !FT_IS_SFNT( face ) )
- goto Exit;
+ FT_Service_SFNT_Table service;
- driver = face->driver;
- func = (FT_Get_Sfnt_Table_Func)driver->root.clazz->get_interface(
- FT_MODULE( driver ), "get_sfnt" );
- if ( func )
- table = func( face, tag );
-
- Exit:
+ if ( face && FT_IS_SFNT( face ) )
+ {
+ FT_FACE_FIND_SERVICE( face, service, FT_SERVICE_ID_SFNT_TABLE );
+ if ( service != NULL )
+ table = service->get_table( face, tag );
+ }
+
return table;
}
@@ -2498,20 +2513,17 @@
FT_Byte* buffer,
FT_ULong* length )
{
- SFNT_Load_Table_Func func;
- FT_Driver driver;
+ FT_Service_SFNT_Table service;
if ( !face || !FT_IS_SFNT( face ) )
return FT_Err_Invalid_Face_Handle;
- driver = face->driver;
- func = (SFNT_Load_Table_Func) driver->root.clazz->get_interface(
- FT_MODULE( driver ), "load_sfnt" );
- if ( !func )
+ FT_FACE_FIND_SERVICE( face, service, FT_SERVICE_ID_SFNT_TABLE );
+ if ( service == NULL )
return FT_Err_Unimplemented_Feature;
-
- return func( face, tag, offset, buffer, length );
+
+ return service->load_table( face, tag, offset, buffer, length );
}
diff --git a/src/base/ftxf86.c b/src/base/ftxf86.c
index 1f5e42c..e8e3056 100644
--- a/src/base/ftxf86.c
+++ b/src/base/ftxf86.c
@@ -19,59 +19,15 @@
#include <ft2build.h>
#include FT_XFREE86_H
#include FT_INTERNAL_OBJECTS_H
-
- /* XXX: This really is a sad hack, but I didn't want to change every */
- /* driver just to support this at the moment, since other important */
- /* changes are coming anyway. */
-
- typedef struct FT_FontFormatRec_
- {
- const char* driver_name;
- const char* format_name;
-
- } FT_FontFormatRec;
-
+#include FT_SERVICE_XFREE86_NAME_H
FT_EXPORT_DEF( const char* )
FT_Get_X11_Font_Format( FT_Face face )
{
- static const FT_FontFormatRec font_formats[] =
- {
- { "type1", "Type 1" },
- { "truetype", "TrueType" },
- { "bdf", "BDF" },
- { "pcf", "PCF" },
- { "type42", "Type 42" },
- { "cidtype1", "CID Type 1" },
- { "cff", "CFF" },
- { "pfr", "PFR" },
- { "winfonts", "Windows FNT" }
- };
-
const char* result = NULL;
-
- if ( face && face->driver )
- {
- FT_Module driver = (FT_Module)face->driver;
-
-
- if ( driver->clazz && driver->clazz->module_name )
- {
- FT_Int n;
- FT_Int count = sizeof( font_formats ) / sizeof ( font_formats[0] );
-
-
- result = driver->clazz->module_name;
-
- for ( n = 0; n < count; n++ )
- if ( ft_strcmp( result, font_formats[n].driver_name ) == 0 )
- {
- result = font_formats[n].format_name;
- break;
- }
- }
- }
+ if ( face )
+ FT_FACE_FIND_SERVICE( result, face, FT_SERVICE_ID_XF86_NAME );
return result;
}
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index dbd4a2f..ea5e674 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -31,6 +31,9 @@ THE SOFTWARE.
#include FT_INTERNAL_OBJECTS_H
#include FT_BDF_H
+#include FT_SERVICE_BDF_H
+#include FT_SERVICE_XFREE86_NAME_H
+
#include "bdf.h"
#include "bdfdrivr.h"
@@ -649,6 +652,12 @@ THE SOFTWARE.
}
+ /*
+ *
+ * BDF SERVICE
+ *
+ */
+
static FT_Error
bdf_get_bdf_property( BDF_Face face,
const char* prop_name,
@@ -689,6 +698,38 @@ THE SOFTWARE.
return BDF_Err_Invalid_Argument;
}
+ static FT_Error
+ bdf_get_charset_id( BDF_Face face,
+ const char* *acharset_encoding,
+ const char* *acharset_registry )
+ {
+ *acharset_encoding = face->charset_encoding;
+ *acharset_registry = face->charset_registry;
+
+ return 0;
+ }
+
+
+ static const FT_Service_BDFRec bdf_service_bdf =
+ {
+ (FT_BDF_GetCharsetIdFunc) bdf_get_charset_id,
+ (FT_BDF_GetPropertyFunc) bdf_get_bdf_property
+ };
+
+
+ /*
+ *
+ * SERVICES LIST
+ *
+ */
+
+ static const FT_ServiceDescRec bdf_services[] =
+ {
+ { FT_SERVICE_ID_BDF, &bdf_service_bdf },
+ { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_BDF },
+ { NULL, NULL }
+ };
+
static FT_Module_Interface
bdf_driver_requester( FT_Module module,
@@ -696,13 +737,11 @@ THE SOFTWARE.
{
FT_UNUSED( module );
- if ( name && ft_strcmp( name, "get_bdf_property" ) == 0 )
- return (FT_Module_Interface)bdf_get_bdf_property;
-
- return NULL;
+ return ft_service_list_lookup( bdf_services, name );
}
+
FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec bdf_driver_class =
{
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 54929b7..19c7fa8 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -30,6 +30,8 @@
#include "cfferrs.h"
+#include FT_SERVICE_XFREE86_NAME_H
+#include FT_SERVICE_GLYPH_DICT_H
/*************************************************************************/
/* */
@@ -210,17 +212,12 @@
}
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
- /**** ****/
- /**** ****/
- /**** C H A R A C T E R M A P P I N G S ****/
- /**** ****/
- /**** ****/
- /*************************************************************************/
- /*************************************************************************/
- /*************************************************************************/
+ /*
+ * GLYPH DICT SERVICE
+ *
+ */
+
+#include FT_SERVICE_GLYPH_DICT_H
static FT_Error
cff_get_glyph_name( CFF_Face face,
@@ -275,23 +272,6 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* cff_get_name_index */
- /* */
- /* <Description> */
- /* Uses the psnames module and the CFF font's charset to to return a */
- /* a given glyph name's glyph index. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* glyph_name :: The glyph name. */
- /* */
- /* <Return> */
- /* Glyph index. 0 means `undefined character code'. */
- /* */
static FT_UInt
cff_get_name_index( CFF_Face face,
FT_String* glyph_name )
@@ -334,6 +314,13 @@
}
+ static const FT_Service_GlyphDictRec cff_service_glyph_dict =
+ {
+ (FT_GlyphDict_GetNameFunc) cff_get_glyph_name,
+ (FT_GlyphDict_NameIndexFunc) cff_get_name_index,
+ };
+
+
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -346,22 +333,25 @@
/*************************************************************************/
/*************************************************************************/
+ static const FT_ServiceDescRec cff_services[] =
+ {
+ { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF },
+#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
+ { FT_SERVICE_ID_GLYPH_DICT, & cff_service_glyph_dict },
+#endif
+ { NULL, NULL }
+ };
+
static FT_Module_Interface
cff_get_interface( CFF_Driver driver,
const char* module_interface )
{
FT_Module sfnt;
+ FT_Module_Interface result;
-
-#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
-
- if ( ft_strcmp( (const char*)module_interface, "glyph_name" ) == 0 )
- return (FT_Module_Interface)cff_get_glyph_name;
-
- if ( ft_strcmp( (const char*)module_interface, "name_index" ) == 0 )
- return (FT_Module_Interface)cff_get_name_index;
-
-#endif
+ result = ft_service_list_lookup( cff_services, module_interface );
+ if ( result != NULL )
+ return result;
/* we simply pass our request to the `sfnt' module */
sfnt = FT_Get_Module( driver->root.root.library, "sfnt" );
diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c
index 471f196..4fa5e02 100644
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -25,6 +25,8 @@
#include "ciderrs.h"
+#include FT_SERVICE_POSTSCRIPT_NAME_H
+#include FT_SERVICE_XFREE86_NAME_H
/*************************************************************************/
/* */
@@ -36,6 +38,11 @@
#define FT_COMPONENT trace_ciddriver
+ /*
+ * POSTSCRIPT NAME SERVICE
+ *
+ */
+
static const char*
cid_get_postscript_name( CID_Face face )
{
@@ -47,7 +54,23 @@
return result;
}
+
+ static const FT_Service_PsNameRec cid_service_ps_name =
+ {
+ (FT_PsName_GetFunc) cid_get_postscript_name
+ };
+ /*
+ * SERVICE LIST
+ *
+ */
+
+ static const FT_ServiceDescRec cid_services[] =
+ {
+ { FT_SERVICE_ID_POSTSCRIPT_NAME, & cid_service_ps_name },
+ { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CID },
+ { NULL, NULL }
+ };
static FT_Module_Interface
cid_get_interface( FT_Driver driver,
@@ -56,10 +79,7 @@
FT_UNUSED( driver );
FT_UNUSED( cid_interface );
- if ( ft_strcmp( (const char*)cid_interface, "postscript_name" ) == 0 )
- return (FT_Module_Interface)cid_get_postscript_name;
-
- return 0;
+ return ft_service_list_lookup( cid_services, cid_interface );
}
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index 3681b1c..ac778ef 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -44,6 +44,8 @@ THE SOFTWARE.
#undef FT_COMPONENT
#define FT_COMPONENT trace_pcfread
+#include FT_SERVICE_BDF_H
+#include FT_SERVICE_XFREE86_NAME_H
typedef struct PCF_CMapRec_
{
@@ -471,6 +473,12 @@ THE SOFTWARE.
}
+ /*
+ *
+ * BDF SERVICE
+ *
+ */
+
static FT_Error
pcf_get_bdf_property( PCF_Face face,
const char* prop_name,
@@ -502,17 +510,34 @@ THE SOFTWARE.
return PCF_Err_Invalid_Argument;
}
+ static FT_Service_BDFRec pcf_service_bdf =
+ {
+ (FT_BDF_GetCharsetIdFunc) NULL, /* unimplemented ? */
+ (FT_BDF_GetPropertyFunc) pcf_get_bdf_property
+ };
+
+
+ /*
+ *
+ * SERVICE LIST
+ *
+ */
+ static FT_ServiceDescRec pcf_services[] =
+ {
+ { FT_SERVICE_ID_BDF, & pcf_service_bdf },
+ { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_PCF },
+ { NULL, NULL }
+ };
+
+
static FT_Module_Interface
pcf_driver_requester( FT_Module module,
const char* name )
{
FT_UNUSED( module );
- if ( name && ft_strcmp( name, "get_bdf_property" ) == 0 )
- return (FT_Module_Interface) pcf_get_bdf_property;
-
- return NULL;
+ return ft_service_list_lookup( pcf_services, name );
}
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index ea504bd..80551be 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -33,6 +33,8 @@
#include "ttpost.h"
#endif
+#include FT_SERVICE_GLYPH_DICT_H
+#include FT_SERVICE_POSTSCRIPT_NAME_H
static void*
get_sfnt_table( TT_Face face,
@@ -81,9 +83,13 @@
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
-
+ /*
+ * GLYPH DICT SERVICE
+ *
+ */
+
static FT_Error
- get_sfnt_glyph_name( TT_Face face,
+ sfnt_get_glyph_name( TT_Face face,
FT_UInt glyph_index,
FT_Pointer buffer,
FT_UInt buffer_max )
@@ -109,16 +115,29 @@
}
+ static const FT_Service_GlyphDictRec sfnt_service_glyph_dict =
+ {
+ (FT_GlyphDict_GetNameFunc) sfnt_get_glyph_name,
+ (FT_GlyphDict_NameIndexFunc) NULL
+ };
+
+#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
+
+ /*
+ * POSTSCRIPT NAME SERVICE
+ *
+ */
+
static const char*
- get_sfnt_postscript_name( TT_Face face )
+ sfnt_get_ps_name( TT_Face face )
{
FT_Int n, found_win, found_apple;
const char* result = NULL;
/* shouldn't happen, but just in case to avoid memory leaks */
- if ( face->root.internal->postscript_name )
- return face->root.internal->postscript_name;
+ if ( face->postscript_name )
+ return face->postscript_name;
/* scan the name table to see whether we have a Postscript name here, */
/* either in Macintosh or Windows platform encodings */
@@ -215,12 +234,31 @@
}
Exit:
- face->root.internal->postscript_name = result;
+ face->postscript_name = result;
return result;
}
+ static const FT_Service_PsNameRec sfnt_service_ps_name =
+ {
+ (FT_PsName_GetFunc) & sfnt_get_ps_name
+ };
+
-#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
+
+ /*
+ * SERVICE LIST
+ *
+ */
+
+ static const FT_ServiceDescRec sfnt_services[] =
+ {
+ { FT_SERVICE_ID_POSTSCRIPT_NAME, & sfnt_service_ps_name },
+#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
+ { FT_SERVICE_ID_GLYPH_DICT, & sfnt_service_glyph_dict },
+#endif
+
+ { NULL, NULL }
+ };
FT_CALLBACK_DEF( FT_Module_Interface )
@@ -235,15 +273,7 @@
if ( ft_strcmp( module_interface, "load_sfnt" ) == 0 )
return (FT_Module_Interface)tt_face_load_any;
-#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
- if ( ft_strcmp( module_interface, "glyph_name" ) == 0 )
- return (FT_Module_Interface)get_sfnt_glyph_name;
-#endif
-
- if ( ft_strcmp( module_interface, "postscript_name" ) == 0 )
- return (FT_Module_Interface)get_sfnt_postscript_name;
-
- return 0;
+ return ft_service_list_lookup( sfnt_services, module_interface );
}
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index 193be06..7f61220 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -21,6 +21,7 @@
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_TRUETYPE_IDS_H
+#include FT_SERVICE_XFREE86_NAME_H
#include "ttdriver.h"
#include "ttgload.h"
@@ -344,17 +345,26 @@
/*************************************************************************/
/*************************************************************************/
+ static const FT_ServiceDescRec tt_services[] =
+ {
+ { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE },
+ { NULL, NULL }
+ };
static FT_Module_Interface
tt_get_interface( TT_Driver driver,
const char* tt_interface )
{
- FT_Module sfntd = FT_Get_Module( driver->root.root.library,
- "sfnt" );
- SFNT_Service sfnt;
+ FT_Module_Interface result;
+ FT_Module sfntd;
+ SFNT_Service sfnt;
+ result = ft_service_list_lookup( tt_services, tt_interface );
+ if ( result != NULL )
+ return result;
/* only return the default interface from the SFNT module */
+ sfntd = FT_Get_Module( driver->root.root.library, "sfnt" );
if ( sfntd )
{
sfnt = (SFNT_Service)( sfntd->clazz->module_interface );
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index ebd6a65..2e2d016 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -31,6 +31,10 @@
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_POSTSCRIPT_NAMES_H
+#include FT_SERVICE_MULTIPLE_MASTERS_H
+#include FT_SERVICE_GLYPH_DICT_H
+#include FT_SERVICE_XFREE86_NAME_H
+#include FT_SERVICE_POSTSCRIPT_NAME_H
/*************************************************************************/
/* */
@@ -41,6 +45,10 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_t1driver
+ /*
+ * GLYPH DICT SERVICE
+ *
+ */
static FT_Error
t1_get_glyph_name( T1_Face face,
@@ -69,23 +77,6 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* t1_get_name_index */
- /* */
- /* <Description> */
- /* Uses the Type 1 font's `glyph_names' table to find a given glyph */
- /* name's glyph index. */
- /* */
- /* <Input> */
- /* face :: A handle to the source face object. */
- /* */
- /* glyph_name :: The glyph name. */
- /* */
- /* <Return> */
- /* Glyph index. 0 means `undefined character code'. */
- /* */
static FT_UInt
t1_get_name_index( T1_Face face,
FT_String* glyph_name )
@@ -105,6 +96,17 @@
return 0;
}
+ static const FT_Service_GlyphDictRec t1_service_glyph_dict =
+ {
+ (FT_GlyphDict_GetNameFunc) t1_get_glyph_name,
+ (FT_GlyphDict_NameIndexFunc) t1_get_name_index
+ };
+
+
+ /*
+ * POSTSCRIPT NAME SERVICE
+ *
+ */
static const char*
t1_get_ps_name( T1_Face face )
@@ -112,61 +114,53 @@
return (const char*) face->type1.font_name;
}
+ static const FT_Service_PsNameRec t1_service_ps_name =
+ {
+ (FT_PsName_GetFunc) & t1_get_ps_name
+ };
- /*************************************************************************/
- /* */
- /* <Function> */
- /* Get_Interface */
- /* */
- /* <Description> */
- /* Each driver can provide one or more extensions to the base */
- /* FreeType API. These can be used to access format specific */
- /* features (e.g., all TrueType/OpenType resources share a common */
- /* file structure and common tables which can be accessed through the */
- /* `sfnt' interface), or more simply generic ones (e.g., the */
- /* `postscript names' interface which can be used to retrieve the */
- /* PostScript name of a given glyph index). */
- /* */
- /* <InOut> */
- /* driver :: A handle to a driver object. */
- /* */
- /* <Input> */
- /* t1_interface :: A string designing the interface. Examples are */
- /* `sfnt', `post_names', `charmaps', etc. */
- /* */
- /* <Return> */
- /* A typeless pointer to the extension's interface (normally a table */
- /* of function pointers). Returns NULL if the requested extension */
- /* isn't available (i.e., wasn't compiled in the driver at build */
- /* time). */
- /* */
- static FT_Module_Interface
- Get_Interface( FT_Driver driver,
- const FT_String* t1_interface )
+
+ /*
+ * MULTIPLE MASTERS SERVICE
+ *
+ */
+
+#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
+ static const FT_Service_MultiMastersRec t1_service_multi_masters =
{
- FT_UNUSED( driver );
- FT_UNUSED( t1_interface );
+ (FT_Get_MM_Func) T1_Get_Multi_Master,
+ (FT_Set_MM_Design_Func) T1_Set_MM_Design,
+ (FT_Set_MM_Blend_Func) T1_Set_MM_Blend
+ };
+#endif
- if ( ft_strcmp( (const char*)t1_interface, "glyph_name" ) == 0 )
- return (FT_Module_Interface)t1_get_glyph_name;
- if ( ft_strcmp( (const char*)t1_interface, "name_index" ) == 0 )
- return (FT_Module_Interface)t1_get_name_index;
+ /*
+ * SERVICE LIST
+ *
+ */
- if ( ft_strcmp( (const char*)t1_interface, "postscript_name" ) == 0 )
- return (FT_Module_Interface)t1_get_ps_name;
+ static const FT_ServiceDescRec t1_services[] =
+ {
+ { FT_SERVICE_ID_POSTSCRIPT_NAME, &t1_service_ps_name },
+ { FT_SERVICE_ID_GLYPH_DICT, &t1_service_glyph_dict },
+ { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TYPE_1 },
+
+#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
+ { FT_SERVICE_ID_MULTI_MASTERS, &t1_service_multi_masters },
+#endif
+ { NULL, NULL }
+ };
-#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
- if ( ft_strcmp( (const char*)t1_interface, "get_mm" ) == 0 )
- return (FT_Module_Interface)T1_Get_Multi_Master;
- if ( ft_strcmp( (const char*)t1_interface, "set_mm_design") == 0 )
- return (FT_Module_Interface)T1_Set_MM_Design;
+ static FT_Module_Interface
+ Get_Interface( FT_Driver driver,
+ const FT_String* t1_interface )
+ {
+ FT_UNUSED( driver );
+ FT_UNUSED( t1_interface );
- if ( ft_strcmp( (const char*)t1_interface, "set_mm_blend") == 0 )
- return (FT_Module_Interface)T1_Set_MM_Blend;
-#endif
- return 0;
+ return ft_service_list_lookup( t1_services, t1_interface );
}
diff --git a/src/type42/t42drivr.c b/src/type42/t42drivr.c
index d966877..b0d21b5 100644
--- a/src/type42/t42drivr.c
+++ b/src/type42/t42drivr.c
@@ -41,11 +41,20 @@
#include "t42error.h"
#include FT_INTERNAL_DEBUG_H
+#include FT_SERVICE_XFREE86_NAME_H
+#include FT_SERVICE_GLYPH_DICT_H
+#include FT_SERVICE_POSTSCRIPT_NAME_H
#undef FT_COMPONENT
#define FT_COMPONENT trace_t42
+ /*
+ *
+ * GLYPH DICT SERVICE
+ *
+ */
+
static FT_Error
t42_get_glyph_name( T42_Face face,
FT_UInt glyph_index,
@@ -73,13 +82,6 @@
}
- static const char*
- t42_get_ps_name( T42_Face face )
- {
- return (const char*)face->type1.font_name;
- }
-
-
static FT_UInt
t42_get_name_index( T42_Face face,
FT_String* glyph_name )
@@ -100,23 +102,53 @@
}
+ static FT_Service_GlyphDictRec t42_service_glyph_dict =
+ {
+ (FT_GlyphDict_GetNameFunc) t42_get_glyph_name,
+ (FT_GlyphDict_NameIndexFunc) t42_get_name_index
+ };
+
+
+ /*
+ *
+ * POSTSCRIPT NAME SERVICE
+ *
+ */
+
+ static const char*
+ t42_get_ps_name( T42_Face face )
+ {
+ return (const char*)face->type1.font_name;
+ }
+
+
+ static FT_Service_PsNameRec t42_service_ps_name =
+ {
+ (FT_PsName_GetFunc) t42_get_ps_name
+ };
+
+
+ /*
+ *
+ * SERVICE LIST
+ *
+ */
+
+ static const FT_ServiceDescRec t42_services[] =
+ {
+ { FT_SERVICE_ID_GLYPH_DICT, & t42_service_glyph_dict },
+ { FT_SERVICE_ID_POSTSCRIPT_NAME, & t42_service_ps_name },
+ { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TYPE_42 },
+ { NULL, NULL }
+ };
+
static FT_Module_Interface
T42_Get_Interface( FT_Driver driver,
const FT_String* t42_interface )
{
FT_UNUSED( driver );
- /* Any additional interface are defined here */
- if (ft_strcmp( (const char*)t42_interface, "glyph_name" ) == 0 )
- return (FT_Module_Interface)t42_get_glyph_name;
-
- if ( ft_strcmp( (const char*)t42_interface, "name_index" ) == 0 )
- return (FT_Module_Interface)t42_get_name_index;
-
- if ( ft_strcmp( (const char*)t42_interface, "postscript_name" ) == 0 )
- return (FT_Module_Interface)t42_get_ps_name;
-
- return 0;
+ return ft_service_list_lookup( t42_services, t42_interface );
}