Heavy modification of the PS parser to handle comments and strings correctly. This doesn't slow down the loading of PS fonts significantly since charstrings aren't affected. * include/freetype/config/ftstdlib.h (ft_xdigit): Renamed to... (ft_isxdigit): This. Updated all callers. (ft_isdigit): New alias to `isdigit'. * include/freetype/internal/psaux.h (PS_Parser_FuncsRec): Renamed `skip_alpha' to `skip_PS_token'. Add parameter to `to_bytes' and change some argument types. * src/psaux/psauxmod.c (ps_parser_funcs): Updated. * src/psaux/psobjs.c (ft_char_table): New array to map character codes (ASCII and EBCDIC) of digits to numbers. (OP): New auxiliary macro holding either `>=' or `<' depending on the character encoding. (skip_comment): New function. (skip_spaces): Use it. (skip_alpha): Removed. (skip_literal_string, skip_string): New functions. (ps_parser_skip_PS_token): New function. This is a better replacement of... (ps_parser_skip_alpha): Removed. (ps_parser_to_token, ps+parser_to_token_array): Updated. (T1Radix): Rewritten, using `ft_char_table'. (t1_toint): Renamed to... (ps_toint): This. Update all callers. Use `ft_char_table'. (ps_tobytes): Add parameter to handle delimiters and change some argument types. Use `ft_char_table'. (t1_tofixed): Renamed to... (ps_tofixed): This. Update all callers. Use `ft_char_table'. (t1_tocoordarray): Renamed and updated to... (ps_tocoordarray): This. Update all callers. (t1_tofixedarray): Renamed and updated to... (ps_tofixedarray): This. Update all callers. (t1_tobool): Renamed to... (ps_tobool): This. Update all callers. (ps_parser_load_field): Updated. (ps_parser_load_field_table): Use `T1_MAX_TABLE_ELEMENTS' everywhere. (ps_parser_to_int, ps_parser_to_fixed, ps_parser_to_coord_array, ps_parser_to_fixed_array): Skip spaces. Updated. (ps_parser_to_bytes): Add parameter to handle delimiters and change some argument types. Updated. * src/psaux/psobjs.h: Updated. * src/cid/cidload.c (cid_parse_dict): Updated. * src/cid/cidparse.c (cid_parser_new): Check whether the `StartData' token was really found. * src/cid/cidparse.h (cid_parser_skip_alpha): Updated and renamed to... (cid_parser_skip_PS_token): This. * src/type1/t1parse.h (T1_ParserRec): Use `FT_Bool' for boolean fields. (T1_Skip_Alpha): Replaced with... (T1_Skip_PS_Token): This new macro. * src/type1/t1parse.c (hexa_value): Removed. (T1_Get_Private_Dict): Use `ft_isxdigit' and `psaux->ps_parser_funcs_to_bytes' for handling ASCII hexadecimal encoding. After decrypting, replace the four random bytes at the beginning with whitespace. * src/type1/t1load.c (t1_allocate_blend): Use proper error values. (parser_blend_design_positions, parse_blend_design_map, parse_weight_vector): Updated. (is_space): Handle `\f' also. (is_name_char): Removed. (read_binary_data): Updated. (parse_encoding): Use `ft_isdigit'. Updated. (parse_subrs): Updated. (TABLE_EXTEND): New macro. (parse_charstrings): Updated. Provide a workaround for buggy fonts which have more entries in the /CharStrings dictionary then expected; the function now adds some slots and skips entries which still exceed the new limit. (parse_dict): Updated. Terminate on the token `closefile'. * src/type42/t42parse.c (T1_Skip_Alpha): Replaced with... (T1_Skip_PS_Token): This new macro. Updated all callers. (t42_parse_encoding): Use `ft_isdigit'. * src/base/ftmm.c (ft_face_get_mm_service): Return FT_Err_OK if success.
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 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011
diff --git a/ChangeLog b/ChangeLog
index 97c71b7..6983ffe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,97 @@
+2003-10-06 Werner Lemberg <wl@gnu.org>
+
+ Heavy modification of the PS parser to handle comments and strings
+ correctly. This doesn't slow down the loading of PS fonts
+ significantly since charstrings aren't affected.
+
+ * include/freetype/config/ftstdlib.h (ft_xdigit): Renamed to...
+ (ft_isxdigit): This. Updated all callers.
+ (ft_isdigit): New alias to `isdigit'.
+
+ * include/freetype/internal/psaux.h (PS_Parser_FuncsRec): Renamed
+ `skip_alpha' to `skip_PS_token'.
+ Add parameter to `to_bytes' and change some argument types.
+
+ * src/psaux/psauxmod.c (ps_parser_funcs): Updated.
+ * src/psaux/psobjs.c (ft_char_table): New array to map character
+ codes (ASCII and EBCDIC) of digits to numbers.
+ (OP): New auxiliary macro holding either `>=' or `<' depending on
+ the character encoding.
+ (skip_comment): New function.
+ (skip_spaces): Use it.
+ (skip_alpha): Removed.
+ (skip_literal_string, skip_string): New functions.
+ (ps_parser_skip_PS_token): New function. This is a better
+ replacement of...
+ (ps_parser_skip_alpha): Removed.
+ (ps_parser_to_token, ps+parser_to_token_array): Updated.
+ (T1Radix): Rewritten, using `ft_char_table'.
+ (t1_toint): Renamed to...
+ (ps_toint): This. Update all callers.
+ Use `ft_char_table'.
+ (ps_tobytes): Add parameter to handle delimiters and change some
+ argument types.
+ Use `ft_char_table'.
+ (t1_tofixed): Renamed to...
+ (ps_tofixed): This. Update all callers.
+ Use `ft_char_table'.
+ (t1_tocoordarray): Renamed and updated to...
+ (ps_tocoordarray): This. Update all callers.
+ (t1_tofixedarray): Renamed and updated to...
+ (ps_tofixedarray): This. Update all callers.
+ (t1_tobool): Renamed to...
+ (ps_tobool): This. Update all callers.
+ (ps_parser_load_field): Updated.
+ (ps_parser_load_field_table): Use `T1_MAX_TABLE_ELEMENTS'
+ everywhere.
+ (ps_parser_to_int, ps_parser_to_fixed, ps_parser_to_coord_array,
+ ps_parser_to_fixed_array): Skip spaces. Updated.
+ (ps_parser_to_bytes): Add parameter to handle delimiters and change
+ some argument types. Updated.
+ * src/psaux/psobjs.h: Updated.
+
+ * src/cid/cidload.c (cid_parse_dict): Updated.
+ * src/cid/cidparse.c (cid_parser_new): Check whether the `StartData'
+ token was really found.
+ * src/cid/cidparse.h (cid_parser_skip_alpha): Updated and renamed
+ to...
+ (cid_parser_skip_PS_token): This.
+
+ * src/type1/t1parse.h (T1_ParserRec): Use `FT_Bool' for boolean
+ fields.
+ (T1_Skip_Alpha): Replaced with...
+ (T1_Skip_PS_Token): This new macro.
+ * src/type1/t1parse.c (hexa_value): Removed.
+ (T1_Get_Private_Dict): Use `ft_isxdigit' and
+ `psaux->ps_parser_funcs_to_bytes' for handling ASCII hexadecimal
+ encoding.
+ After decrypting, replace the four random bytes at the beginning
+ with whitespace.
+ * src/type1/t1load.c (t1_allocate_blend): Use proper error values.
+ (parser_blend_design_positions, parse_blend_design_map,
+ parse_weight_vector): Updated.
+ (is_space): Handle `\f' also.
+ (is_name_char): Removed.
+ (read_binary_data): Updated.
+ (parse_encoding): Use `ft_isdigit'.
+ Updated.
+ (parse_subrs): Updated.
+ (TABLE_EXTEND): New macro.
+ (parse_charstrings): Updated.
+ Provide a workaround for buggy fonts which have more entries in the
+ /CharStrings dictionary then expected; the function now adds some
+ slots and skips entries which still exceed the new limit.
+ (parse_dict): Updated.
+ Terminate on the token `closefile'.
+
+ * src/type42/t42parse.c (T1_Skip_Alpha): Replaced with...
+ (T1_Skip_PS_Token): This new macro. Updated all callers.
+ (t42_parse_encoding): Use `ft_isdigit'.
+
+
+ * src/base/ftmm.c (ft_face_get_mm_service): Return FT_Err_OK if
+ success.
+
2003-10-05 Werner Lemberg <wl@gnu.org>
* include/freetype/ftmodule.h: Renamed to...
diff --git a/include/freetype/config/ftstdlib.h b/include/freetype/config/ftstdlib.h
index 7868fd4..f160ad2 100644
--- a/include/freetype/config/ftstdlib.h
+++ b/include/freetype/config/ftstdlib.h
@@ -5,7 +5,7 @@
/* ANSI-specific library and header configuration file (specification */
/* only). */
/* */
-/* Copyright 2002 by */
+/* Copyright 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -73,10 +73,11 @@
#include <ctype.h>
-#define ft_isalnum isalnum
-#define ft_isupper isupper
-#define ft_islower islower
-#define ft_xdigit isxdigit
+#define ft_isalnum isalnum
+#define ft_isupper isupper
+#define ft_islower islower
+#define ft_isdigit isdigit
+#define ft_isxdigit isxdigit
#include <string.h>
diff --git a/include/freetype/ftoutln.h b/include/freetype/ftoutln.h
index daebae8..8c6a689 100644
--- a/include/freetype/ftoutln.h
+++ b/include/freetype/ftoutln.h
@@ -5,7 +5,7 @@
/* Support for the FT_Outline type used to store glyph shapes of */
/* most scalable font formats (specification). */
/* */
-/* Copyright 1996-2001, 2002 by */
+/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -391,32 +391,33 @@ FT_BEGIN_HEADER
/**************************************************************************
*
- * @enum: FT_Orientation
+ * @enum:
+ * FT_Orientation
*
* @description:
- * a list of values used to describe an outline's contour orientation
+ * A list of values used to describe an outline's contour orientation.
*
- * The TrueType and Postscript specifications used different conventions
- * to determine wether outline contours should be filled or unfilled.
+ * The TrueType and Postscript specifications use different conventions
+ * to determine whether outline contours should be filled or unfilled.
*
* @values:
* FT_ORIENTATION_TRUETYPE ::
- * according to the TrueType specification, clockwise contours must
- * be filled, and counter-clockwise ones must be unfilled
+ * According to the TrueType specification, clockwise contours must
+ * be filled, and counter-clockwise ones must be unfilled.
*
* FT_ORIENTATION_POSTSCRIPT ::
- * according to the Postscript specification, counter-clockwise contours
- * must be filled, and clockwise ones must be unfilled
+ * According to the Postscript specification, counter-clockwise contours
+ * must be filled, and clockwise ones must be unfilled.
*
* FT_ORIENTATION_FILL_RIGHT ::
- * this is identical to @FT_ORIENTATION_TRUETYPE, but is used to
+ * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
* remember that in TrueType, everything that is to the right of
* the drawing direction of a contour must be filled.
*
* FT_ORIENTATION_FILL_LEFT ::
- * this is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
+ * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
* remember that in Postscript, everything that is to the left of
- * the drawing direction of a contour must be filled
+ * the drawing direction of a contour must be filled.
*/
typedef enum
{
@@ -430,22 +431,24 @@ FT_BEGIN_HEADER
/**************************************************************************
*
- * @function: FT_Outline_Get_Orientation
+ * @function:
+ * FT_Outline_Get_Orientation
*
* @description:
- * this function analyzes a glyph outline and tries to compute its
- * fill orientation (see @FT_Orientation). This is done by computing
+ * This function analyzes a glyph outline and tries to compute its
+ * fill orientation (see @FT_Orientation). This is done by computing
* the direction of each global horizontal and/or vertical extrema
* within the outline.
*
- * note that this will return @FT_ORIENTATION_TRUETYPE for empty
+ * Note that this will return @FT_ORIENTATION_TRUETYPE for empty
* outlines.
*
* @input:
- * outline :: handle to source outline
+ * outline ::
+ * A handle to the source outline.
*
* @return:
- * orientation
+ * The orientation.
*
*/
FT_EXPORT( FT_Orientation )
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index 48bda92..bc36da7 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -330,18 +330,20 @@ FT_BEGIN_HEADER
void
(*skip_spaces)( PS_Parser parser );
void
- (*skip_alpha)( PS_Parser parser );
+ (*skip_PS_token)( PS_Parser parser );
FT_Long
(*to_int)( PS_Parser parser );
FT_Fixed
(*to_fixed)( PS_Parser parser,
FT_Int power_ten );
+
FT_Error
(*to_bytes)( PS_Parser parser,
FT_Byte* bytes,
- FT_Int max_bytes,
- FT_Int* pnum_bytes );
+ FT_Long max_bytes,
+ FT_Long* pnum_bytes,
+ FT_Bool delimiters );
FT_Int
(*to_coord_array)( PS_Parser parser,
diff --git a/src/base/ftmm.c b/src/base/ftmm.c
index 039a850..0bb2813 100644
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -51,6 +51,9 @@
FT_FACE_LOOKUP_SERVICE( face,
*aservice,
MULTI_MASTERS );
+
+ if ( aservice )
+ error = FT_Err_Ok;
}
return error;
diff --git a/src/base/ftpfr.c b/src/base/ftpfr.c
index b1cd773..80a657c 100644
--- a/src/base/ftpfr.c
+++ b/src/base/ftpfr.c
@@ -26,6 +26,7 @@
{
FT_Service_PfrMetrics service;
+
FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
return service;
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 32c4a0d..db302b2 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -39,7 +39,7 @@
/* read a single offset */
FT_LOCAL_DEF( FT_Long )
- cid_get_offset( FT_Byte** start,
+ cid_get_offset( FT_Byte* *start,
FT_Byte offsize )
{
FT_Long result;
@@ -164,9 +164,9 @@
temp_scale = ABS( temp[3] );
- /* Set Units per EM based on FontMatrix values. We set the value to */
+ /* Set units per EM based on FontMatrix values. We set the value to */
/* `1000/temp_scale', because temp_scale was already multiplied by */
- /* 1000 (in t1_tofixed(), from psobjs.c). */
+ /* 1000 (in `t1_tofixed', from psobjs.c). */
root->units_per_EM = (FT_UShort)( FT_DivFix( 0x10000L,
FT_DivFix( temp_scale, 1000 ) ) );
@@ -258,38 +258,57 @@
parser->root.cursor = base;
parser->root.limit = base + size;
- parser->root.error = 0;
+ parser->root.error = CID_Err_Ok;
{
FT_Byte* cur = base;
FT_Byte* limit = cur + size;
- for ( ; cur < limit; cur++ )
+ for (;;)
{
+ FT_Byte* newlimit;
+
+
+ parser->root.cursor = cur;
+ cid_parser_skip_spaces( parser );
+
+ if ( parser->root.cursor >= limit )
+ newlimit = limit - 1 - 17;
+ else
+ newlimit = parser->root.cursor - 17;
+
/* look for `%ADOBeginFontDict' */
- if ( *cur == '%' && cur + 20 < limit &&
- ft_strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 )
+ for ( ; cur < newlimit; cur++ )
{
- cur += 17;
-
- /* if /FDArray was found, then cid->num_dicts is > 0, and */
- /* we can start increasing parser->num_dict */
- if ( face->cid.num_dicts > 0 )
- parser->num_dict++;
+ if ( *cur == '%' &&
+ ft_strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 )
+ {
+ /* if /FDArray was found, then cid->num_dicts is > 0, and */
+ /* we can start increasing parser->num_dict */
+ if ( face->cid.num_dicts > 0 )
+ parser->num_dict++;
+ }
}
+
+ cur = parser->root.cursor;
+ /* no error can occur in cid_parser_skip_spaces */
+ if ( cur >= limit )
+ break;
+
+ cid_parser_skip_PS_token( parser );
+ if ( parser->root.cursor >= limit || parser->root.error )
+ break;
+
/* look for immediates */
- else if ( *cur == '/' && cur + 2 < limit )
+ if ( *cur == '/' && cur + 2 < limit )
{
FT_PtrDist len;
cur++;
-
- parser->root.cursor = cur;
- cid_parser_skip_alpha( parser );
-
len = parser->root.cursor - cur;
+
if ( len > 0 && len < 22 )
{
/* now compare the immediate name to the keyword table */
@@ -303,10 +322,7 @@
name = (FT_Byte*)keyword->ident;
if ( !name )
- {
- cid_parser_skip_alpha( parser );
break;
- }
if ( cur[0] == name[0] &&
len == ft_strlen( (const char*)name ) )
@@ -321,14 +337,11 @@
if ( n >= len )
{
/* we found it - run the parsing callback */
- cid_parser_skip_spaces( parser );
parser->root.error = cid_load_keyword( face,
loader,
keyword );
if ( parser->root.error )
return parser->root.error;
-
- cur = parser->root.cursor;
break;
}
}
@@ -336,6 +349,8 @@
}
}
}
+
+ cur = parser->root.cursor;
}
}
return parser->root.error;
diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c
index 397a66f..5703729 100644
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -4,7 +4,7 @@
/* */
/* CID-keyed Type1 parser (body). */
/* */
-/* Copyright 1996-2001, 2002 by */
+/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -58,6 +58,7 @@
FT_ULong base_offset, offset, ps_len;
FT_Byte buffer[256 + 10];
FT_Int buff_len;
+ FT_Byte *cur, *limit;
FT_MEM_ZERO( parser, sizeof ( *parser ) );
@@ -67,7 +68,7 @@
base_offset = FT_STREAM_POS();
- /* first of all, check the font format in the header */
+ /* first of all, check the font format in the header */
if ( FT_FRAME_ENTER( 31 ) )
goto Exit;
@@ -82,15 +83,17 @@
if ( error )
goto Exit;
- /* now, read the rest of the file, until we find a `StartData' */
+ Again:
+ /* now, read the rest of the file until we find a `StartData' */
buff_len = 256;
for (;;)
{
- FT_Byte *p, *limit = buffer + 256;
+ FT_Byte* p;
FT_ULong top_position;
/* fill input buffer */
+ limit = buffer + 256;
buff_len -= 256;
if ( buff_len > 0 )
FT_MEM_MOVE( buffer, limit, buff_len );
@@ -101,7 +104,7 @@
goto Exit;
top_position = FT_STREAM_POS() - buff_len;
- buff_len = 256 + 10;
+ buff_len = 256 + 10;
/* look for `StartData' */
for ( p = buffer; p < limit; p++ )
@@ -116,12 +119,12 @@
}
Found:
- /* we have found the start of the binary data. We will now */
- /* rewind and extract the frame of corresponding to the Postscript */
- /* section */
+ /* we have found the start of the binary data. We will now */
+ /* rewind and extract the frame corresponding to the PostScript */
+ /* section */
ps_len = offset - base_offset;
- if ( FT_STREAM_SEEK( base_offset ) ||
+ if ( FT_STREAM_SEEK( base_offset ) ||
FT_FRAME_EXTRACT( ps_len, parser->postscript ) )
goto Exit;
@@ -132,6 +135,32 @@
parser->root.limit = parser->root.cursor + ps_len;
parser->num_dict = -1;
+ /* finally we check whether `StartData' was real -- it could be */
+ /* in a comment or string */
+
+ limit = parser->root.limit;
+ cur = parser->root.cursor;
+
+ while ( cur < limit )
+ {
+ if ( *cur == 'S' && ft_strncmp( (char*)cur, "StartData", 9 ) == 0 )
+ {
+ limit = parser->root.limit;
+ cur = parser->root.cursor;
+ goto Exit;
+ }
+
+ cid_parser_skip_PS_token( parser );
+ cid_parser_skip_spaces ( parser );
+ cur = parser->root.cursor;
+ }
+
+ /* we haven't found the correct `StartData'; go back and continue */
+ /* searching */
+ FT_FRAME_RELEASE( parser->postscript );
+ if ( !FT_STREAM_SEEK( offset ) )
+ goto Again;
+
Exit:
return error;
}
diff --git a/src/cid/cidparse.h b/src/cid/cidparse.h
index 1b3e0b9..6114803 100644
--- a/src/cid/cidparse.h
+++ b/src/cid/cidparse.h
@@ -4,7 +4,7 @@
/* */
/* CID-keyed Type1 parser (specification). */
/* */
-/* Copyright 1996-2001, 2002 by */
+/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -87,8 +87,10 @@ FT_BEGIN_HEADER
/* */
/*************************************************************************/
-#define cid_parser_skip_spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
-#define cid_parser_skip_alpha( p ) (p)->root.funcs.skip_alpha ( &(p)->root )
+#define cid_parser_skip_spaces( p ) \
+ (p)->root.funcs.skip_spaces( &(p)->root )
+#define cid_parser_skip_PS_token( p ) \
+ (p)->root.funcs.skip_PS_token( &(p)->root )
#define cid_parser_to_int( p ) (p)->root.funcs.to_int( &(p)->root )
#define cid_parser_to_fixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t )
diff --git a/src/psaux/psauxmod.c b/src/psaux/psauxmod.c
index d602417..756ec1c 100644
--- a/src/psaux/psauxmod.c
+++ b/src/psaux/psauxmod.c
@@ -39,7 +39,7 @@
ps_parser_init,
ps_parser_done,
ps_parser_skip_spaces,
- ps_parser_skip_alpha,
+ ps_parser_skip_PS_token,
ps_parser_to_int,
ps_parser_to_fixed,
ps_parser_to_bytes,
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 992800f..adc9772 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -267,31 +267,76 @@
/*************************************************************************/
/* In the PostScript Language Reference Manual (PLRM) the following */
- /* characters are called `white-space characters'. */
+ /* characters are called `whitespace characters'. */
#define IS_T1_WHITESPACE( c ) ( (c) == ' ' || (c) == '\t' )
#define IS_T1_LINESPACE( c ) ( (c) == '\r' || (c) == '\n' || (c) == '\f' )
#define IS_T1_NULLSPACE( c ) ( (c) == '\0' )
- /* According to the PLRM all white-space characters are equivalent, */
- /* except in comments and strings. */
+ /* According to the PLRM all whitespace characters are equivalent, */
+ /* except in comments and strings. */
#define IS_T1_SPACE( c ) ( IS_T1_WHITESPACE( c ) || \
IS_T1_LINESPACE( c ) || \
IS_T1_NULLSPACE( c ) )
+ /* The following array is used by various functions to quickly convert */
+ /* digits (both decimal and non-decimal) into numbers. */
+
+#if 'A' == 65
+ /* ASCII */
+
+ char ft_char_table[128] =
+ {
+ /* 0x00 */
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
+ -1, 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, -1, -1, -1, -1, -1,
+ -1, 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, -1, -1, -1, -1, -1,
+ };
+
+ /* no character >= 0x80 can represent a valid number */
+#define OP >=
+
+#endif /* 'A' == 65 */
+
+#if 'A' == 193
+ /* EBCDIC */
+
+ char ft_char_table[128] =
+ {
+ /* 0x80 */
+ -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1,
+ -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
+ -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1,
+ -1, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1,
+ -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
+ }
+
+ /* no character < 0x80 can represent a valid number */
+#define OP <
+
+#endif /* 'A' == 193 */
+
+
+ /* first character must be already part of the comment */
+
static void
- skip_spaces( FT_Byte** acur,
- FT_Byte* limit )
+ skip_comment( FT_Byte* *acur,
+ FT_Byte* limit )
{
- FT_Byte* cur = *acur;
+ FT_Byte* cur = *acur;
while ( cur < limit )
{
- FT_Byte c = *cur;
-
-
- if ( !IS_T1_SPACE( c ) )
+ if ( IS_T1_LINESPACE( *cur ) )
break;
cur++;
}
@@ -301,19 +346,54 @@
static void
- skip_alpha( FT_Byte** acur,
- FT_Byte* limit )
+ skip_spaces( FT_Byte* *acur,
+ FT_Byte* limit )
{
FT_Byte* cur = *acur;
while ( cur < limit )
{
- FT_Byte c = *cur;
+ if ( !IS_T1_SPACE( *cur ) )
+ {
+ if ( *cur == '%' )
+ /* According to the PLRM, a comment is equal to a space. */
+ skip_comment( &cur, limit );
+ else
+ break;
+ }
+ cur++;
+ }
+ *acur = cur;
+ }
- if ( IS_T1_SPACE( c ) )
- break;
+
+ /* first character must be `(' */
+
+ static void
+ skip_literal_string( FT_Byte* *acur,
+ FT_Byte* limit )
+ {
+ FT_Byte* cur = *acur;
+ FT_Int embed = 0;
+
+
+ while ( cur < limit )
+ {
+ if ( *cur == '\\' )
+ cur++;
+ else if ( *cur == '(' )
+ embed++;
+ else if ( *cur == ')' )
+ {
+ embed--;
+ if ( embed == 0 )
+ {
+ cur++;
+ break;
+ }
+ }
cur++;
}
@@ -321,20 +401,145 @@
}
+ /* first character must be `<' */
+
+ static void
+ skip_string( PS_Parser parser )
+ {
+ FT_Byte* cur = parser->cursor;
+ FT_Byte* limit = parser->limit;
+
+
+ cur++;
+
+ while ( cur < limit )
+ {
+ int d;
+
+
+ /* All whitespace characters are ignored. */
+ skip_spaces( &cur, limit );
+ if ( cur >= limit )
+ break;
+
+ if ( *cur OP 0x80 )
+ break;
+
+ d = ft_char_table[*cur & 0x7F];
+ if ( d < 0 || d >= 16 )
+ break;
+ }
+
+ if ( cur < limit && *cur != '>' )
+ parser->error = PSaux_Err_Invalid_File_Format;
+ else
+ cur++;
+
+ parser->cursor = cur;
+ }
+
+
+ /***********************************************************************/
+ /* */
+ /* All exported parsing routines handle leading whitespace and stop at */
+ /* the first character which isn't part of the just handled token. */
+ /* */
+ /***********************************************************************/
+
+
FT_LOCAL_DEF( void )
- ps_parser_skip_spaces( PS_Parser parser )
+ ps_parser_skip_PS_token( PS_Parser parser )
{
- skip_spaces( &parser->cursor, parser->limit );
+ /* Note: PostScript allows any non-delimiting, non-whitespace */
+ /* character in a name (PS Ref Manual, 3rd ed, p31). */
+ /* PostScript delimiters are (, ), <, >, [, ], {, }, /, and %. */
+
+ FT_Byte* cur = parser->cursor;
+ FT_Byte* limit = parser->limit;
+
+
+ skip_spaces( &cur, limit ); /* this also skips comments */
+ if ( cur >= limit )
+ goto Exit;
+
+ /* self-delimiting, single-character tokens */
+ if ( *cur == '[' || *cur == ']' ||
+ *cur == '{' || *cur == '}' )
+ {
+ cur++;
+ goto Exit;
+ }
+
+ if ( *cur == '(' ) /* (...) */
+ {
+ skip_literal_string( &cur, limit );
+ goto Exit;
+ }
+
+ if ( *cur == '<' ) /* <...> */
+ {
+ if ( cur + 1 < limit && *(cur + 1) == '<' ) /* << */
+ {
+ cur++;
+ cur++;
+ goto Exit;
+ }
+ parser->cursor = cur;
+ skip_string( parser );
+ return;
+ }
+
+ if ( *cur == '>' )
+ {
+ cur++;
+ if ( cur >= limit || *cur != '>' ) /* >> */
+ {
+ parser->error = PSaux_Err_Invalid_File_Format;
+ goto Exit;
+ }
+ cur++;
+ goto Exit;
+ }
+
+ if ( *cur == '/' )
+ cur++;
+
+ /* anything else */
+ while ( cur < limit )
+ {
+ if ( IS_T1_SPACE( *cur ) ||
+ *cur == '(' ||
+ *cur == '/' ||
+ *cur == '%' ||
+ *cur == '[' || *cur == ']' ||
+ *cur == '{' || *cur == '}' ||
+ *cur == '<' || *cur == '>' )
+ break;
+
+ if ( *cur == ')' )
+ {
+ parser->error = PSaux_Err_Invalid_File_Format;
+ goto Exit;
+ }
+
+ cur++;
+ }
+
+ Exit:
+ parser->cursor = cur;
}
FT_LOCAL_DEF( void )
- ps_parser_skip_alpha( PS_Parser parser )
+ ps_parser_skip_spaces( PS_Parser parser )
{
- skip_alpha( &parser->cursor, parser->limit );
+ skip_spaces( &parser->cursor, parser->limit );
}
+ /* `token' here means either something between balanced delimiters */
+ /* or the next token; the delimiters are not removed. */
+
FT_LOCAL_DEF( void )
ps_parser_to_token( PS_Parser parser,
T1_Token token )
@@ -349,72 +554,87 @@
token->start = 0;
token->limit = 0;
- /* first of all, skip space */
+ /* first of all, skip leading whitespace */
ps_parser_skip_spaces( parser );
cur = parser->cursor;
limit = parser->limit;
- if ( cur < limit )
+ if ( cur >= limit )
+ return;
+
+ switch ( *cur )
{
- switch ( *cur )
+ /************* check for literal string *****************/
+ case '(':
+ token->type = T1_TOKEN_TYPE_STRING;
+ token->start = cur;
+ skip_literal_string( &cur, limit );
+ if ( cur < limit )
+ token->limit = cur;
+ break;
+
+ /************* check for programs/array *****************/
+ case '{':
+ token->type = T1_TOKEN_TYPE_ARRAY;
+ ender = '}';
+ goto Lookup_Ender;
+
+ /************* check for table/array ********************/
+ case '[':
+ token->type = T1_TOKEN_TYPE_ARRAY;
+ ender = ']';
+ /* fall through */
+
+ Lookup_Ender:
+ embed = 1;
+ starter = *cur;
+ token->start = cur++;
+
+ /* we need this to catch `[ ]' */
+ parser->cursor = cur;
+ ps_parser_skip_spaces( parser );
+ cur = parser->cursor;
+
+ while ( cur < limit && !parser->error )
{
- /************* check for strings ***********************/
- case '(':
- token->type = T1_TOKEN_TYPE_STRING;
- ender = ')';
- goto Lookup_Ender;
-
- /************* check for programs/array ****************/
- case '{':
- token->type = T1_TOKEN_TYPE_ARRAY;
- ender = '}';
- goto Lookup_Ender;
-
- /************* check for table/array ******************/
- case '[':
- token->type = T1_TOKEN_TYPE_ARRAY;
- ender = ']';
-
- Lookup_Ender:
- embed = 1;
- starter = *cur++;
- token->start = cur;
- while ( cur < limit )
+ if ( *cur == starter )
+ embed++;
+ else if ( *cur == ender )
{
- if ( *cur == starter )
- embed++;
- else if ( *cur == ender )
+ embed--;
+ if ( embed <= 0 )
{
- embed--;
- if ( embed <= 0 )
- {
- token->limit = cur++;
- break;
- }
+ token->limit = ++cur;
+ break;
}
- cur++;
}
- break;
- /* **************** otherwise, it's any token **********/
- default:
- token->start = cur++;
- token->type = T1_TOKEN_TYPE_ANY;
- while ( cur < limit && !IS_T1_SPACE( *cur ) )
- cur++;
-
- token->limit = cur;
- }
-
- if ( !token->limit )
- {
- token->start = 0;
- token->type = T1_TOKEN_TYPE_NONE;
+ parser->cursor = cur;
+ ps_parser_skip_PS_token( parser );
+ /* we need this to catch `[XXX ]' */
+ ps_parser_skip_spaces ( parser );
+ cur = parser->cursor;
}
+ break;
+
+ /* ************ otherwise, it is any token **************/
+ default:
+ token->start = cur;
+ token->type = T1_TOKEN_TYPE_ANY;
+ ps_parser_skip_PS_token( parser );
+ cur = parser->cursor;
+ if ( !parser->error )
+ token->limit = cur;
+ }
- parser->cursor = cur;
+ if ( !token->limit )
+ {
+ token->start = 0;
+ token->type = T1_TOKEN_TYPE_NONE;
}
+
+ parser->cursor = cur;
}
@@ -429,7 +649,9 @@
*pnum_tokens = -1;
+ /* this also handles leading whitespace */
ps_parser_to_token( parser, &master );
+
if ( master.type == T1_TOKEN_TYPE_ARRAY )
{
FT_Byte* old_cursor = parser->cursor;
@@ -438,8 +660,9 @@
T1_Token limit = cur + max_tokens;
- parser->cursor = master.start;
- parser->limit = master.limit;
+ /* don't include outermost delimiters */
+ parser->cursor = master.start + 1;
+ parser->limit = master.limit - 1;
while ( parser->cursor < parser->limit )
{
@@ -464,150 +687,161 @@
}
+ /* first character must be already part of the number */
+
static FT_Long
T1Radix( FT_Long radixBase,
- FT_Byte** cur,
+ FT_Byte* *acur,
FT_Byte* limit )
{
- FT_Long result = 0;
- FT_Byte radixEndChar0 =
- (FT_Byte)( radixBase > 10 ? '9' + 1 : '0' + radixBase );
- FT_Byte radixEndChar1 =
- (FT_Byte)( 'A' + radixBase - 10 );
- FT_Byte radixEndChar2 =
- (FT_Byte)( 'a' + radixBase - 10 );
+ FT_Long result = 0;
+ FT_Byte* cur = *acur;
- while( *cur < limit )
+ if ( radixBase < 2 || radixBase > 36 )
+ return 0;
+
+ while ( cur < limit )
{
- if ( (*cur)[0] >= '0' && (*cur)[0] < radixEndChar0 )
- result = result * radixBase + (*cur)[0] - '0';
+ int d;
- else if ( radixBase > 10 &&
- (*cur)[0] >= 'A' && (*cur)[0] < radixEndChar1 )
- result = result * radixBase + ( (*cur)[0] - 'A' + 10 );
- else if ( radixBase > 10 &&
- (*cur)[0] >= 'a' && (*cur)[0] < radixEndChar2 )
- result = result * radixBase + ( (*cur)[0] - 'a' + 10 );
+ if ( *cur OP 0x80 )
+ break;
+
+ d = ft_char_table[*cur & 0x7F];
+ if ( d < 0 || d >= radixBase )
+ break;
- else
- return result;
+ result = result * radixBase + d;
- (*cur)++;
+ cur++;
}
return result;
}
+ /* first character must be already part of the number */
+
static FT_Long
- t1_toint( FT_Byte** cursor,
+ ps_toint( FT_Byte* *acur,
FT_Byte* limit )
{
FT_Long result = 0;
- FT_Byte* cur = *cursor;
- FT_Byte c = '\0', d;
+ FT_Byte* cur = *acur;
+ FT_Byte c;
- for ( ; cur < limit; cur++ )
+ if ( cur >= limit )
+ goto Exit;
+
+ c = *cur;
+ if ( c == '-' )
+ cur++;
+
+ while ( cur < limit )
{
- c = *cur;
- d = (FT_Byte)( c - '0' );
- if ( d < 10 )
- break;
+ int d;
+
- if ( c == '-' )
+ if ( *cur == '#' )
{
cur++;
+ result = T1Radix( result, &cur, limit );
break;
}
- }
- if ( cur < limit )
- {
- do
- {
- d = (FT_Byte)( cur[0] - '0' );
- if ( d >= 10 )
- {
- if ( cur[0] == '#' )
- {
- cur++;
- result = T1Radix( result, &cur, limit );
- }
- break;
- }
+ if ( *cur OP 0x80 )
+ break;
- result = result * 10 + d;
- cur++;
+ d = ft_char_table[*cur & 0x7F];
+ if ( d < 0 || d >= 10 )
+ break;
+ result = result * 10 + d;
- } while ( cur < limit );
+ cur++;
+ };
- if ( c == '-' )
- result = -result;
- }
+ if ( c == '-' )
+ result = -result;
- *cursor = cur;
+ Exit:
+ *acur = cur;
return result;
}
- /* <...>: hexadecimal string */
+ /* first character must be `<' if `delimiters' is non-zero */
+
static FT_Error
- ps_tobytes( FT_Byte** cursor,
+ ps_tobytes( FT_Byte* *acur,
FT_Byte* limit,
- FT_Int max_bytes,
+ FT_Long max_bytes,
FT_Byte* bytes,
- FT_Int* pnum_bytes )
+ FT_Long* pnum_bytes,
+ FT_Bool delimiters )
{
FT_Error error = PSaux_Err_Ok;
- FT_Byte* cur = *cursor;
- FT_Int n = 0;
- FT_Byte b;
+ FT_Byte* cur = *acur;
+ FT_Long n;
- skip_spaces( &cur, limit );
+ if ( cur >= limit )
+ goto Exit;
- if ( *cur != '<' )
+ if ( delimiters )
{
- error = PSaux_Err_Invalid_File_Format;
- goto Exit;
+ if ( *cur != '<' )
+ {
+ error = PSaux_Err_Invalid_File_Format;
+ goto Exit;
+ }
+
+ cur++;
}
- cur++;
+ max_bytes = max_bytes * 2;
- for ( ; cur < limit; n++ )
+ for ( n = 0; cur < limit; n++, cur++ )
{
- FT_Byte* cur2 = cur;
+ int d;
- if ( n + 1 > max_bytes * 2 )
+ if ( n >= max_bytes )
+ /* buffer is full */
goto Exit;
- /* All white-space charcters are ignored. */
+ /* All whitespace characters are ignored. */
skip_spaces( &cur, limit );
+ if ( cur >= limit )
+ break;
- b = (FT_Byte) T1Radix( 16, &cur, cur + 1 );
+ if ( *cur OP 0x80 )
+ break;
- if ( cur == cur2 )
+ d = ft_char_table[*cur & 0x7F];
+ if ( d < 0 || d >= 16 )
break;
/* <f> == <f0> != <0f> */
- bytes[n / 2] = (FT_Byte)( ( n % 2 ) ? bytes[n / 2] + b
- : b * 16 );
+ bytes[n / 2] = (FT_Byte)( ( n % 2 ) ? bytes[n / 2] + d
+ : d * 16 );
}
- skip_spaces( &cur, limit );
-
- if ( *cur != '>' )
+ if ( delimiters )
{
- error = PSaux_Err_Invalid_File_Format;
- goto Exit;
+ if ( cur < limit && *cur != '>' )
+ {
+ error = PSaux_Err_Invalid_File_Format;
+ goto Exit;
+ }
+
+ cur++;
}
- *cursor = ++cur;
+ *acur = cur;
Exit:
*pnum_bytes = ( n + 1 ) / 2;
@@ -616,22 +850,23 @@
}
+ /* first character must be already part of the number */
+
static FT_Long
- t1_tofixed( FT_Byte** cursor,
+ ps_tofixed( FT_Byte* *acur,
FT_Byte* limit,
FT_Long power_ten )
{
- FT_Byte* cur = *cursor;
+ FT_Byte* cur = *acur;
FT_Long num, divider, result;
FT_Int sign = 0;
- FT_Byte d;
if ( cur >= limit )
return 0;
/* first of all, check the sign */
- if ( *cur == '-' )
+ if ( *cur == '-' && cur + 1 < limit )
{
sign = 1;
cur++;
@@ -639,7 +874,7 @@
/* then, read the integer part, if any */
if ( *cur != '.' )
- result = t1_toint( &cur, limit ) << 16;
+ result = ps_toint( &cur, limit ) << 16;
else
result = 0;
@@ -656,8 +891,14 @@
for (;;)
{
- d = (FT_Byte)( *cur - '0' );
- if ( d >= 10 )
+ int d;
+
+
+ if ( *cur OP 0x80 )
+ break;
+
+ d = ft_char_table[*cur & 0x7F];
+ if ( d < 0 || d >= 10 )
break;
if ( divider < 10000000L )
@@ -676,7 +917,7 @@
if ( cur + 1 < limit && ( *cur == 'e' || *cur == 'E' ) )
{
cur++;
- power_ten += t1_toint( &cur, limit );
+ power_ten += ps_toint( &cur, limit );
}
Exit:
@@ -701,18 +942,20 @@
if ( sign )
result = -result;
- *cursor = cur;
+ *acur = cur;
return result;
}
+ /* first character must be a delimiter or a part of a number */
+
static FT_Int
- t1_tocoordarray( FT_Byte** cursor,
+ ps_tocoordarray( FT_Byte* *acur,
FT_Byte* limit,
FT_Int max_coords,
FT_Short* coords )
{
- FT_Byte* cur = *cursor;
+ FT_Byte* cur = *acur;
FT_Int count = 0;
FT_Byte c, ender;
@@ -720,8 +963,8 @@
if ( cur >= limit )
goto Exit;
- /* check for the beginning of an array; if not, only one number will */
- /* be read */
+ /* check for the beginning of an array; otherwise, only one number */
+ /* will be read */
c = *cur;
ender = 0;
@@ -735,24 +978,23 @@
cur++;
/* now, read the coordinates */
- for ( ; cur < limit; )
+ while ( cur < limit )
{
/* skip whitespace in front of data */
- for (;;)
- {
- c = *cur;
- if ( c != ' ' && c != '\t' )
- break;
+ skip_spaces( &cur, limit );
+ if ( cur >= limit )
+ goto Exit;
- cur++;
- if ( cur >= limit )
- goto Exit;
- }
+ if ( count >= max_coords )
+ break;
- if ( count >= max_coords || c == ender )
+ if ( c == ender )
+ {
+ cur++;
break;
+ }
- coords[count] = (FT_Short)( t1_tofixed( &cur, limit, 0 ) >> 16 );
+ coords[count] = (FT_Short)( ps_tofixed( &cur, limit, 0 ) >> 16 );
count++;
if ( !ender )
@@ -760,27 +1002,30 @@
}
Exit:
- *cursor = cur;
+ *acur = cur;
return count;
}
+ /* first character must be a delimiter or a part of a number */
+
static FT_Int
- t1_tofixedarray( FT_Byte** cursor,
+ ps_tofixedarray( FT_Byte* *acur,
FT_Byte* limit,
FT_Int max_values,
FT_Fixed* values,
FT_Int power_ten )
{
- FT_Byte* cur = *cursor;
+ FT_Byte* cur = *acur;
FT_Int count = 0;
FT_Byte c, ender;
- if ( cur >= limit ) goto Exit;
+ if ( cur >= limit )
+ goto Exit;
- /* check for the beginning of an array. If not, only one number will */
- /* be read */
+ /* Check for the beginning of an array. Otherwise, only one number */
+ /* will be read. */
c = *cur;
ender = 0;
@@ -794,24 +1039,23 @@
cur++;
/* now, read the values */
- for ( ; cur < limit; )
+ while ( cur < limit )
{
/* skip whitespace in front of data */
- for (;;)
- {
- c = *cur;
- if ( c != ' ' && c != '\t' )
- break;
+ skip_spaces( &cur, limit );
+ if ( cur >= limit )
+ goto Exit;
- cur++;
- if ( cur >= limit )
- goto Exit;
- }
+ if ( count >= max_values )
+ break;
- if ( count >= max_values || c == ender )
+ if ( c == ender )
+ {
+ cur++;
break;
+ }
- values[count] = t1_tofixed( &cur, limit, power_ten );
+ values[count] = ps_tofixed( &cur, limit, power_ten );
count++;
if ( !ender )
@@ -819,7 +1063,7 @@
}
Exit:
- *cursor = cur;
+ *acur = cur;
return count;
}
@@ -827,7 +1071,7 @@
#if 0
static FT_String*
- t1_tostring( FT_Byte** cursor,
+ ps_tostring( FT_Byte** cursor,
FT_Byte* limit,
FT_Memory memory )
{
@@ -887,40 +1131,41 @@
static int
- t1_tobool( FT_Byte** cursor,
+ ps_tobool( FT_Byte* *acur,
FT_Byte* limit )
{
- FT_Byte* cur = *cursor;
+ FT_Byte* cur = *acur;
FT_Bool result = 0;
/* return 1 if we find `true', 0 otherwise */
if ( cur + 3 < limit &&
- cur[0] == 't' &&
- cur[1] == 'r' &&
- cur[2] == 'u' &&
- cur[3] == 'e' )
+ cur[0] == 't' &&
+ cur[1] == 'r' &&
+ cur[2] == 'u' &&
+ cur[3] == 'e' )
{
result = 1;
cur += 5;
}
else if ( cur + 4 < limit &&
- cur[0] == 'f' &&
- cur[1] == 'a' &&
- cur[2] == 'l' &&
- cur[3] == 's' &&
- cur[4] == 'e' )
+ cur[0] == 'f' &&
+ cur[1] == 'a' &&
+ cur[2] == 'l' &&
+ cur[3] == 's' &&
+ cur[4] == 'e' )
{
result = 0;
cur += 6;
}
- *cursor = cur;
+ *acur = cur;
return result;
}
- /* Load a simple field (i.e. non-table) into the current list of objects */
+ /* load a simple field (i.e. non-table) into the current list of objects */
+
FT_LOCAL_DEF( FT_Error )
ps_parser_load_field( PS_Parser parser,
const T1_Field field,
@@ -936,6 +1181,7 @@
FT_Error error;
+ /* this also skips leading whitespace */
ps_parser_to_token( parser, &token );
if ( !token.type )
goto Fail;
@@ -945,7 +1191,7 @@
cur = token.start;
limit = token.limit;
- /* we must detect arrays */
+ /* we must detect arrays in /FontBBox */
if ( field->type == T1_FIELD_TYPE_BBOX )
{
T1_TokenRec token2;
@@ -953,8 +1199,9 @@
FT_Byte* old_limit = parser->limit;
- parser->cursor = token.start;
- parser->limit = token.limit;
+ /* don't include delimiters */
+ parser->cursor = token.start + 1;
+ parser->limit = token.limit - 1;
ps_parser_to_token( parser, &token2 );
parser->cursor = old_cur;
@@ -966,12 +1213,16 @@
else if ( token.type == T1_TOKEN_TYPE_ARRAY )
{
FieldArray:
- /* if this is an array, and we have no blend, an error occurs */
+ /* if this is an array and we have no blend, an error occurs */
if ( max_objects == 0 )
goto Fail;
count = max_objects;
- idx = 1;
+ idx = 1;
+
+ /* don't include delimiters */
+ cur++;
+ limit--;
}
for ( ; count > 0; count--, idx++ )
@@ -981,23 +1232,25 @@
FT_String* string;
+ skip_spaces( &cur, limit );
+
switch ( field->type )
{
case T1_FIELD_TYPE_BOOL:
- val = t1_tobool( &cur, limit );
+ val = ps_tobool( &cur, limit );
goto Store_Integer;
case T1_FIELD_TYPE_FIXED:
- val = t1_tofixed( &cur, limit, 0 );
+ val = ps_tofixed( &cur, limit, 0 );
goto Store_Integer;
case T1_FIELD_TYPE_FIXED_1000:
- val = t1_tofixed( &cur, limit, 3 );
+ val = ps_tofixed( &cur, limit, 3 );
goto Store_Integer;
case T1_FIELD_TYPE_INTEGER:
- val = t1_toint( &cur, limit );
- goto Store_Integer;
+ val = ps_toint( &cur, limit );
+ /* fall through */
Store_Integer:
switch ( field->size )
@@ -1026,15 +1279,25 @@
FT_UInt len = (FT_UInt)( limit - cur );
- /* with synthetic fonts, it's possible to find a field twice */
+ if ( cur >= limit )
+ break;
+
+ /* with synthetic fonts, it is possible to find a field twice */
if ( *(FT_String**)q )
break;
if ( field->type == T1_FIELD_TYPE_KEY )
{
+ /* don't include leading `/' */
len--;
cur++;
}
+ else
+ {
+ /* don't include delimiting parentheses */
+ cur++;
+ len -= 2;
+ }
if ( FT_ALLOC( string, len + 1 ) )
goto Exit;
@@ -1052,10 +1315,7 @@
FT_BBox* bbox = (FT_BBox*)q;
- /* we need the '[' and ']' delimiters */
- token.start--;
- token.limit++;
- (void)t1_tofixedarray( &token.start, token.limit, 4, temp, 0 );
+ (void)ps_tofixedarray( &token.start, token.limit, 4, temp, 0 );
bbox->xMin = FT_RoundFix( temp[0] );
bbox->yMin = FT_RoundFix( temp[1] );
@@ -1070,7 +1330,7 @@
}
}
-#if 0 /* obsolete - keep for reference */
+#if 0 /* obsolete -- keep for reference */
if ( pflags )
*pflags |= 1L << field->flag_bit;
#else
@@ -1113,7 +1373,8 @@
fieldrec.type = T1_FIELD_TYPE_FIXED;
#endif
- ps_parser_to_token_array( parser, elements, 32, &num_elements );
+ ps_parser_to_token_array( parser, elements,
+ T1_MAX_TABLE_ELEMENTS, &num_elements );
if ( num_elements < 0 )
goto Fail;
@@ -1159,21 +1420,25 @@
FT_LOCAL_DEF( FT_Long )
ps_parser_to_int( PS_Parser parser )
{
- return t1_toint( &parser->cursor, parser->limit );
+ ps_parser_skip_spaces( parser );
+ return ps_toint( &parser->cursor, parser->limit );
}
FT_LOCAL_DEF( FT_Error )
ps_parser_to_bytes( PS_Parser parser,
FT_Byte* bytes,
- FT_Int max_bytes,
- FT_Int* pnum_bytes )
+ FT_Long max_bytes,
+ FT_Long* pnum_bytes,
+ FT_Bool delimiters )
{
+ ps_parser_skip_spaces( parser );
return ps_tobytes( &parser->cursor,
parser->limit,
max_bytes,
bytes,
- pnum_bytes );
+ pnum_bytes,
+ delimiters );
}
@@ -1181,7 +1446,8 @@
ps_parser_to_fixed( PS_Parser parser,
FT_Int power_ten )
{
- return t1_tofixed( &parser->cursor, parser->limit, power_ten );
+ ps_parser_skip_spaces( parser );
+ return ps_tofixed( &parser->cursor, parser->limit, power_ten );
}
@@ -1190,7 +1456,8 @@
FT_Int max_coords,
FT_Short* coords )
{
- return t1_tocoordarray( &parser->cursor, parser->limit,
+ ps_parser_skip_spaces( parser );
+ return ps_tocoordarray( &parser->cursor, parser->limit,
max_coords, coords );
}
@@ -1201,7 +1468,8 @@
FT_Fixed* values,
FT_Int power_ten )
{
- return t1_tofixedarray( &parser->cursor, parser->limit,
+ ps_parser_skip_spaces( parser );
+ return ps_tofixedarray( &parser->cursor, parser->limit,
max_values, values, power_ten );
}
@@ -1211,14 +1479,14 @@
FT_LOCAL_DEF( FT_String* )
T1_ToString( PS_Parser parser )
{
- return t1_tostring( &parser->cursor, parser->limit, parser->memory );
+ return ps_tostring( &parser->cursor, parser->limit, parser->memory );
}
FT_LOCAL_DEF( FT_Bool )
T1_ToBool( PS_Parser parser )
{
- return t1_tobool( &parser->cursor, parser->limit );
+ return ps_tobool( &parser->cursor, parser->limit );
}
#endif /* 0 */
@@ -1230,7 +1498,7 @@
FT_Byte* limit,
FT_Memory memory )
{
- parser->error = 0;
+ parser->error = PSaux_Err_Ok;
parser->base = base;
parser->limit = limit;
parser->cursor = base;
diff --git a/src/psaux/psobjs.h b/src/psaux/psobjs.h
index 528efc3..c2cbf2c 100644
--- a/src/psaux/psobjs.h
+++ b/src/psaux/psobjs.h
@@ -78,7 +78,7 @@ FT_BEGIN_HEADER
ps_parser_skip_spaces( PS_Parser parser );
FT_LOCAL( void )
- ps_parser_skip_alpha( PS_Parser parser );
+ ps_parser_skip_PS_token( PS_Parser parser );
FT_LOCAL( void )
ps_parser_to_token( PS_Parser parser,
@@ -111,8 +111,9 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
ps_parser_to_bytes( PS_Parser parser,
FT_Byte* bytes,
- FT_Int max_bytes,
- FT_Int* pnum_bytes );
+ FT_Long max_bytes,
+ FT_Long* pnum_bytes,
+ FT_Bool delimiters );
FT_LOCAL( FT_Fixed )
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 6bc7b92..0440e21 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -41,11 +41,10 @@
/* */
/* All other common cases are handled very simply. The matching rules */
/* are defined in the file `t1tokens.h' through the use of several */
- /* macros calls PARSE_XXX. */
- /* */
- /* This file is included twice here; the first time to generate parsing */
- /* callback functions, the second to generate a table of keywords (with */
- /* pointers to the associated callback). */
+ /* macros calls PARSE_XXX. This file is included twice here; the first */
+ /* time to generate parsing callback functions, the second time to */
+ /* generate a table of keywords (with pointers to the associated */
+ /* callback functions). */
/* */
/* The function `parse_dict' simply scans *linearly* a given dictionary */
/* (either the top-level or private one) and calls the appropriate */
@@ -71,7 +70,6 @@
#include "t1errors.h"
-
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -100,7 +98,7 @@
{
PS_Blend blend;
FT_Memory memory = face->root.memory;
- FT_Error error = 0;
+ FT_Error error = T1_Err_Ok;
blend = face->blend;
@@ -174,7 +172,7 @@
return error;
Fail:
- error = -1;
+ error = T1_Err_Invalid_File_Format;
goto Exit;
}
@@ -205,8 +203,10 @@
axis->minimum = map->design_points[0];
axis->maximum = map->design_points[map->num_points - 1];
}
- error = 0;
+
+ error = T1_Err_Ok;
}
+
return error;
}
@@ -253,6 +253,7 @@
error = T1_Err_Ok;
}
+
return error;
}
@@ -289,7 +290,7 @@
FT_Fixed p_design = designs[p];
- /* exact match ? */
+ /* exact match? */
if ( design == p_design )
{
the_blend = blends[p];
@@ -305,7 +306,7 @@
before = p;
}
- /* now, interpolate if needed */
+ /* now interpolate if necessary */
if ( before < 0 )
the_blend = blends[0];
@@ -386,9 +387,9 @@
parse_blend_axis_types( T1_Face face,
T1_Loader loader )
{
- T1_TokenRec axis_tokens[ T1_MAX_MM_AXIS ];
+ T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
FT_Int n, num_axis;
- FT_Error error = 0;
+ FT_Error error = T1_Err_Ok;
PS_Blend blend;
FT_Memory memory;
@@ -448,16 +449,16 @@
parse_blend_design_positions( T1_Face face,
T1_Loader loader )
{
- T1_TokenRec design_tokens[ T1_MAX_MM_DESIGNS ];
+ T1_TokenRec design_tokens[T1_MAX_MM_DESIGNS];
FT_Int num_designs;
FT_Int num_axis;
T1_Parser parser = &loader->parser;
- FT_Error error = 0;
+ FT_Error error = T1_Err_Ok;
PS_Blend blend;
- /* get the array of design tokens - compute number of designs */
+ /* get the array of design tokens -- compute number of designs */
T1_ToTokenArray( parser, design_tokens, T1_MAX_MM_DESIGNS, &num_designs );
if ( num_designs <= 0 || num_designs > T1_MAX_MM_DESIGNS )
{
@@ -479,15 +480,15 @@
for ( n = 0; n < (FT_UInt)num_designs; n++ )
{
- T1_TokenRec axis_tokens[ T1_MAX_MM_DESIGNS ];
+ T1_TokenRec axis_tokens[T1_MAX_MM_DESIGNS];
T1_Token token;
FT_Int axis, n_axis;
/* read axis/coordinates tokens */
token = design_tokens + n;
- parser->root.cursor = token->start - 1;
- parser->root.limit = token->limit + 1;
+ parser->root.cursor = token->start;
+ parser->root.limit = token->limit;
T1_ToTokenArray( parser, axis_tokens, T1_MAX_MM_AXIS, &n_axis );
if ( n == 0 )
@@ -505,7 +506,7 @@
goto Exit;
}
- /* now, read each axis token into the design position */
+ /* now read each axis token into the design position */
for ( axis = 0; axis < n_axis; axis++ )
{
T1_Token token2 = axis_tokens + axis;
@@ -530,7 +531,7 @@
parse_blend_design_map( T1_Face face,
T1_Loader loader )
{
- FT_Error error = 0;
+ FT_Error error = T1_Err_Ok;
T1_Parser parser = &loader->parser;
PS_Blend blend;
T1_TokenRec axis_tokens[T1_MAX_MM_AXIS];
@@ -548,6 +549,7 @@
error = T1_Err_Invalid_File_Format;
goto Exit;
}
+
old_cursor = parser->root.cursor;
old_limit = parser->root.limit;
@@ -556,29 +558,22 @@
goto Exit;
blend = face->blend;
- /* now, read each axis design map */
+ /* now read each axis design map */
for ( n = 0; n < num_axis; n++ )
{
PS_DesignMap map = blend->design_map + n;
- T1_Token token;
+ T1_Token axis_token;
+ T1_TokenRec point_tokens[T1_MAX_MM_MAP_POINTS];
FT_Int p, num_points;
- token = axis_tokens + n;
- parser->root.cursor = token->start;
- parser->root.limit = token->limit;
-
- /* count the number of map points */
- {
- FT_Byte* ptr = token->start;
- FT_Byte* limit = token->limit;
+ axis_token = axis_tokens + n;
+ parser->root.cursor = axis_token->start;
+ parser->root.limit = axis_token->limit;
+ T1_ToTokenArray( parser, point_tokens,
+ T1_MAX_MM_MAP_POINTS, &num_points );
- num_points = 0;
- for ( ; ptr < limit; ptr++ )
- if ( ptr[0] == '[' )
- num_points++;
- }
if ( num_points <= 0 || num_points > T1_MAX_MM_MAP_POINTS )
{
FT_ERROR(( "parse_blend_design_map: incorrect table\n" ));
@@ -594,6 +589,15 @@
for ( p = 0; p < num_points; p++ )
{
+ T1_Token point_token;
+
+
+ point_token = point_tokens + p;
+
+ /* don't include delimiting brackets */
+ parser->root.cursor = point_token->start + 1;
+ parser->root.limit = point_token->limit - 1;
+
map->design_points[p] = T1_ToInt( parser );
map->blend_points [p] = T1_ToFixed( parser, 0 );
}
@@ -611,7 +615,7 @@
parse_weight_vector( T1_Face face,
T1_Loader loader )
{
- FT_Error error = 0;
+ FT_Error error = T1_Err_Ok;
T1_Parser parser = &loader->parser;
PS_Blend blend = face->blend;
T1_TokenRec master;
@@ -638,8 +642,9 @@
old_cursor = parser->root.cursor;
old_limit = parser->root.limit;
- parser->root.cursor = master.start;
- parser->root.limit = master.limit;
+ /* don't include the delimiting brackets */
+ parser->root.cursor = master.start + 1;
+ parser->root.limit = master.limit - 1;
for ( n = 0; n < blend->num_designs; n++ )
{
@@ -675,6 +680,8 @@
#endif /* T1_CONFIG_OPTION_NO_MM_SUPPORT */
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
@@ -683,15 +690,6 @@
/*************************************************************************/
/*************************************************************************/
-
- /*************************************************************************/
- /* */
- /* First of all, define the token field static variables. This is a set */
- /* of T1_FieldRec variables used later. */
- /* */
- /*************************************************************************/
-
-
static FT_Error
t1_load_keyword( T1_Face face,
T1_Loader loader,
@@ -774,33 +772,13 @@
static int
is_space( FT_Byte c )
{
- return ( c == ' ' || c == '\t' || c == '\r' || c == '\n' );
+ return ( c == ' ' || c == '\t' ||
+ c == '\r' || c == '\n' || c == '\f' ||
+ c == '\0' );
}
static int
- is_name_char( FT_Byte c )
- {
- /* Note: PostScript allows any non-delimiting, non-whitespace */
- /* in a name (PS Ref Manual, 3rd Ed, p31) */
- /* PostScript delimiters include (,),<,>,[,],{,},/ and % */
-
- return ( c != '(' &&
- c != ')' &&
- c != '<' &&
- c != '>' &&
- c != '[' &&
- c != ']' &&
- c != '{' &&
- c != '}' &&
- c != '/' &&
- c != '%' &&
- ! is_space( c )
- );
- }
-
-
- static int
read_binary_data( T1_Parser parser,
FT_Long* size,
FT_Byte** base )
@@ -815,14 +793,14 @@
/* */
T1_Skip_Spaces( parser );
+
cur = parser->root.cursor;
- if ( cur < limit && (FT_Byte)( *cur - '0' ) < 10 )
+ if ( cur < limit && ft_isdigit( *cur ) )
{
*size = T1_ToInt( parser );
- T1_Skip_Spaces( parser );
- T1_Skip_Alpha ( parser ); /* `RD' or `-|' or something else */
+ T1_Skip_PS_Token( parser ); /* `RD' or `-|' or something else */
/* there is only one whitespace char after the */
/* `RD' or `-|' token */
@@ -838,9 +816,8 @@
}
- /* we will now define the routines used to handle */
- /* the `/Encoding', `/Subrs', and `/CharStrings' */
- /* dictionaries */
+ /* We now define the routines to handle the `/Encoding', `/Subrs', */
+ /* and `/CharStrings' dictionaries. */
static void
parse_font_matrix( T1_Face face,
@@ -855,7 +832,7 @@
if ( matrix->xx || matrix->yx )
- /* with synthetic fonts, it's possible we get here twice */
+ /* with synthetic fonts it is possible we get here twice */
return;
(void)T1_ToFixedArray( parser, 6, temp, 3 );
@@ -895,28 +872,25 @@
parse_encoding( T1_Face face,
T1_Loader loader )
{
- T1_Parser parser = &loader->parser;
- FT_Byte* cur = parser->root.cursor;
- FT_Byte* limit = parser->root.limit;
+ T1_Parser parser = &loader->parser;
+ FT_Byte* cur;
+ FT_Byte* limit = parser->root.limit;
- PSAux_Service psaux = (PSAux_Service)face->psaux;
+ PSAux_Service psaux = (PSAux_Service)face->psaux;
- /* skip whitespace */
- while ( is_space( *cur ) )
+ T1_Skip_Spaces( parser );
+ cur = parser->root.cursor;
+ if ( cur >= limit )
{
- cur++;
- if ( cur >= limit )
- {
- FT_ERROR(( "parse_encoding: out of bounds!\n" ));
- parser->root.error = T1_Err_Invalid_File_Format;
- return;
- }
+ FT_ERROR(( "parse_encoding: out of bounds!\n" ));
+ parser->root.error = T1_Err_Invalid_File_Format;
+ return;
}
/* if we have a number, then the encoding is an array, */
/* and we must load it now */
- if ( (FT_Byte)( *cur - '0' ) < 10 )
+ if ( ft_isdigit( *cur ) )
{
T1_Encoding encode = &face->type1.encoding;
FT_Int count, n;
@@ -926,18 +900,19 @@
if ( encode->char_index )
- /* with synthetic fonts, it's possible we get here twice */
+ /* with synthetic fonts it is possible we get here twice */
return;
- /* read the number of entries in the encoding, should be 256 */
+ /* read the number of entries in the encoding; should be 256 */
count = (FT_Int)T1_ToInt( parser );
- if ( parser->root.error )
+ T1_Skip_Spaces( parser );
+ if ( parser->root.cursor >= limit )
return;
/* we use a T1_Table to store our charnames */
loader->num_chars = encode->num_chars = count;
- if ( FT_NEW_ARRAY( encode->char_index, count ) ||
- FT_NEW_ARRAY( encode->char_name, count ) ||
+ if ( FT_NEW_ARRAY( encode->char_index, count ) ||
+ FT_NEW_ARRAY( encode->char_name, count ) ||
FT_SET_ERROR( psaux->ps_table_funcs->init(
char_table, count, memory ) ) )
{
@@ -954,86 +929,74 @@
T1_Add_Table( char_table, n, notdef, 8 );
}
- /* Now, we will need to read a record of the form */
+ /* Now we need to read a record of the form */
/* ... charcode /charname ... for each entry in our table */
/* */
/* We simply look for a number followed by an immediate */
/* name. Note that this ignores correctly the sequence */
- /* that is often seen in type1 fonts: */
+ /* that is often seen in Type 1 fonts: */
/* */
/* 0 1 255 { 1 index exch /.notdef put } for dup */
/* */
/* used to clean the encoding array before anything else. */
- /* */
- /* We stop when we encounter a `def'. */
- cur = parser->root.cursor;
- limit = parser->root.limit;
- n = 0;
+ n = 0;
- for ( ; cur < limit; )
+ while ( parser->root.cursor < limit )
{
- FT_Byte c;
-
-
- c = *cur;
+ T1_Skip_Spaces( parser );
+ cur = parser->root.cursor;
/* we stop when we encounter a `def' */
- if ( c == 'd' && cur + 3 < limit )
+ if ( *cur == 'd' && cur + 3 < limit )
{
- if ( cur[1] == 'e' &&
- cur[2] == 'f' &&
- is_space( cur[-1] ) &&
- is_space( cur[3] ) )
+ if ( cur[1] == 'e' &&
+ cur[2] == 'f' &&
+ is_space( cur[3] ) )
{
FT_TRACE6(( "encoding end\n" ));
+ cur += 3;
break;
}
}
/* otherwise, we must find a number before anything else */
- if ( (FT_Byte)( c - '0' ) < 10 )
+ if ( ft_isdigit( *cur ) )
{
FT_Int charcode;
- parser->root.cursor = cur;
charcode = (FT_Int)T1_ToInt( parser );
- cur = parser->root.cursor;
-
- /* skip whitespace */
- while ( cur < limit && is_space( *cur ) )
- cur++;
+ T1_Skip_Spaces( parser );
+ cur = parser->root.cursor;
- if ( cur < limit && *cur == '/' )
+ if ( *cur == '/' && cur + 2 < limit )
{
- /* bingo, we have an immediate name -- it must be a */
- /* character name */
- FT_Byte* cur2 = cur + 1;
FT_PtrDist len;
- while ( cur2 < limit && is_name_char( *cur2 ) )
- cur2++;
+ cur++;
+
+ parser->root.cursor = cur;
+ T1_Skip_PS_Token( parser );
- len = cur2 - cur - 1;
+ len = parser->root.cursor - cur;
parser->root.error = T1_Add_Table( char_table, charcode,
- cur + 1, len + 1 );
+ cur, len + 1 );
char_table->elements[charcode][len] = '\0';
if ( parser->root.error )
return;
-
- cur = cur2;
}
}
else
- cur++;
+ T1_Skip_PS_Token( parser );
}
face->type1.encoding_type = T1_ENCODING_TYPE_ARRAY;
parser->root.cursor = cur;
}
+
/* Otherwise, we should have either `StandardEncoding', */
/* `ExpertEncoding', or `ISOLatin1Encoding' */
else
@@ -1063,35 +1026,38 @@
parse_subrs( T1_Face face,
T1_Loader loader )
{
- T1_Parser parser = &loader->parser;
- PS_Table table = &loader->subrs;
- FT_Memory memory = parser->root.memory;
- FT_Error error;
- FT_Int n;
+ T1_Parser parser = &loader->parser;
+ PS_Table table = &loader->subrs;
+ FT_Memory memory = parser->root.memory;
+ FT_Error error;
+ FT_Int n;
PSAux_Service psaux = (PSAux_Service)face->psaux;
if ( loader->num_subrs )
- /* with synthetic fonts, it's possible we get here twice */
+ /* with synthetic fonts it is possible we get here twice */
return;
- if ( parser->root.cursor + 2 > parser->root.limit &&
- parser->root.cursor[0] == '[' &&
- parser->root.cursor[1] == ']' )
+ T1_Skip_Spaces( parser );
+
+ /* test for empty array */
+ if ( parser->root.cursor < parser->root.limit &&
+ *parser->root.cursor == '[' )
{
- /* empty array */
+ T1_Skip_PS_Token( parser );
+ T1_Skip_Spaces ( parser );
+ if ( parser->root.cursor >= parser->root.limit ||
+ *parser->root.cursor != ']' )
+ parser->root.error = T1_Err_Invalid_File_Format;
return;
}
loader->num_subrs = (FT_Int)T1_ToInt( parser );
- if ( parser->root.error )
- return;
/* position the parser right before the `dup' of the first subr */
- T1_Skip_Spaces( parser );
- T1_Skip_Alpha( parser ); /* `array' */
- T1_Skip_Spaces( parser );
+ T1_Skip_PS_Token( parser ); /* `array' */
+ T1_Skip_Spaces ( parser );
/* initialize subrs array */
error = psaux->ps_table_funcs->init( table, loader->num_subrs, memory );
@@ -1113,6 +1079,8 @@
if ( ft_strncmp( (char*)parser->root.cursor, "dup", 3 ) != 0 )
break;
+ T1_Skip_PS_Token( parser ); /* `dup' */
+
idx = T1_ToInt( parser );
if ( !read_binary_data( parser, &size, &base ) )
@@ -1122,14 +1090,13 @@
/* (bound to `noaccess put') or by two separate tokens: */
/* `noaccess' & `put'. We position the parser right */
/* before the next `dup', if any. */
- T1_Skip_Spaces( parser );
- T1_Skip_Alpha( parser ); /* `NP' or `I' or `noaccess' */
- T1_Skip_Spaces( parser );
+ T1_Skip_PS_Token( parser ); /* `NP' or `I' or `noaccess' */
+ T1_Skip_Spaces ( parser );
if ( ft_strncmp( (char*)parser->root.cursor, "put", 3 ) == 0 )
{
- T1_Skip_Alpha( parser ); /* skip `put' */
- T1_Skip_Spaces( parser );
+ T1_Skip_PS_Token( parser ); /* skip `put' */
+ T1_Skip_Spaces ( parser );
}
/* some fonts use a value of -1 for lenIV to indicate that */
@@ -1164,6 +1131,9 @@
}
+#define TABLE_EXTEND 5
+
+
static void
parse_charstrings( T1_Face face,
T1_Loader loader )
@@ -1185,25 +1155,24 @@
if ( loader->num_glyphs )
- /* with synthetic fonts, it's possible we get here twice */
+ /* with synthetic fonts it is possible we get here twice */
return;
loader->num_glyphs = (FT_Int)T1_ToInt( parser );
if ( parser->root.error )
return;
- /* initialize tables (leaving room for addition of .notdef, */
- /* if necessary). */
+ /* initialize tables, leaving room for addition of .notdef, */
+ /* if necessary, and a few other glyphs to handle buggy */
+ /* fonts which have more glyphs than specified. */
- error = psaux->ps_table_funcs->init( code_table,
- loader->num_glyphs + 1,
- memory );
+ error = psaux->ps_table_funcs->init(
+ code_table, loader->num_glyphs + 1 + TABLE_EXTEND, memory );
if ( error )
goto Fail;
- error = psaux->ps_table_funcs->init( name_table,
- loader->num_glyphs + 1,
- memory );
+ error = psaux->ps_table_funcs->init(
+ name_table, loader->num_glyphs + 1 + TABLE_EXTEND, memory );
if ( error )
goto Fail;
@@ -1235,29 +1204,34 @@
break;
/* we stop when we find a `def' or `end' keyword */
- if ( *cur == 'd' &&
- cur + 3 < limit &&
- cur[1] == 'e' &&
- cur[2] == 'f' )
- break;
+ if ( cur + 3 < limit && is_space( cur[3] ) )
+ {
+ if ( cur[0] == 'd' &&
+ cur[1] == 'e' &&
+ cur[2] == 'f' )
+ break;
- if ( *cur == 'e' &&
- cur + 3 < limit &&
- cur[1] == 'n' &&
- cur[2] == 'd' )
- break;
+ if ( cur[0] == 'e' &&
+ cur[1] == 'n' &&
+ cur[2] == 'd' )
+ break;
+ }
if ( *cur != '/' )
- T1_Skip_Alpha( parser );
+ T1_Skip_PS_Token( parser );
else
{
- FT_Byte* cur2 = cur + 1;
FT_PtrDist len;
- while ( cur2 < limit && is_name_char( *cur2 ) )
- cur2++;
- len = cur2 - cur - 1;
+ T1_Skip_PS_Token( parser );
+ if ( cur >= limit )
+ {
+ error = T1_Err_Invalid_File_Format;
+ goto Fail;
+ }
+
+ len = parser->root.cursor - cur;
error = T1_Add_Table( name_table, n, cur + 1, len + 1 );
if ( error )
@@ -1274,11 +1248,11 @@
notdef_found = 1;
}
- parser->root.cursor = cur2;
if ( !read_binary_data( parser, &size, &base ) )
return;
- if ( face->type1.private_dict.lenIV >= 0 )
+ if ( face->type1.private_dict.lenIV >= 0 &&
+ n < loader->num_glyphs + TABLE_EXTEND )
{
FT_Byte* temp;
@@ -1299,8 +1273,6 @@
goto Fail;
n++;
- if ( n >= loader->num_glyphs )
- break;
}
}
@@ -1311,11 +1283,11 @@
(const char*)name_table->elements[0] ) &&
notdef_found )
{
- /* Swap glyph in index 0 with /.notdef glyph. First, add index 0 */
- /* name and code entries to swap_table. Then place notdef_index name */
- /* and code entries into swap_table. Then swap name and code */
- /* entries at indices notdef_index and 0 using values stored in */
- /* swap_table. */
+ /* Swap glyph in index 0 with /.notdef glyph. First, add index 0 */
+ /* name and code entries to swap_table. Then place notdef_index */
+ /* name and code entries into swap_table. Then swap name and code */
+ /* entries at indices notdef_index and 0 using values stored in */
+ /* swap_table. */
/* Index 0 name */
error = T1_Add_Table( swap_table, 0,
@@ -1426,6 +1398,14 @@
}
+ /*************************************************************************/
+ /* */
+ /* Define the token field static variables. This is a set of */
+ /* T1_FieldRec variables. */
+ /* */
+ /*************************************************************************/
+
+
static
const T1_FieldRec t1_keywords[] =
{
@@ -1462,120 +1442,134 @@
FT_Byte* keyword_flags )
{
T1_Parser parser = &loader->parser;
+ FT_Byte* limit;
parser->root.cursor = base;
parser->root.limit = base + size;
- parser->root.error = 0;
+ parser->root.error = T1_Err_Ok;
+
+ limit = parser->root.limit;
+ while ( parser->root.cursor < limit )
{
- FT_Byte* cur = base;
- FT_Byte* limit = cur + size;
+ FT_Byte* cur;
- for ( ; cur < limit; cur++ )
+ T1_Skip_Spaces( parser );
+ cur = parser->root.cursor;
+
+ /* look for `FontDirectory', which causes problems for some fonts */
+ if ( *cur == 'F' && cur + 25 < limit &&
+ ft_strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
{
- /* look for `FontDirectory', which causes problems on some fonts */
- if ( *cur == 'F' && cur + 25 < limit &&
- ft_strncmp( (char*)cur, "FontDirectory", 13 ) == 0 )
- {
- FT_Byte* cur2;
+ FT_Byte* cur2;
- /* skip the `FontDirectory' keyword */
- cur += 13;
- cur2 = cur;
+ /* skip the `FontDirectory' keyword */
+ T1_Skip_PS_Token( parser );
+ T1_Skip_Spaces ( parser );
+ cur = cur2 = parser->root.cursor;
- /* lookup the `known' keyword */
- while ( cur < limit && *cur != 'k' &&
- ft_strncmp( (char*)cur, "known", 5 ) )
- cur++;
+ /* look up the `known' keyword */
+ while ( cur < limit )
+ {
+ if ( *cur == 'k' && cur + 5 < limit &&
+ ft_strncmp( (char*)cur, "known", 5 ) )
+ break;
- if ( cur < limit )
- {
- T1_TokenRec token;
+ T1_Skip_PS_Token( parser );
+ T1_Skip_Spaces ( parser );
+ cur = parser->root.cursor;
+ }
+ if ( cur < limit )
+ {
+ T1_TokenRec token;
- /* skip the `known' keyword and the token following it */
- cur += 5;
- loader->parser.root.cursor = cur;
- T1_ToToken( &loader->parser, &token );
- /* if the last token was an array, skip it! */
- if ( token.type == T1_TOKEN_TYPE_ARRAY )
- cur2 = parser->root.cursor;
- }
- cur = cur2;
+ /* skip the `known' keyword and the token following it */
+ T1_Skip_PS_Token( parser );
+ T1_ToToken( parser, &token );
+
+ /* if the last token was an array, skip it! */
+ if ( token.type == T1_TOKEN_TYPE_ARRAY )
+ cur2 = parser->root.cursor;
}
- /* look for immediates */
- else if ( *cur == '/' && cur + 2 < limit )
- {
- FT_Byte* cur2;
- FT_PtrDist len;
+ parser->root.cursor = cur2;
+ }
+
+ /* look for `closefile' which ends the eexec section */
+ else if ( *cur == 'c' && cur + 9 < limit &&
+ ft_strncmp( (char*)cur, "closefile", 9 ) == 0 )
+ break;
+
+ /* look for immediates */
+ else if ( *cur == '/' && cur + 2 < limit )
+ {
+ FT_PtrDist len;
+
+ cur++;
- cur++;
- cur2 = cur;
- while ( cur2 < limit && is_name_char( *cur2 ) )
- cur2++;
+ parser->root.cursor = cur;
+ T1_Skip_PS_Token( parser );
- len = cur2 - cur;
- if ( len > 0 && len < 22 )
+ len = parser->root.cursor - cur;
+
+ if ( len > 0 && len < 22 )
+ {
+ /* now compare the immediate name to the keyword table */
+ T1_Field keyword = (T1_Field)t1_keywords;
+ FT_Byte* keyword_flag = keyword_flags;
+
+
+ for (;;)
{
- {
- /* now, compare the immediate name to the keyword table */
- T1_Field keyword = (T1_Field)t1_keywords;
- FT_Byte* keyword_flag = keyword_flags;
+ FT_Byte* name;
- for (;;)
- {
- FT_Byte* name;
+ name = (FT_Byte*)keyword->ident;
+ if ( !name )
+ {
+ T1_Skip_PS_Token( parser );
+ break;
+ }
+
+ if ( cur[0] == name[0] &&
+ len == ft_strlen( (const char*)name ) )
+ {
+ FT_PtrDist n;
- name = (FT_Byte*)keyword->ident;
- if ( !name )
+ for ( n = 1; n < len; n++ )
+ if ( cur[n] != name[n] )
break;
- if ( cur[0] == name[0] &&
- len == ft_strlen( (const char*)name ) )
+ if ( n >= len )
+ {
+ /* We found it -- run the parsing callback! */
+ /* We only record the first instance of any */
+ /* field to deal adequately with synthetic fonts */
+ if ( keyword_flag[0] == 0 )
{
- FT_PtrDist n;
-
-
- for ( n = 1; n < len; n++ )
- if ( cur[n] != name[n] )
- break;
-
- if ( n >= len )
- {
- /* we found it -- run the parsing callback! */
- parser->root.cursor = cur2;
- T1_Skip_Spaces( parser );
-
- /* we only record the first instance of any */
- /* field to deal adequately with synthetic fonts */
- if ( keyword_flag[0] == 0 )
- {
- parser->root.error = t1_load_keyword( face,
- loader,
- keyword );
- if ( parser->root.error )
- return parser->root.error;
- }
- keyword_flag[0] = 1;
-
- cur = parser->root.cursor;
- break;
- }
+ parser->root.error = t1_load_keyword( face,
+ loader,
+ keyword );
+ if ( parser->root.error )
+ return parser->root.error;
}
- keyword++;
- keyword_flag++;
+ keyword_flag[0] = 1;
+ break;
}
}
+ keyword++;
+ keyword_flag++;
}
}
}
+ else
+ T1_Skip_PS_Token( parser );
}
return parser->root.error;
}
@@ -1742,16 +1736,21 @@
if ( ft_strcmp( (const char*)".notdef",
(const char*)glyph_name ) != 0 )
{
- if ( charcode < min_char ) min_char = charcode;
- if ( charcode > max_char ) max_char = charcode;
+ if ( charcode < min_char )
+ min_char = charcode;
+ if ( charcode > max_char )
+ max_char = charcode;
}
break;
}
}
}
- /* Yes, this happens: Certain PDF-embedded fonts have only a ".notdef"
- * glyph defined!
+
+ /*
+ * Yes, this happens: Certain PDF-embedded fonts have only a
+ * `.notdef' glyph defined!
*/
+
if ( min_char > max_char )
{
min_char = 0;
diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c
index d785aec..5a38063 100644
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -104,7 +104,7 @@
FT_Long size;
- psaux->ps_parser_funcs->init( &parser->root,0, 0, memory );
+ psaux->ps_parser_funcs->init( &parser->root, 0, 0, memory );
parser->stream = stream;
parser->base_len = 0;
@@ -219,36 +219,13 @@
}
- /* return the value of an hexadecimal digit */
- static int
- hexa_value( char c )
- {
- unsigned int d;
-
-
- d = (unsigned int)( c - '0' );
- if ( d <= 9 )
- return (int)d;
-
- d = (unsigned int)( c - 'a' );
- if ( d <= 5 )
- return (int)( d + 10 );
-
- d = (unsigned int)( c - 'A' );
- if ( d <= 5 )
- return (int)( d + 10 );
-
- return -1;
- }
-
-
FT_LOCAL_DEF( FT_Error )
T1_Get_Private_Dict( T1_Parser parser,
PSAux_Service psaux )
{
FT_Stream stream = parser->stream;
FT_Memory memory = parser->root.memory;
- FT_Error error = 0;
+ FT_Error error = T1_Err_Ok;
FT_Long size;
@@ -302,7 +279,8 @@
break;
}
- if ( FT_STREAM_READ( parser->private_dict + parser->private_len, size ) )
+ if ( FT_STREAM_READ( parser->private_dict + parser->private_len,
+ size ) )
goto Fail;
parser->private_len += size;
@@ -310,9 +288,9 @@
}
else
{
- /* we have already `loaded' the whole PFA font file into memory; */
+ /* We have already `loaded' the whole PFA font file into memory; */
/* if this is a memory resource, allocate a new block to hold */
- /* the private dict. Otherwise, simply overwrite into the base */
+ /* the private dict. Otherwise, simply overwrite into the base */
/* dictionary block in the heap. */
/* first of all, look at the `eexec' keyword */
@@ -330,7 +308,7 @@
if ( cur[1] == 'e' && cur[2] == 'x' &&
cur[3] == 'e' && cur[4] == 'c' )
{
- cur += 6; /* we skip the newling after the `eexec' */
+ cur += 6; /* we skip the newline after the `eexec' */
/* XXX: Some fonts use DOS-linefeeds, i.e. \r\n; we need to */
/* skip the extra \n if we find it */
@@ -379,51 +357,38 @@
/* the `eexec' keyword); if they all are hexadecimal digits, then */
/* we have a case of ASCII storage */
- if ( ( hexa_value( cur[0] ) | hexa_value( cur[1] ) |
- hexa_value( cur[2] ) | hexa_value( cur[3] ) ) < 0 )
-
- /* binary encoding -- `simply' copy the private dict */
- FT_MEM_COPY( parser->private_dict, cur, size );
-
- else
+ if ( ft_isxdigit( cur[0] ) && ft_isxdigit( cur[1] ) &&
+ ft_isxdigit( cur[2] ) && ft_isxdigit( cur[3] ) )
{
/* ASCII hexadecimal encoding */
+ FT_Long len;
- FT_Byte* write;
- FT_Int count;
-
- write = parser->private_dict;
- count = 0;
-
- for ( ;cur < limit; cur++ )
- {
- int hex1;
-
-
- /* check for newline */
- if ( cur[0] == '\r' || cur[0] == '\n' )
- continue;
-
- /* exit if we have a non-hexadecimal digit that isn't a newline */
- hex1 = hexa_value( cur[0] );
- if ( hex1 < 0 || cur + 1 >= limit )
- break;
-
- /* otherwise, store byte */
- *write++ = (FT_Byte)( ( hex1 << 4 ) | hexa_value( cur[1] ) );
- count++;
- cur++;
- }
+ parser->root.cursor = cur;
+ (void)psaux->ps_parser_funcs->to_bytes( &parser->root,
+ parser->private_dict,
+ parser->private_len,
+ &len,
+ 0 );
+ parser->private_len = len;
/* put a safeguard */
- parser->private_len = write - parser->private_dict;
- *write++ = 0;
+ parser->private_dict[len] = '\0';
}
+ else
+ /* binary encoding -- copy the private dict */
+ FT_MEM_COPY( parser->private_dict, cur, size );
}
/* we now decrypt the encoded binary private dictionary */
psaux->t1_decrypt( parser->private_dict, parser->private_len, 55665U );
+
+ /* replace the four random bytes at the beginning with whitespace */
+ parser->private_dict[0] = ' ';
+ parser->private_dict[1] = ' ';
+ parser->private_dict[2] = ' ';
+ parser->private_dict[3] = ' ';
+
parser->root.base = parser->private_dict;
parser->root.cursor = parser->private_dict;
parser->root.limit = parser->root.cursor + parser->private_len;
diff --git a/src/type1/t1parse.h b/src/type1/t1parse.h
index ecc2067..6fa4ca6 100644
--- a/src/type1/t1parse.h
+++ b/src/type1/t1parse.h
@@ -4,7 +4,7 @@
/* */
/* Type 1 parser (specification). */
/* */
-/* Copyright 1996-2001, 2002 by */
+/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -69,9 +69,9 @@ FT_BEGIN_HEADER
FT_Byte* private_dict;
FT_Long private_len;
- FT_Byte in_pfb;
- FT_Byte in_memory;
- FT_Byte single_block;
+ FT_Bool in_pfb;
+ FT_Bool in_memory;
+ FT_Bool single_block;
} T1_ParserRec, *T1_Parser;
@@ -91,8 +91,8 @@ FT_BEGIN_HEADER
} while ( 0 )
-#define T1_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
-#define T1_Skip_Alpha( p ) (p)->root.funcs.skip_alpha ( &(p)->root )
+#define T1_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
+#define T1_Skip_PS_Token( p ) (p)->root.funcs.skip_PS_token( &(p)->root )
#define T1_ToInt( p ) (p)->root.funcs.to_int( &(p)->root )
#define T1_ToFixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t )
diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c
index 071c6ec..7ce4707 100644
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -111,8 +111,8 @@
(p)->funcs.release( p ); \
} while ( 0 )
-#define T1_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
-#define T1_Skip_Alpha( p ) (p)->root.funcs.skip_alpha ( &(p)->root )
+#define T1_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root )
+#define T1_Skip_PS_Token( p ) (p)->root.funcs.skip_PS_token( &(p)->root )
#define T1_ToInt( p ) (p)->root.funcs.to_int( &(p)->root )
#define T1_ToFixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t )
@@ -318,7 +318,7 @@
/* if we have a number, then the encoding is an array, */
/* and we must load it now */
- if ( (FT_Byte)( *cur - '0' ) < 10 )
+ if ( ft_isdigit( *cur ) )
{
T1_Encoding encode = &face->type1.encoding;
FT_Int count, n;
@@ -394,7 +394,7 @@
}
/* otherwise, we must find a number before anything else */
- if ( (FT_Byte)( c - '0' ) < 10 )
+ if ( ft_isdigit( c ) )
{
FT_Int charcode;
@@ -571,7 +571,7 @@
}
default:
- if ( !ft_xdigit( *cur ) || !ft_xdigit( *(cur + 1) ) )
+ if ( !ft_isxdigit( *cur ) || !ft_isxdigit( *(cur + 1) ) )
{
FT_ERROR(( "t42_parse_sfnts: found non-hex characters in string" ));
error = T42_Err_Invalid_File_Format;
@@ -705,7 +705,7 @@
break;
if ( *cur != '/' )
- T1_Skip_Alpha( parser );
+ T1_Skip_PS_Token( parser );
else
{
FT_Byte* cur2 = cur + 1;