/usr/share/pyshared/pyx/font/afmfile.py is in python-pyx 0.12.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | # -*- encoding: utf-8 -*-
#
#
# Copyright (C) 2006-2011 Jörg Lehmann <joergl@users.sourceforge.net>
# Copyright (C) 2007-2011 André Wobst <wobsta@users.sourceforge.net>
#
# This file is part of PyX (http://pyx.sourceforge.net/).
#
# PyX is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PyX is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyX; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import string
import metric
unicodestring = {u" ": "space",
u"!": "exclam",
u"\"": "quotedbl",
u"#": "numbersign",
u"$": "dollar",
u"%": "percent",
u"&": "ampersand",
u"'": "quotesingle",
u"(": "parenleft",
u")": "parenright",
u"*": "asterisk",
u"+": "plus",
u",": "comma",
u"-": "hyphen",
u".": "period",
u"/": "slash",
u"0": "zero",
u"1": "one",
u"2": "two",
u"3": "three",
u"4": "four",
u"5": "five",
u"6": "six",
u"7": "seven",
u"8": "eight",
u"9": "nine",
u":": "colon",
u";": "semicolon",
u"<": "less",
u"=": "equal",
u">": "greater",
u"?": "question",
u"@": "at",
u"A": "A",
u"B": "B",
u"C": "C",
u"D": "D",
u"E": "E",
u"F": "F",
u"G": "G",
u"H": "H",
u"I": "I",
u"J": "J",
u"K": "K",
u"L": "L",
u"M": "M",
u"N": "N",
u"O": "O",
u"P": "P",
u"Q": "Q",
u"R": "R",
u"S": "S",
u"T": "T",
u"U": "U",
u"V": "V",
u"W": "W",
u"X": "X",
u"Y": "Y",
u"Z": "Z",
u"[": "bracketleft",
u"\\": "backslash",
u"]": "bracketright",
u"^": "asciicircum",
u"_": "underscore",
u"`": "grave",
u"a": "a",
u"b": "b",
u"c": "c",
u"d": "d",
u"e": "e",
u"f": "f",
u"g": "g",
u"h": "h",
u"i": "i",
u"j": "j",
u"k": "k",
u"l": "l",
u"m": "m",
u"n": "n",
u"o": "o",
u"p": "p",
u"q": "q",
u"r": "r",
u"s": "s",
u"t": "t",
u"u": "u",
u"v": "v",
u"w": "w",
u"x": "x",
u"y": "y",
u"z": "z",
u"{": "braceleft",
u"|": "bar",
u"}": "braceright",
u"~": "asciitilde",
u"\xa0": "space",
u"\xa1": "exclamdown",
u"\xa2": "cent",
u"\xa3": "sterling",
u"\xa4": "currency",
u"\xa5": "yen",
u"\xa6": "brokenbar",
u"\xa7": "section",
u"\xa8": "dieresis",
u"\xa9": "copyright",
u"\xaa": "ordfeminine",
u"\xab": "guillemotleft",
u"\xac": "logicalnot",
u"\xad": "hyphen",
u"\xae": "registered",
u"\xaf": "macron",
u"\xb0": "degree",
u"\xb1": "plusminus",
u"\xb4": "acute",
u"\xb6": "paragraph",
u"\xb7": "periodcentered",
u"\xb8": "cedilla",
u"\xba": "ordmasculine",
u"\xbb": "guillemotright",
u"\xbc": "onequarter",
u"\xbd": "onehalf",
u"\xbe": "threequarters",
u"\xbf": "questiondown",
u"\xc0": "Agrave",
u"\xc1": "Aacute",
u"\xc2": "Acircumflex",
u"\xc3": "Atilde",
u"\xc4": "Adieresis",
u"\xc5": "Aring",
u"\xc6": "AE",
u"\xc7": "Ccedilla",
u"\xc8": "Egrave",
u"\xc9": "Eacute",
u"\xca": "Ecircumflex",
u"\xcb": "Edieresis",
u"\xcc": "Igrave",
u"\xcd": "Iacute",
u"\xce": "Icircumflex",
u"\xcf": "Idieresis",
u"\xd0": "Eth",
u"\xd1": "Ntilde",
u"\xd2": "Ograve",
u"\xd3": "Oacute",
u"\xd4": "Ocircumflex",
u"\xd5": "Otilde",
u"\xd6": "Odieresis",
u"\xd7": "multiply",
u"\xd8": "Oslash",
u"\xd9": "Ugrave",
u"\xda": "Uacute",
u"\xdb": "Ucircumflex",
u"\xdc": "Udieresis",
u"\xdd": "Yacute",
u"\xde": "Thorn",
u"\xdf": "germandbls",
u"\xe0": "agrave",
u"\xe1": "aacute",
u"\xe2": "acircumflex",
u"\xe3": "atilde",
u"\xe4": "adieresis",
u"\xe5": "aring",
u"\xe6": "ae",
u"\xe7": "ccedilla",
u"\xe8": "egrave",
u"\xe9": "eacute",
u"\xea": "ecircumflex",
u"\xeb": "edieresis",
u"\xec": "igrave",
u"\xed": "iacute",
u"\xee": "icircumflex",
u"\xef": "idieresis",
u"\xf0": "eth",
u"\xf1": "ntilde",
u"\xf2": "ograve",
u"\xf3": "oacute",
u"\xf4": "ocircumflex",
u"\xf5": "otilde",
u"\xf6": "odieresis",
u"\xf7": "divide",
u"\xf8": "oslash",
u"\xf9": "ugrave",
u"\xfa": "uacute",
u"\xfb": "ucircumflex",
u"\xfc": "udieresis",
u"\xfd": "yacute",
u"\xfe": "thorn",
u"\xff": "ydieresis",
u"\u0100": "Amacron",
u"\u0101": "amacron",
u"\u0102": "Abreve",
u"\u0103": "abreve",
u"\u0104": "Aogonek",
u"\u0105": "aogonek",
u"\u0106": "Cacute",
u"\u0107": "cacute",
u"\u0108": "Ccircumflex",
u"\u0109": "ccircumflex",
u"\u010a": "Cdotaccent",
u"\u010b": "cdotaccent",
u"\u010c": "Ccaron",
u"\u010d": "ccaron",
u"\u010e": "Dcaron",
u"\u010f": "dcaron",
u"\u0110": "Dcroat",
u"\u0111": "dcroat",
u"\u0112": "Emacron",
u"\u0113": "emacron",
u"\u0114": "Ebreve",
u"\u0115": "ebreve",
u"\u0116": "Edotaccent",
u"\u0117": "edotaccent",
u"\u0118": "Eogonek",
u"\u0119": "eogonek",
u"\u011a": "Ecaron",
u"\u011b": "ecaron",
u"\u011c": "Gcircumflex",
u"\u011d": "gcircumflex",
u"\u011e": "Gbreve",
u"\u011f": "gbreve",
u"\u0120": "Gdotaccent",
u"\u0121": "gdotaccent",
u"\u0122": "Gcommaaccent",
u"\u0123": "gcommaaccent",
u"\u0124": "Hcircumflex",
u"\u0125": "hcircumflex",
u"\u0126": "Hbar",
u"\u0127": "hbar",
u"\u0128": "Itilde",
u"\u0129": "itilde",
u"\u012a": "Imacron",
u"\u012b": "imacron",
u"\u012c": "Ibreve",
u"\u012d": "ibreve",
u"\u012e": "Iogonek",
u"\u012f": "iogonek",
u"\u0130": "Idotaccent",
u"\u0131": "dotlessi",
u"\u0132": "IJ",
u"\u0133": "ij",
u"\u0134": "Jcircumflex",
u"\u0135": "jcircumflex",
u"\u0136": "Kcommaaccent",
u"\u0137": "kcommaaccent",
u"\u0138": "kgreenlandic",
u"\u0139": "Lacute",
u"\u013a": "lacute",
u"\u013b": "Lcommaaccent",
u"\u013c": "lcommaaccent",
u"\u013d": "Lcaron",
u"\u013e": "lcaron",
u"\u013f": "Ldot",
u"\u0140": "ldot",
u"\u0141": "Lslash",
u"\u0142": "lslash",
u"\u0143": "Nacute",
u"\u0144": "nacute",
u"\u0145": "Ncommaaccent",
u"\u0146": "ncommaaccent",
u"\u0147": "Ncaron",
u"\u0148": "ncaron",
u"\u0149": "napostrophe",
u"\u014a": "Eng",
u"\u014b": "eng",
u"\u014c": "Omacron",
u"\u014d": "omacron",
u"\u014e": "Obreve",
u"\u014f": "obreve",
u"\u0150": "Ohungarumlaut",
u"\u0151": "ohungarumlaut",
u"\u0152": "OE",
u"\u0153": "oe",
u"\u0154": "Racute",
u"\u0155": "racute",
u"\u0156": "Rcommaaccent",
u"\u0157": "rcommaaccent",
u"\u0158": "Rcaron",
u"\u0159": "rcaron",
u"\u015a": "Sacute",
u"\u015b": "sacute",
u"\u015c": "Scircumflex",
u"\u015d": "scircumflex",
u"\u015e": "Scedilla",
u"\u015f": "scedilla",
u"\u0160": "Scaron",
u"\u0161": "scaron",
u"\u0162": "Tcommaaccent",
u"\u0163": "tcommaaccent",
u"\u0164": "Tcaron",
u"\u0165": "tcaron",
u"\u0166": "Tbar",
u"\u0167": "tbar",
u"\u0168": "Utilde",
u"\u0169": "utilde",
u"\u016a": "Umacron",
u"\u016b": "umacron",
u"\u016c": "Ubreve",
u"\u016d": "ubreve",
u"\u016e": "Uring",
u"\u016f": "uring",
u"\u0170": "Uhungarumlaut",
u"\u0171": "uhungarumlaut",
u"\u0172": "Uogonek",
u"\u0173": "uogonek",
u"\u0174": "Wcircumflex",
u"\u0175": "wcircumflex",
u"\u0176": "Ycircumflex",
u"\u0177": "ycircumflex",
u"\u0178": "Ydieresis",
u"\u0179": "Zacute",
u"\u017a": "zacute",
u"\u017b": "Zdotaccent",
u"\u017c": "zdotaccent",
u"\u017d": "Zcaron",
u"\u017e": "zcaron",
u"\u017f": "longs",
u"\u0192": "florin",
u"\u01a0": "Ohorn",
u"\u01a1": "ohorn",
u"\u01af": "Uhorn",
u"\u01b0": "uhorn",
u"\u01e6": "Gcaron",
u"\u01e7": "gcaron",
u"\u01fa": "Aringacute",
u"\u01fb": "aringacute",
u"\u01fc": "AEacute",
u"\u01fd": "aeacute",
u"\u01fe": "Oslashacute",
u"\u01ff": "oslashacute",
u"\u0218": "Scommaaccent",
u"\u0219": "scommaaccent",
u"\u02bc": "afii57929",
u"\u02bd": "afii64937",
u"\u02c6": "circumflex",
u"\u02c7": "caron",
u"\u02c9": "macron",
u"\u02d8": "breve",
u"\u02d9": "dotaccent",
u"\u02da": "ring",
u"\u02db": "ogonek",
u"\u02dc": "tilde",
u"\u02dd": "hungarumlaut",
u"\u0300": "gravecomb",
u"\u0301": "acutecomb",
u"\u0303": "tildecomb",
u"\u0309": "hookabovecomb",
u"\u0323": "dotbelowcomb",
u"\u0384": "tonos",
u"\u0385": "dieresistonos",
u"\u0386": "Alphatonos",
u"\u0387": "anoteleia",
u"\u0388": "Epsilontonos",
u"\u0389": "Etatonos",
u"\u038a": "Iotatonos",
u"\u038c": "Omicrontonos",
u"\u038e": "Upsilontonos",
u"\u038f": "Omegatonos",
u"\u0390": "iotadieresistonos",
u"\u0391": "Alpha",
u"\u0392": "Beta",
u"\u0393": "Gamma",
u"\u0394": "Delta",
u"\u0395": "Epsilon",
u"\u0396": "Zeta",
u"\u0397": "Eta",
u"\u0398": "Theta",
u"\u0399": "Iota",
u"\u039a": "Kappa",
u"\u039b": "Lambda",
u"\u039c": "Mu",
u"\u039d": "Nu",
u"\u039e": "Xi",
u"\u039f": "Omicron",
u"\u03a0": "Pi",
u"\u03a1": "Rho",
u"\u03a3": "Sigma",
u"\u03a4": "Tau",
u"\u03a5": "Upsilon",
u"\u03a6": "Phi",
u"\u03a7": "Chi",
u"\u03a8": "Psi",
u"\u03a9": "Omega",
u"\u03aa": "Iotadieresis",
u"\u03ab": "Upsilondieresis",
u"\u03ac": "alphatonos",
u"\u03ad": "epsilontonos",
u"\u03ae": "etatonos",
u"\u03af": "iotatonos",
u"\u03b0": "upsilondieresistonos",
u"\u03b1": "alpha",
u"\u03b2": "beta",
u"\u03b3": "gamma",
u"\u03b4": "delta",
u"\u03b5": "epsilon",
u"\u03b6": "zeta",
u"\u03b7": "eta",
u"\u03b8": "theta",
u"\u03b9": "iota",
u"\u03ba": "kappa",
u"\u03bb": "lambda",
u"\u03bc": "mu",
u"\u03bd": "nu",
u"\u03be": "xi",
u"\u03bf": "omicron",
u"\u03c0": "pi",
u"\u03c1": "rho",
u"\u03c2": "sigma1",
u"\u03c3": "sigma",
u"\u03c4": "tau",
u"\u03c5": "upsilon",
u"\u03c6": "phi",
u"\u03c7": "chi",
u"\u03c8": "psi",
u"\u03c9": "omega",
u"\u03ca": "iotadieresis",
u"\u03cb": "upsilondieresis",
u"\u03cc": "omicrontonos",
u"\u03cd": "upsilontonos",
u"\u03ce": "omegatonos",
u"\u03d1": "theta1",
u"\u03d2": "Upsilon1",
u"\u03d5": "phi1",
u"\u03d6": "omega1",
u"\u0401": "afii10023",
u"\u0402": "afii10051",
u"\u0403": "afii10052",
u"\u0404": "afii10053",
u"\u0405": "afii10054",
u"\u0406": "afii10055",
u"\u0407": "afii10056",
u"\u0408": "afii10057",
u"\u0409": "afii10058",
u"\u040a": "afii10059",
u"\u040b": "afii10060",
u"\u040c": "afii10061",
u"\u040e": "afii10062",
u"\u040f": "afii10145",
u"\u0410": "afii10017",
u"\u0411": "afii10018",
u"\u0412": "afii10019",
u"\u0413": "afii10020",
u"\u0414": "afii10021",
u"\u0415": "afii10022",
u"\u0416": "afii10024",
u"\u0417": "afii10025",
u"\u0418": "afii10026",
u"\u0419": "afii10027",
u"\u041a": "afii10028",
u"\u041b": "afii10029",
u"\u041c": "afii10030",
u"\u041d": "afii10031",
u"\u041e": "afii10032",
u"\u041f": "afii10033",
u"\u0420": "afii10034",
u"\u0421": "afii10035",
u"\u0422": "afii10036",
u"\u0423": "afii10037",
u"\u0424": "afii10038",
u"\u0425": "afii10039",
u"\u0426": "afii10040",
u"\u0427": "afii10041",
u"\u0428": "afii10042",
u"\u0429": "afii10043",
u"\u042a": "afii10044",
u"\u042b": "afii10045",
u"\u042c": "afii10046",
u"\u042d": "afii10047",
u"\u042e": "afii10048",
u"\u042f": "afii10049",
u"\u0430": "afii10065",
u"\u0431": "afii10066",
u"\u0432": "afii10067",
u"\u0433": "afii10068",
u"\u0434": "afii10069",
u"\u0435": "afii10070",
u"\u0436": "afii10072",
u"\u0437": "afii10073",
u"\u0438": "afii10074",
u"\u0439": "afii10075",
u"\u043a": "afii10076",
u"\u043b": "afii10077",
u"\u043c": "afii10078",
u"\u043d": "afii10079",
u"\u043e": "afii10080",
u"\u043f": "afii10081",
u"\u0440": "afii10082",
u"\u0441": "afii10083",
u"\u0442": "afii10084",
u"\u0443": "afii10085",
u"\u0444": "afii10086",
u"\u0445": "afii10087",
u"\u0446": "afii10088",
u"\u0447": "afii10089",
u"\u0448": "afii10090",
u"\u0449": "afii10091",
u"\u044a": "afii10092",
u"\u044b": "afii10093",
u"\u044c": "afii10094",
u"\u044d": "afii10095",
u"\u044e": "afii10096",
u"\u044f": "afii10097",
u"\u0451": "afii10071",
u"\u0452": "afii10099",
u"\u0453": "afii10100",
u"\u0454": "afii10101",
u"\u0455": "afii10102",
u"\u0456": "afii10103",
u"\u0457": "afii10104",
u"\u0458": "afii10105",
u"\u0459": "afii10106",
u"\u045a": "afii10107",
u"\u045b": "afii10108",
u"\u045c": "afii10109",
u"\u045e": "afii10110",
u"\u045f": "afii10193",
u"\u0462": "afii10146",
u"\u0463": "afii10194",
u"\u0472": "afii10147",
u"\u0473": "afii10195",
u"\u0474": "afii10148",
u"\u0475": "afii10196",
u"\u0490": "afii10050",
u"\u0491": "afii10098",
u"\u04d9": "afii10846",
u"\u05b0": "afii57799",
u"\u05b1": "afii57801",
u"\u05b2": "afii57800",
u"\u05b3": "afii57802",
u"\u05b4": "afii57793",
u"\u05b5": "afii57794",
u"\u05b6": "afii57795",
u"\u05b7": "afii57798",
u"\u05b8": "afii57797",
u"\u05b9": "afii57806",
u"\u05bb": "afii57796",
u"\u05bc": "afii57807",
u"\u05bd": "afii57839",
u"\u05be": "afii57645",
u"\u05bf": "afii57841",
u"\u05c0": "afii57842",
u"\u05c1": "afii57804",
u"\u05c2": "afii57803",
u"\u05c3": "afii57658",
u"\u05d0": "afii57664",
u"\u05d1": "afii57665",
u"\u05d2": "afii57666",
u"\u05d3": "afii57667",
u"\u05d4": "afii57668",
u"\u05d5": "afii57669",
u"\u05d6": "afii57670",
u"\u05d7": "afii57671",
u"\u05d8": "afii57672",
u"\u05d9": "afii57673",
u"\u05da": "afii57674",
u"\u05db": "afii57675",
u"\u05dc": "afii57676",
u"\u05dd": "afii57677",
u"\u05de": "afii57678",
u"\u05df": "afii57679",
u"\u05e0": "afii57680",
u"\u05e1": "afii57681",
u"\u05e2": "afii57682",
u"\u05e3": "afii57683",
u"\u05e4": "afii57684",
u"\u05e5": "afii57685",
u"\u05e6": "afii57686",
u"\u05e7": "afii57687",
u"\u05e8": "afii57688",
u"\u05e9": "afii57689",
u"\u05ea": "afii57690",
u"\u05f0": "afii57716",
u"\u05f1": "afii57717",
u"\u05f2": "afii57718",
u"\u060c": "afii57388",
u"\u061b": "afii57403",
u"\u061f": "afii57407",
u"\u0621": "afii57409",
u"\u0622": "afii57410",
u"\u0623": "afii57411",
u"\u0624": "afii57412",
u"\u0625": "afii57413",
u"\u0626": "afii57414",
u"\u0627": "afii57415",
u"\u0628": "afii57416",
u"\u0629": "afii57417",
u"\u062a": "afii57418",
u"\u062b": "afii57419",
u"\u062c": "afii57420",
u"\u062d": "afii57421",
u"\u062e": "afii57422",
u"\u062f": "afii57423",
u"\u0630": "afii57424",
u"\u0631": "afii57425",
u"\u0632": "afii57426",
u"\u0633": "afii57427",
u"\u0634": "afii57428",
u"\u0635": "afii57429",
u"\u0636": "afii57430",
u"\u0637": "afii57431",
u"\u0638": "afii57432",
u"\u0639": "afii57433",
u"\u063a": "afii57434",
u"\u0640": "afii57440",
u"\u0641": "afii57441",
u"\u0642": "afii57442",
u"\u0643": "afii57443",
u"\u0644": "afii57444",
u"\u0645": "afii57445",
u"\u0646": "afii57446",
u"\u0647": "afii57470",
u"\u0648": "afii57448",
u"\u0649": "afii57449",
u"\u064a": "afii57450",
u"\u064b": "afii57451",
u"\u064c": "afii57452",
u"\u064d": "afii57453",
u"\u064e": "afii57454",
u"\u064f": "afii57455",
u"\u0650": "afii57456",
u"\u0651": "afii57457",
u"\u0652": "afii57458",
u"\u0660": "afii57392",
u"\u0661": "afii57393",
u"\u0662": "afii57394",
u"\u0663": "afii57395",
u"\u0664": "afii57396",
u"\u0665": "afii57397",
u"\u0666": "afii57398",
u"\u0667": "afii57399",
u"\u0668": "afii57400",
u"\u0669": "afii57401",
u"\u066a": "afii57381",
u"\u066d": "afii63167",
u"\u0679": "afii57511",
u"\u067e": "afii57506",
u"\u0686": "afii57507",
u"\u0688": "afii57512",
u"\u0691": "afii57513",
u"\u0698": "afii57508",
u"\u06a4": "afii57505",
u"\u06af": "afii57509",
u"\u06ba": "afii57514",
u"\u06d2": "afii57519",
u"\u06d5": "afii57534",
u"\u1e80": "Wgrave",
u"\u1e81": "wgrave",
u"\u1e82": "Wacute",
u"\u1e83": "wacute",
u"\u1e84": "Wdieresis",
u"\u1e85": "wdieresis",
u"\u1ef2": "Ygrave",
u"\u1ef3": "ygrave",
u"\u200c": "afii61664",
u"\u200d": "afii301",
u"\u200e": "afii299",
u"\u200f": "afii300",
u"\u2012": "figuredash",
u"\u2013": "endash",
u"\u2014": "emdash",
u"\u2015": "afii00208",
u"\u2017": "underscoredbl",
u"\u2018": "quoteleft",
u"\u2019": "quoteright",
u"\u201a": "quotesinglbase",
u"\u201b": "quotereversed",
u"\u201c": "quotedblleft",
u"\u201d": "quotedblright",
u"\u201e": "quotedblbase",
u"\u2020": "dagger",
u"\u2021": "daggerdbl",
u"\u2022": "bullet",
u"\u2024": "onedotenleader",
u"\u2025": "twodotenleader",
u"\u2026": "ellipsis",
u"\u202c": "afii61573",
u"\u202d": "afii61574",
u"\u202e": "afii61575",
u"\u2030": "perthousand",
u"\u2032": "minute",
u"\u2033": "second",
u"\u2039": "guilsinglleft",
u"\u203a": "guilsinglright",
u"\u203c": "exclamdbl",
u"\u2044": "fraction",
u"\u20a1": "colonmonetary",
u"\u20a3": "franc",
u"\u20a4": "lira",
u"\u20a7": "peseta",
u"\u20aa": "afii57636",
u"\u20ab": "dong",
u"\u20ac": "Euro",
u"\u2105": "afii61248",
u"\u2111": "Ifraktur",
u"\u2113": "afii61289",
u"\u2116": "afii61352",
u"\u2118": "weierstrass",
u"\u211c": "Rfraktur",
u"\u211e": "prescription",
u"\u2122": "trademark",
u"\u212e": "estimated",
u"\u2135": "aleph",
u"\u2153": "onethird",
u"\u2154": "twothirds",
u"\u215b": "oneeighth",
u"\u215c": "threeeighths",
u"\u215d": "fiveeighths",
u"\u215e": "seveneighths",
u"\u2190": "arrowleft",
u"\u2191": "arrowup",
u"\u2192": "arrowright",
u"\u2193": "arrowdown",
u"\u2194": "arrowboth",
u"\u2195": "arrowupdn",
u"\u21a8": "arrowupdnbse",
u"\u21b5": "carriagereturn",
u"\u21d0": "arrowdblleft",
u"\u21d1": "arrowdblup",
u"\u21d2": "arrowdblright",
u"\u21d3": "arrowdbldown",
u"\u21d4": "arrowdblboth",
u"\u2200": "universal",
u"\u2202": "partialdiff",
u"\u2203": "existential",
u"\u2205": "emptyset",
u"\u2207": "gradient",
u"\u2208": "element",
u"\u2209": "notelement",
u"\u220b": "suchthat",
u"\u220f": "product",
u"\u2211": "summation",
u"\u2212": "minus",
u"\u2215": "fraction",
u"\u2217": "asteriskmath",
u"\u2219": "periodcentered",
u"\u221a": "radical",
u"\u221d": "proportional",
u"\u221e": "infinity",
u"\u221f": "orthogonal",
u"\u2220": "angle",
u"\u2227": "logicaland",
u"\u2228": "logicalor",
u"\u2229": "intersection",
u"\u222a": "union",
u"\u222b": "integral",
u"\u2234": "therefore",
u"\u223c": "similar",
u"\u2245": "congruent",
u"\u2248": "approxequal",
u"\u2260": "notequal",
u"\u2261": "equivalence",
u"\u2264": "lessequal",
u"\u2265": "greaterequal",
u"\u2282": "propersubset",
u"\u2283": "propersuperset",
u"\u2284": "notsubset",
u"\u2286": "reflexsubset",
u"\u2287": "reflexsuperset",
u"\u2295": "circleplus",
u"\u2297": "circlemultiply",
u"\u22a5": "perpendicular",
u"\u22c5": "dotmath",
u"\u2302": "house",
u"\u2310": "revlogicalnot",
u"\u2320": "integraltp",
u"\u2321": "integralbt",
u"\u2329": "angleleft",
u"\u232a": "angleright",
u"\u2500": "SF100000",
u"\u2502": "SF110000",
u"\u250c": "SF010000",
u"\u2510": "SF030000",
u"\u2514": "SF020000",
u"\u2518": "SF040000",
u"\u251c": "SF080000",
u"\u2524": "SF090000",
u"\u252c": "SF060000",
u"\u2534": "SF070000",
u"\u253c": "SF050000",
u"\u2550": "SF430000",
u"\u2551": "SF240000",
u"\u2552": "SF510000",
u"\u2553": "SF520000",
u"\u2554": "SF390000",
u"\u2555": "SF220000",
u"\u2556": "SF210000",
u"\u2557": "SF250000",
u"\u2558": "SF500000",
u"\u2559": "SF490000",
u"\u255a": "SF380000",
u"\u255b": "SF280000",
u"\u255c": "SF270000",
u"\u255d": "SF260000",
u"\u255e": "SF360000",
u"\u255f": "SF370000",
u"\u2560": "SF420000",
u"\u2561": "SF190000",
u"\u2562": "SF200000",
u"\u2563": "SF230000",
u"\u2564": "SF470000",
u"\u2565": "SF480000",
u"\u2566": "SF410000",
u"\u2567": "SF450000",
u"\u2568": "SF460000",
u"\u2569": "SF400000",
u"\u256a": "SF540000",
u"\u256b": "SF530000",
u"\u256c": "SF440000",
u"\u2580": "upblock",
u"\u2584": "dnblock",
u"\u2588": "block",
u"\u258c": "lfblock",
u"\u2590": "rtblock",
u"\u2591": "ltshade",
u"\u2592": "shade",
u"\u2593": "dkshade",
u"\u25a0": "filledbox",
u"\u25a1": "H22073",
u"\u25aa": "H18543",
u"\u25ab": "H18551",
u"\u25ac": "filledrect",
u"\u25b2": "triagup",
u"\u25ba": "triagrt",
u"\u25bc": "triagdn",
u"\u25c4": "triaglf",
u"\u25ca": "lozenge",
u"\u25cb": "circle",
u"\u25cf": "H18533",
u"\u25d8": "invbullet",
u"\u25d9": "invcircle",
u"\u25e6": "openbullet",
u"\u263a": "smileface",
u"\u263b": "invsmileface",
u"\u263c": "sun",
u"\u2640": "female",
u"\u2642": "male",
u"\u2660": "spade",
u"\u2663": "club",
u"\u2665": "heart",
u"\u2666": "diamond",
u"\u266a": "musicalnote",
u"\u266b": "musicalnotedbl",
u"\ufb01": "fi",
u"\ufb02": "fl"}
class AFMError(Exception):
pass
# reader states
_READ_START = 0
_READ_MAIN = 1
_READ_DIRECTION = 2
_READ_CHARMETRICS = 3
_READ_KERNDATA = 4
_READ_TRACKKERN = 5
_READ_KERNPAIRS = 6
_READ_COMPOSITES = 7
_READ_END = 8
# various parsing functions
def _parseint(s):
try:
return int(s)
except:
raise AFMError("Expecting int, got '%s'" % s)
def _parsehex(s):
try:
if s[0] != "<" or s[-1] != ">":
raise AFMError()
return int(s[1:-1], 16)
except:
raise AFMError("Expecting hexadecimal int, got '%s'" % s)
def _parsefloat(s):
try:
return float(s)
except:
raise AFMError("Expecting float, got '%s'" % s)
def _parsefloats(s, nos):
try:
numbers = s.split()
result = map(float, numbers)
if len(result) != nos:
raise AFMError()
except:
raise AFMError("Expecting list of %d numbers, got '%s'" % (s, nos))
return result
def _parsestr(s):
# XXX: check for invalid characters in s
return s
def _parsebool(s):
s = s.rstrip()
if s == "true":
return 1
elif s == "false":
return 0
else:
raise AFMError("Expecting boolean, got '%s'" % s)
class AFMcharmetrics:
def __init__(self, code, widths=None, vvector=None, name=None, bbox=None, ligatures=None):
self.code = code
if widths is None:
self.widths = [None] * 2
else:
self.widths = widths
self.vvector = vvector
self.name = name
self.bbox = bbox
if ligatures is None:
self.ligatures = []
else:
self.ligatures = ligatures
class AFMtrackkern:
def __init__(self, degree, min_ptsize, min_kern, max_ptsize, max_kern):
self.degree = degree
self.min_ptsize = min_ptsize
self.min_kern = min_kern
self.max_ptsize = max_ptsize
self.max_kern = max_kern
class AFMkernpair:
def __init__(self, name1, name2, x, y):
self.name1 = name1
self.name2 = name2
self.x = x
self.y = y
class AFMcomposite:
def __init__(self, name, parts):
self.name = name
self.parts = parts
class AFMfile(metric.metric):
def __init__(self, file):
self.metricssets = 0 # int, optional
self.fontname = None # str, required
self.fullname = None # str, optional
self.familyname = None # str, optional
self.weight = None # str, optional
self.fontbbox = None # 4 floats, required
self.version = None # str, optional
self.notice = None # str, optional
self.encodingscheme = None # str, optional
self.mappingscheme = None # int, optional (not present in base font programs)
self.escchar = None # int, required if mappingscheme == 3
self.characterset = None # str, optional
self.characters = None # int, optional
self.isbasefont = 1 # bool, optional
self.vvector = None # 2 floats, required if metricssets == 2
self.isfixedv = None # bool, default: true if vvector present, false otherwise
self.capheight = None # float, optional
self.xheight = None # float, optional
self.ascender = None # float, optional
self.descender = None # float, optional
self.stdhw = None # float, optional
self.stdvw = None # float, optional
self.underlinepositions = [None] * 2 # int, optional (for each direction)
self.underlinethicknesses = [None] * 2 # float, optional (for each direction)
self.italicangles = [None] * 2 # float, optional (for each direction)
self.charwidths = [None] * 2 # 2 floats, optional (for each direction)
self.isfixedpitchs = [None] * 2 # bool, optional (for each direction)
self.charmetrics = None # list of character metrics information, optional
self.charmetricsdict = {} # helper dictionary mapping glyph names to character metrics information
self.trackkerns = None # list of track kernings, optional
self.kernpairs = [None] * 2 # list of list of kerning pairs (for each direction), optional
self.kernpairsdict = {} # helper dictionary mapping glyph names to kerning pairs, first direction
self.kernpairsdict1 = {} # helper dictionary mapping glyph names to kerning pairs, second direction
self.composites = None # list of composite character data sets, optional
self.parse(file)
if self.isfixedv is None:
self.isfixedv = self.vvector is not None
# XXX we should check the constraints on some parameters
# the following methods process a line when the reader is in the corresponding
# state and return the new state
def _processline_start(self, line):
key, args = line.split(None, 1)
if key != "StartFontMetrics":
raise AFMError("Expecting StartFontMetrics, no found")
return _READ_MAIN, None
def _processline_main(self, line):
try:
key, args = line.split(None, 1)
except ValueError:
key = line.rstrip()
if key == "Comment":
return _READ_MAIN, None
elif key == "MetricsSets":
self.metricssets = _parseint(args)
if direction is not None:
raise AFMError("MetricsSets not allowed after first (implicit) StartDirection")
elif key == "FontName":
self.fontname = _parsestr(args)
elif key == "FullName":
self.fullname = _parsestr(args)
elif key == "FamilyName":
self.familyname = _parsestr(args)
elif key == "Weight":
self.weight = _parsestr(args)
elif key == "FontBBox":
self.fontbbox = _parsefloats(args, 4)
elif key == "Version":
self.version = _parsestr(args)
elif key == "Notice":
self.notice = _parsestr(args)
elif key == "EncodingScheme":
self.encodingscheme = _parsestr(args)
elif key == "MappingScheme":
self.mappingscheme = _parseint(args)
elif key == "EscChar":
self.escchar = _parseint(args)
elif key == "CharacterSet":
self.characterset = _parsestr(args)
elif key == "Characters":
self.characters = _parseint(args)
elif key == "IsBaseFont":
self.isbasefont = _parsebool(args)
elif key == "VVector":
self.vvector = _parsefloats(args, 2)
elif key == "IsFixedV":
self.isfixedv = _parsebool(args)
elif key == "CapHeight":
self.capheight = _parsefloat(args)
elif key == "XHeight":
self.xheight = _parsefloat(args)
elif key == "Ascender":
self.ascender = _parsefloat(args)
elif key == "Descender":
self.descender = _parsefloat(args)
elif key == "StdHW":
self.stdhw = _parsefloat(args)
elif key == "StdVW":
self.stdvw = _parsefloat(args)
elif key == "StartDirection":
direction = _parseint(args)
if 0 <= direction <= 2:
return _READ_DIRECTION, direction
else:
raise AFMError("Wrong direction number %d" % direction)
elif (key == "UnderLinePosition" or key == "UnderlineThickness" or key == "ItalicAngle" or
key == "Charwidth" or key == "IsFixedPitch"):
# we implicitly entered a direction section, so we should process the line again
return self._processline_direction(line, 0)
elif key == "StartCharMetrics":
if self.charmetrics is not None:
raise AFMError("Multiple character metrics sections")
self.charmetrics = [None] * _parseint(args)
return _READ_CHARMETRICS, 0
elif key == "StartKernData":
return _READ_KERNDATA, None
elif key == "StartComposites":
if self.composites is not None:
raise AFMError("Multiple composite character data sections")
self.composites = [None] * _parseint(args)
return _READ_COMPOSITES, 0
elif key == "EndFontMetrics":
return _READ_END, None
elif key[0] in string.lowercase:
# ignoring private commands
pass
return _READ_MAIN, None
def _processline_direction(self, line, direction):
try:
key, args = line.split(None, 1)
except ValueError:
key = line.rstrip()
if key == "UnderLinePosition":
self.underlinepositions[direction] = _parseint(args)
elif key == "UnderlineThickness":
self.underlinethicknesses[direction] = _parsefloat(args)
elif key == "ItalicAngle":
self.italicangles[direction] = _parsefloat(args)
elif key == "Charwidth":
self.charwidths[direction] = _parsefloats(args, 2)
elif key == "IsFixedPitch":
self.isfixedpitchs[direction] = _parsebool(args)
elif key == "EndDirection":
return _READ_MAIN, None
else:
# we assume that we are implicitly leaving the direction section again,
# so try to reprocess the line in the header reader state
return self._processline_main(line)
return _READ_DIRECTION, direction
def _processline_charmetrics(self, line, charno):
if line.rstrip() == "EndCharMetrics":
if charno != len(self.charmetrics):
raise AFMError("Fewer character metrics than expected")
return _READ_MAIN, None
if charno >= len(self.charmetrics):
raise AFMError("More character metrics than expected")
has_name = False
char = None
for s in line.split(";"):
s = s.strip()
if not s:
continue
key, args = s.split(None, 1)
if key == "C":
if char is not None:
raise AFMError("Cannot define char code twice")
char = AFMcharmetrics(_parseint(args))
elif key == "CH":
if char is not None:
raise AFMError("Cannot define char code twice")
char = AFMcharmetrics(_parsehex(args))
elif key == "WX" or key == "W0X":
char.widths[0] = _parsefloat(args), 0
elif key == "W1X":
char.widths[1] = _parsefloat(args), 0
elif key == "WY" or key == "W0Y":
char.widths[0] = 0, _parsefloat(args)
elif key == "W1Y":
char.widths[1] = 0, _parsefloat(args)
elif key == "W" or key == "W0":
char.widths[0] = _parsefloats(args, 2)
elif key == "W1":
char.widths[1] = _parsefloats(args, 2)
elif key == "VV":
char.vvector = _parsefloats(args, 2)
elif key == "N":
# XXX: we should check that name is valid (no whitespace, etc.)
has_name = True
char.name = _parsestr(args)
elif key == "B":
char.bbox = _parsefloats(args, 4)
elif key == "L":
successor, ligature = args.split(None, 1)
char.ligatures.append((_parsestr(successor), ligature))
else:
raise AFMError("Undefined command in character widths specification: '%s'", s)
if char is None:
raise AFMError("Character metrics not defined")
self.charmetrics[charno] = char
if has_name:
self.charmetricsdict[char.name] = char
return _READ_CHARMETRICS, charno+1
def _processline_kerndata(self, line):
try:
key, args = line.split(None, 1)
except ValueError:
key = line.rstrip()
if key == "Comment":
return _READ_KERNDATA, None
if key == "StartTrackKern":
if self.trackkerns is not None:
raise AFMError("Multiple track kernings data sections")
self.trackkerns = [None] * _parseint(args)
return _READ_TRACKKERN, 0
elif key == "StartKernPairs" or key == "StartKernPairs0":
if self.kernpairs[0] is not None:
raise AFMError("Multiple kerning pairs data sections for direction 0")
self.kernpairs[0] = [None] * _parseint(args)
return _READ_KERNPAIRS, (0, 0)
elif key == "StartKernPairs1":
if self.kernpairs[1] is not None:
raise AFMError("Multiple kerning pairs data sections for direction 1")
self.kernpairs[1] = [None] * _parseint(args)
return _READ_KERNPAIRS, (1, 0)
elif key == "EndKernData":
return _READ_MAIN, None
else:
raise AFMError("Unsupported key %s in kerning data section" % key)
def _processline_trackkern(self, line, i):
try:
key, args = line.split(None, 1)
except ValueError:
key = line.rstrip()
if key == "Comment":
return _READ_TRACKKERN, i
elif key == "TrackKern":
if i >= len(self.trackkerns):
raise AFMError("More track kerning data sets than expected")
degrees, args = args.split(None, 1)
self.trackkerns[i] = AFMtrackkern(int(degrees), *_parsefloats(args, 4))
return _READ_TRACKKERN, i+1
elif key == "EndTrackKern":
if i < len(self.trackkerns):
raise AFMError("Fewer track kerning data sets than expected")
return _READ_KERNDATA, None
else:
raise AFMError("Unsupported key %s in kerning data section" % key)
def _processline_kernpairs(self, line, (direction, i)):
try:
key, args = line.split(None, 1)
except ValueError:
key = line.rstrip()
if key == "Comment":
return _READ_KERNPAIRS, (direction, i)
elif key == "EndKernPairs":
if i < len(self.kernpairs[direction]):
raise AFMError("Fewer kerning pairs than expected")
return _READ_KERNDATA, None
else:
if i >= len(self.kernpairs[direction]):
raise AFMError("More kerning pairs than expected")
if key == "KP":
try:
name1, name2, x, y = args.split()
except:
raise AFMError("Expecting name1, name2, x, y, got '%s'" % args)
x = _parsefloat(x)
y = _parsefloat(y)
elif key == "KPH":
try:
hex1, hex2, x, y = args.split()
except:
raise AFMError("Expecting <hex1>, <hex2>, x, y, got '%s'" % args)
name1 = _parsehex(hex1)
name2 = _parsehex(hex2)
x = _parsefloat(x)
y = _parsefloat(y)
elif key == "KPX":
try:
name1, name2, x = args.split()
except:
raise AFMError("Expecting name1, name2, x, got '%s'" % args)
x = _parsefloat(x)
y = 0
self.kernpairs[direction][i] = AFMkernpair(name1, name2, _parsefloat(x), 0)
elif key == "KPY":
try:
name1, name2, y = args.split()
except:
raise AFMError("Expecting name1, name2, y, got '%s'" % args)
x = 0
y = _parsefloat(y)
self.kernpairs[direction][i] = AFMkernpair(name1, name2, 0, _parsefloat(y))
else:
raise AFMError("Unknown key '%s' in kern pair section" % key)
kernpair = AFMkernpair(name1, name2, x, y)
self.kernpairs[direction][i] = kernpair
if direction:
self.kernpairsdict1[name1, name2] = kernpair
else:
self.kernpairsdict[name1, name2] = kernpair
return _READ_KERNPAIRS, (direction, i+1)
def _processline_composites(self, line, i):
if line.rstrip() == "EndComposites":
if i < len(self.composites):
raise AFMError("Fewer composite character data sets than expected")
return _READ_MAIN, None
if i >= len(self.composites):
raise AFMError("More composite character data sets than expected")
name = None
no = None
parts = []
for s in line.split(";"):
s = s.strip()
if not s:
continue
key, args = s.split(None, 1)
if key == "CC":
try:
name, no = args.split()
except:
raise AFMError("Expecting name number, got '%s'" % args)
no = _parseint(no)
elif key == "PCC":
try:
name1, x, y = args.split()
except:
raise AFMError("Expecting name x y, got '%s'" % args)
parts.append((name1, _parsefloat(x), _parsefloat(y)))
else:
raise AFMError("Unknown key '%s' in composite character data section" % key)
if len(parts) != no:
raise AFMError("Wrong number of composite characters")
return _READ_COMPOSITES, i+1
def parse(self, f):
# state of the reader, consisting of
# - the main state, i.e. the type of the section
# - a parameter sstate
state = _READ_START, None
# Note that we do a line by line processing here, since one
# of the states (_READ_DIRECTION) can be entered implicitly, i.e.
# without a corresponding StartDirection section and we thus
# may need to reprocess a line in the context of the new state
for line in f:
line = line[:-1]
mstate, sstate = state
if mstate == _READ_START:
state = self._processline_start(line)
else:
# except for the first line, any empty will be ignored
if not line.strip():
continue
if mstate == _READ_MAIN:
state = self._processline_main(line)
elif mstate == _READ_DIRECTION:
state = self._processline_direction(line, sstate)
elif mstate == _READ_CHARMETRICS:
state = self._processline_charmetrics(line, sstate)
elif mstate == _READ_KERNDATA:
state = self._processline_kerndata(line)
elif mstate == _READ_TRACKKERN:
state = self._processline_trackkern(line, sstate)
elif mstate == _READ_KERNPAIRS:
state = self._processline_kernpairs(line, sstate)
elif mstate == _READ_COMPOSITES:
state = self._processline_composites(line, sstate)
else:
raise AFMError("Undefined state in AFM reader")
def width_ds(self, glyphname):
return self.charmetricsdict[glyphname].widths[0][0]
def width_pt(self, glyphnames, size_pt):
return sum([self.charmetricsdict[glyphname].widths[0][0] for glyphname in glyphnames])*size_pt/1000.0
def height_pt(self, glyphnames, size_pt):
return max([self.charmetricsdict[glyphname].bbox[3] for glyphname in glyphnames])*size_pt/1000.0
def depth_pt(self, glyphnames, size_pt):
return min([self.charmetricsdict[glyphname].bbox[1] for glyphname in glyphnames])*size_pt/1000.0
def resolveligatures(self, glyphnames):
i = 1
while i < len(glyphnames):
for glyphname, replacement in self.charmetricsdict[glyphnames[i-1]].ligatures:
if glyphname == glyphnames[i]:
glyphnames[i-1] = replacement
del glyphnames[i]
break
else:
i += 1
return glyphnames
def resolvekernings(self, glyphnames, size_pt=None):
result = [None]*(2*len(glyphnames)-1)
for i, glyphname in enumerate(glyphnames):
result[2*i] = glyphname
if i:
kernpair = self.kernpairsdict.get((glyphnames[i-1], glyphname))
if kernpair:
if size_pt is not None:
result[2*i-1] = kernpair.x*size_pt/1000.0
else:
result[2*i-1] = kernpair.x
return result
def writePDFfontinfo(self, file, seriffont=False, symbolfont=True):
flags = 0
if self.isfixedpitchs[0]:
flags += 1<<0
if seriffont:
flags += 1<<1
if symbolfont:
flags += 1<<2
else:
flags += 1<<5
if self.italicangles[0]:
flags += 1<<6
file.write("/Flags %d\n" % flags)
if self.italicangles[0] is not None:
file.write("/ItalicAngles %d\n" % self.italicangles[0])
if self.ascender is not None:
ascent = self.ascender
elif self.fontbbox is not None:
ascent = self.fontbbox[3]
else:
ascent = 1000 # guessed default
file.write("/Ascent %d\n" % ascent)
if self.descender is not None:
descent = self.descender
elif self.fontbbox is not None:
descent = self.fontbbox[3]
else:
descent = -200 # guessed default
file.write("/Descent %d\n" % descent)
if self.fontbbox is not None:
file.write("/FontBBox [%d %d %d %d]\n" % tuple(self.fontbbox))
else:
# the fontbbox is required, so we have to have to provide some default
file.write("/FontBBox [0 %d 1000 %d]\n" % (descent, ascent))
if self.capheight is not None:
file.write("/CapHeight %d\n" % self.capheight)
else:
# the CapHeight is required, so we have to have to provide some default
file.write("/CapHeight %d\n" % ascent)
if self.stdvw is not None:
stemv = self.stdvw
elif self.weight is not None and ("bold" in self.weight.lower() or "black" in self.weight.lower()):
stemv = 120 # guessed default
else:
stemv = 70 # guessed default
file.write("/StemV %d\n" % stemv)
if __name__ == "__main__":
a = AFMfile("/opt/local/share/texmf-dist/fonts/afm/yandy/lucida/lbc.afm")
print a.charmetrics[0].name
a = AFMfile("/usr/share/enscript/hv.afm")
print a.charmetrics[32].name
|