GeezerVison is showing github.com — Remove now unused StandardPsFonts, latex_to_{standard,cmex}, use_cmex. · matplotlib/matplotlib@519d1eb
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/matplotlib/_mathtext.py +1-163Lines changed: 1 addition & 163 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 20 | 20 | import matplotlib as mpl | 21 | 21 | from . import cbook | 22 | 22 | from ._mathtext_data import ( | 23 | | - latex_to_bakoma, latex_to_standard, stix_glyph_fixes, stix_virtual_fonts, | 24 | | - tex2uni) | 25 | | -from ._afm import AFM | | 23 | + latex_to_bakoma, stix_glyph_fixes, stix_virtual_fonts, tex2uni) | 26 | 24 | from .font_manager import FontProperties, findfont, get_font | 27 | 25 | from .ft2font import KERNING_DEFAULT | 28 | 26 |
| @@ -405,7 +403,6 @@ class UnicodeFonts(TruetypeFonts): | 405 | 403 | This class will "fallback" on the Bakoma fonts when a required | 406 | 404 | symbol can not be found in the font. | 407 | 405 | """ | 408 | | - use_cmex = True # Unused; delete once mathtext becomes private. | 409 | 406 |
| 410 | 407 | def __init__(self, *args, **kwargs): | 411 | 408 | # This must come first so the backend's owner is set correctly | @@ -517,7 +514,6 @@ def get_sized_alternatives_for_symbol(self, fontname, sym): | 517 | 514 |
| 518 | 515 |
| 519 | 516 | class DejaVuFonts(UnicodeFonts): | 520 | | - use_cmex = False # Unused; delete once mathtext becomes private. | 521 | 517 |
| 522 | 518 | def __init__(self, *args, **kwargs): | 523 | 519 | # This must come first so the backend's owner is set correctly | @@ -620,7 +616,6 @@ class StixFonts(UnicodeFonts): | 620 | 616 | 4: 'STIXSizeFourSym', | 621 | 617 | 5: 'STIXSizeFiveSym', | 622 | 618 | } | 623 | | - use_cmex = False # Unused; delete once mathtext becomes private. | 624 | 619 | cm_fallback = False | 625 | 620 | _sans = False | 626 | 621 |
| @@ -710,163 +705,6 @@ class StixSansFonts(StixFonts): | 710 | 705 | _sans = True | 711 | 706 |
| 712 | 707 |
| 713 | | -class StandardPsFonts(Fonts): | 714 | | - """ | 715 | | - Use the standard postscript fonts for rendering to backend_ps | 716 | | -
| 717 | | - Unlike the other font classes, BakomaFont and UnicodeFont, this | 718 | | - one requires the Ps backend. | 719 | | - """ | 720 | | - basepath = str(cbook._get_data_path('fonts/afm')) | 721 | | - | 722 | | - fontmap = { | 723 | | - 'cal': 'pzcmi8a', # Zapf Chancery | 724 | | - 'rm': 'pncr8a', # New Century Schoolbook | 725 | | - 'tt': 'pcrr8a', # Courier | 726 | | - 'it': 'pncri8a', # New Century Schoolbook Italic | 727 | | - 'sf': 'phvr8a', # Helvetica | 728 | | - 'bf': 'pncb8a', # New Century Schoolbook Bold | 729 | | - None: 'psyr', # Symbol | 730 | | - } | 731 | | - | 732 | | - def __init__(self, default_font_prop, mathtext_backend=None): | 733 | | - if mathtext_backend is None: | 734 | | - # Circular import, can be dropped after public access to | 735 | | - # StandardPsFonts is removed and mathtext_backend made a required | 736 | | - # parameter. | 737 | | - from . import mathtext | 738 | | - mathtext_backend = mathtext.MathtextBackendPath() | 739 | | - super().__init__(default_font_prop, mathtext_backend) | 740 | | - self.glyphd = {} | 741 | | - self.fonts = {} | 742 | | - | 743 | | - filename = findfont(default_font_prop, fontext='afm', | 744 | | - directory=self.basepath) | 745 | | - if filename is None: | 746 | | - filename = findfont('Helvetica', fontext='afm', | 747 | | - directory=self.basepath) | 748 | | - with open(filename, 'rb') as fd: | 749 | | - default_font = AFM(fd) | 750 | | - default_font.fname = filename | 751 | | - | 752 | | - self.fonts['default'] = default_font | 753 | | - self.fonts['regular'] = default_font | 754 | | - | 755 | | - def _get_font(self, font): | 756 | | - if font in self.fontmap: | 757 | | - basename = self.fontmap[font] | 758 | | - else: | 759 | | - basename = font | 760 | | - | 761 | | - cached_font = self.fonts.get(basename) | 762 | | - if cached_font is None: | 763 | | - fname = os.path.join(self.basepath, basename + ".afm") | 764 | | - with open(fname, 'rb') as fd: | 765 | | - cached_font = AFM(fd) | 766 | | - cached_font.fname = fname | 767 | | - self.fonts[basename] = cached_font | 768 | | - self.fonts[cached_font.get_fontname()] = cached_font | 769 | | - return cached_font | 770 | | - | 771 | | - def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True): | 772 | | - """Load the cmfont, metrics and glyph with caching.""" | 773 | | - key = fontname, sym, fontsize, dpi | 774 | | - tup = self.glyphd.get(key) | 775 | | - | 776 | | - if tup is not None: | 777 | | - return tup | 778 | | - | 779 | | - # Only characters in the "Letter" class should really be italicized. | 780 | | - # This class includes greek letters, so we're ok | 781 | | - if (fontname == 'it' and | 782 | | - (len(sym) > 1 | 783 | | - or not unicodedata.category(sym).startswith("L"))): | 784 | | - fontname = 'rm' | 785 | | - | 786 | | - found_symbol = False | 787 | | - | 788 | | - if sym in latex_to_standard: | 789 | | - fontname, num = latex_to_standard[sym] | 790 | | - glyph = chr(num) | 791 | | - found_symbol = True | 792 | | - elif len(sym) == 1: | 793 | | - glyph = sym | 794 | | - num = ord(glyph) | 795 | | - found_symbol = True | 796 | | - else: | 797 | | - _log.warning( | 798 | | - "No TeX to built-in Postscript mapping for {!r}".format(sym)) | 799 | | - | 800 | | - slanted = (fontname == 'it') | 801 | | - font = self._get_font(fontname) | 802 | | - | 803 | | - if found_symbol: | 804 | | - try: | 805 | | - glyph_name = font.get_name_char(glyph) | 806 | | - except KeyError: | 807 | | - _log.warning( | 808 | | - "No glyph in standard Postscript font {!r} for {!r}" | 809 | | - .format(font.get_fontname(), sym)) | 810 | | - found_symbol = False | 811 | | - | 812 | | - if not found_symbol: | 813 | | - glyph = '?' | 814 | | - num = ord(glyph) | 815 | | - glyph_name = font.get_name_char(glyph) | 816 | | - | 817 | | - offset = 0 | 818 | | - | 819 | | - scale = 0.001 * fontsize | 820 | | - | 821 | | - xmin, ymin, xmax, ymax = [val * scale | 822 | | - for val in font.get_bbox_char(glyph)] | 823 | | - metrics = types.SimpleNamespace( | 824 | | - advance = font.get_width_char(glyph) * scale, | 825 | | - width = font.get_width_char(glyph) * scale, | 826 | | - height = font.get_height_char(glyph) * scale, | 827 | | - xmin = xmin, | 828 | | - xmax = xmax, | 829 | | - ymin = ymin+offset, | 830 | | - ymax = ymax+offset, | 831 | | - # iceberg is the equivalent of TeX's "height" | 832 | | - iceberg = ymax + offset, | 833 | | - slanted = slanted | 834 | | - ) | 835 | | - | 836 | | - self.glyphd[key] = types.SimpleNamespace( | 837 | | - font = font, | 838 | | - fontsize = fontsize, | 839 | | - postscript_name = font.get_fontname(), | 840 | | - metrics = metrics, | 841 | | - glyph_name = glyph_name, | 842 | | - symbol_name = glyph_name, # Backcompat alias. | 843 | | - num = num, | 844 | | - glyph = glyph, | 845 | | - offset = offset | 846 | | - ) | 847 | | - | 848 | | - return self.glyphd[key] | 849 | | - | 850 | | - def get_kern(self, font1, fontclass1, sym1, fontsize1, | 851 | | - font2, fontclass2, sym2, fontsize2, dpi): | 852 | | - if font1 == font2 and fontsize1 == fontsize2: | 853 | | - info1 = self._get_info(font1, fontclass1, sym1, fontsize1, dpi) | 854 | | - info2 = self._get_info(font2, fontclass2, sym2, fontsize2, dpi) | 855 | | - font = info1.font | 856 | | - return (font.get_kern_dist(info1.glyph, info2.glyph) | 857 | | - * 0.001 * fontsize1) | 858 | | - return super().get_kern(font1, fontclass1, sym1, fontsize1, | 859 | | - font2, fontclass2, sym2, fontsize2, dpi) | 860 | | - | 861 | | - def get_xheight(self, font, fontsize, dpi): | 862 | | - font = self._get_font(font) | 863 | | - return font.get_xheight() * 0.001 * fontsize | 864 | | - | 865 | | - def get_underline_thickness(self, font, fontsize, dpi): | 866 | | - font = self._get_font(font) | 867 | | - return font.get_underline_thickness() * 0.001 * fontsize | 868 | | - | 869 | | - | 870 | 708 | ############################################################################## | 871 | 709 | # TeX-LIKE BOX MODEL | 872 | 710 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/matplotlib/_mathtext_data.py -167Lines changed: 0 additions & 167 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 236 | 236 | '\\_' : ('cmtt10', 0x5f) | 237 | 237 | } | 238 | 238 |
| 239 | | -latex_to_cmex = { # Unused; delete once mathtext becomes private. | 240 | | - r'\__sqrt__' : 112, | 241 | | - r'\bigcap' : 92, | 242 | | - r'\bigcup' : 91, | 243 | | - r'\bigodot' : 75, | 244 | | - r'\bigoplus' : 77, | 245 | | - r'\bigotimes' : 79, | 246 | | - r'\biguplus' : 93, | 247 | | - r'\bigvee' : 95, | 248 | | - r'\bigwedge' : 94, | 249 | | - r'\coprod' : 97, | 250 | | - r'\int' : 90, | 251 | | - r'\leftangle' : 173, | 252 | | - r'\leftbrace' : 169, | 253 | | - r'\oint' : 73, | 254 | | - r'\prod' : 89, | 255 | | - r'\rightangle' : 174, | 256 | | - r'\rightbrace' : 170, | 257 | | - r'\sum' : 88, | 258 | | - r'\widehat' : 98, | 259 | | - r'\widetilde' : 101, | 260 | | -} | 261 | | - | 262 | | -latex_to_standard = { | 263 | | - r'\cong' : ('psyr', 64), | 264 | | - r'\Delta' : ('psyr', 68), | 265 | | - r'\Phi' : ('psyr', 70), | 266 | | - r'\Gamma' : ('psyr', 89), | 267 | | - r'\alpha' : ('psyr', 97), | 268 | | - r'\beta' : ('psyr', 98), | 269 | | - r'\chi' : ('psyr', 99), | 270 | | - r'\delta' : ('psyr', 100), | 271 | | - r'\varepsilon' : ('psyr', 101), | 272 | | - r'\phi' : ('psyr', 102), | 273 | | - r'\gamma' : ('psyr', 103), | 274 | | - r'\eta' : ('psyr', 104), | 275 | | - r'\iota' : ('psyr', 105), | 276 | | - r'\varphi' : ('psyr', 106), | 277 | | - r'\kappa' : ('psyr', 108), | 278 | | - r'\nu' : ('psyr', 110), | 279 | | - r'\pi' : ('psyr', 112), | 280 | | - r'\theta' : ('psyr', 113), | 281 | | - r'\rho' : ('psyr', 114), | 282 | | - r'\sigma' : ('psyr', 115), | 283 | | - r'\tau' : ('psyr', 116), | 284 | | - r'\upsilon' : ('psyr', 117), | 285 | | - r'\varpi' : ('psyr', 118), | 286 | | - r'\omega' : ('psyr', 119), | 287 | | - r'\xi' : ('psyr', 120), | 288 | | - r'\psi' : ('psyr', 121), | 289 | | - r'\zeta' : ('psyr', 122), | 290 | | - r'\sim' : ('psyr', 126), | 291 | | - r'\leq' : ('psyr', 163), | 292 | | - r'\infty' : ('psyr', 165), | 293 | | - r'\clubsuit' : ('psyr', 167), | 294 | | - r'\diamondsuit' : ('psyr', 168), | 295 | | - r'\heartsuit' : ('psyr', 169), | 296 | | - r'\spadesuit' : ('psyr', 170), | 297 | | - r'\leftrightarrow' : ('psyr', 171), | 298 | | - r'\leftarrow' : ('psyr', 172), | 299 | | - r'\uparrow' : ('psyr', 173), | 300 | | - r'\rightarrow' : ('psyr', 174), | 301 | | - r'\downarrow' : ('psyr', 175), | 302 | | - r'\pm' : ('psyr', 176), | 303 | | - r'\geq' : ('psyr', 179), | 304 | | - r'\times' : ('psyr', 180), | 305 | | - r'\propto' : ('psyr', 181), | 306 | | - r'\partial' : ('psyr', 182), | 307 | | - r'\bullet' : ('psyr', 183), | 308 | | - r'\div' : ('psyr', 184), | 309 | | - r'\neq' : ('psyr', 185), | 310 | | - r'\equiv' : ('psyr', 186), | 311 | | - r'\approx' : ('psyr', 187), | 312 | | - r'\ldots' : ('psyr', 188), | 313 | | - r'\aleph' : ('psyr', 192), | 314 | | - r'\Im' : ('psyr', 193), | 315 | | - r'\Re' : ('psyr', 194), | 316 | | - r'\wp' : ('psyr', 195), | 317 | | - r'\otimes' : ('psyr', 196), | 318 | | - r'\oplus' : ('psyr', 197), | 319 | | - r'\oslash' : ('psyr', 198), | 320 | | - r'\cap' : ('psyr', 199), | 321 | | - r'\cup' : ('psyr', 200), | 322 | | - r'\supset' : ('psyr', 201), | 323 | | - r'\supseteq' : ('psyr', 202), | 324 | | - r'\subset' : ('psyr', 204), | 325 | | - r'\subseteq' : ('psyr', 205), | 326 | | - r'\in' : ('psyr', 206), | 327 | | - r'\notin' : ('psyr', 207), | 328 | | - r'\angle' : ('psyr', 208), | 329 | | - r'\nabla' : ('psyr', 209), | 330 | | - r'\textregistered' : ('psyr', 210), | 331 | | - r'\copyright' : ('psyr', 211), | 332 | | - r'\texttrademark' : ('psyr', 212), | 333 | | - r'\Pi' : ('psyr', 213), | 334 | | - r'\prod' : ('psyr', 213), | 335 | | - r'\surd' : ('psyr', 214), | 336 | | - r'\__sqrt__' : ('psyr', 214), | 337 | | - r'\cdot' : ('psyr', 215), | 338 | | - r'\urcorner' : ('psyr', 216), | 339 | | - r'\vee' : ('psyr', 217), | 340 | | - r'\wedge' : ('psyr', 218), | 341 | | - r'\Leftrightarrow' : ('psyr', 219), | 342 | | - r'\Leftarrow' : ('psyr', 220), | 343 | | - r'\Uparrow' : ('psyr', 221), | 344 | | - r'\Rightarrow' : ('psyr', 222), | 345 | | - r'\Downarrow' : ('psyr', 223), | 346 | | - r'\Diamond' : ('psyr', 224), | 347 | | - r'\Sigma' : ('psyr', 229), | 348 | | - r'\sum' : ('psyr', 229), | 349 | | - r'\forall' : ('psyr', 34), | 350 | | - r'\exists' : ('psyr', 36), | 351 | | - r'\lceil' : ('psyr', 233), | 352 | | - r'\lbrace' : ('psyr', 123), | 353 | | - r'\Psi' : ('psyr', 89), | 354 | | - r'\bot' : ('psyr', 0o136), | 355 | | - r'\Omega' : ('psyr', 0o127), | 356 | | - r'\leftbracket' : ('psyr', 0o133), | 357 | | - r'\rightbracket' : ('psyr', 0o135), | 358 | | - r'\leftbrace' : ('psyr', 123), | 359 | | - r'\leftparen' : ('psyr', 0o50), | 360 | | - r'\prime' : ('psyr', 0o242), | 361 | | - r'\sharp' : ('psyr', 0o43), | 362 | | - r'\slash' : ('psyr', 0o57), | 363 | | - r'\Lambda' : ('psyr', 0o114), | 364 | | - r'\neg' : ('psyr', 0o330), | 365 | | - r'\Upsilon' : ('psyr', 0o241), | 366 | | - r'\rightbrace' : ('psyr', 0o175), | 367 | | - r'\rfloor' : ('psyr', 0o373), | 368 | | - r'\lambda' : ('psyr', 0o154), | 369 | | - r'\to' : ('psyr', 0o256), | 370 | | - r'\Xi' : ('psyr', 0o130), | 371 | | - r'\emptyset' : ('psyr', 0o306), | 372 | | - r'\lfloor' : ('psyr', 0o353), | 373 | | - r'\rightparen' : ('psyr', 0o51), | 374 | | - r'\rceil' : ('psyr', 0o371), | 375 | | - r'\ni' : ('psyr', 0o47), | 376 | | - r'\epsilon' : ('psyr', 0o145), | 377 | | - r'\Theta' : ('psyr', 0o121), | 378 | | - r'\langle' : ('psyr', 0o341), | 379 | | - r'\leftangle' : ('psyr', 0o341), | 380 | | - r'\rangle' : ('psyr', 0o361), | 381 | | - r'\rightangle' : ('psyr', 0o361), | 382 | | - r'\rbrace' : ('psyr', 0o175), | 383 | | - r'\circ' : ('psyr', 0o260), | 384 | | - r'\diamond' : ('psyr', 0o340), | 385 | | - r'\mu' : ('psyr', 0o155), | 386 | | - r'\mid' : ('psyr', 0o352), | 387 | | - r'\imath' : ('pncri8a', 105), | 388 | | - r'\%' : ('pncr8a', 37), | 389 | | - r'\$' : ('pncr8a', 36), | 390 | | - r'\{' : ('pncr8a', 123), | 391 | | - r'\}' : ('pncr8a', 125), | 392 | | - r'\backslash' : ('pncr8a', 92), | 393 | | - r'\ast' : ('pncr8a', 42), | 394 | | - r'\#' : ('pncr8a', 35), | 395 | | - | 396 | | - r'\circumflexaccent' : ('pncri8a', 124), # for \hat | 397 | | - r'\combiningbreve' : ('pncri8a', 81), # for \breve | 398 | | - r'\combininggraveaccent' : ('pncri8a', 114), # for \grave | 399 | | - r'\combiningacuteaccent' : ('pncri8a', 63), # for \accute | 400 | | - r'\combiningdiaeresis' : ('pncri8a', 91), # for \ddot | 401 | | - r'\combiningtilde' : ('pncri8a', 75), # for \tilde | 402 | | - r'\combiningrightarrowabove' : ('pncri8a', 110), # for \vec | 403 | | - r'\combiningdotabove' : ('pncri8a', 26), # for \dot | 404 | | -} | 405 | | - | 406 | 239 | # Automatically generated. | 407 | 240 |
| 408 | 241 | type12uni = { | |
|