Skip to content

Commit 35259b3

Browse files
committed
Remove now unused StandardPsFonts, latex_to_{standard,cmex}, use_cmex.
1 parent 014fa96 commit 35259b3

File tree

2 files changed

+1
-330
lines changed

2 files changed

+1
-330
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 1 addition & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
import matplotlib as mpl
2121
from . import cbook
2222
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)
2624
from .font_manager import FontProperties, findfont, get_font
2725
from .ft2font import KERNING_DEFAULT
2826

@@ -403,7 +401,6 @@ class UnicodeFonts(TruetypeFonts):
403401
This class will "fallback" on the Bakoma fonts when a required
404402
symbol can not be found in the font.
405403
"""
406-
use_cmex = True # Unused; delete once mathtext becomes private.
407404

408405
def __init__(self, *args, **kwargs):
409406
# This must come first so the backend's owner is set correctly
@@ -515,7 +512,6 @@ def get_sized_alternatives_for_symbol(self, fontname, sym):
515512

516513

517514
class DejaVuFonts(UnicodeFonts):
518-
use_cmex = False # Unused; delete once mathtext becomes private.
519515

520516
def __init__(self, *args, **kwargs):
521517
# This must come first so the backend's owner is set correctly
@@ -618,7 +614,6 @@ class StixFonts(UnicodeFonts):
618614
4: 'STIXSizeFourSym',
619615
5: 'STIXSizeFiveSym',
620616
}
621-
use_cmex = False # Unused; delete once mathtext becomes private.
622617
cm_fallback = False
623618
_sans = False
624619

@@ -708,163 +703,6 @@ class StixSansFonts(StixFonts):
708703
_sans = True
709704

710705

711-
class StandardPsFonts(Fonts):
712-
"""
713-
Use the standard postscript fonts for rendering to backend_ps
714-
715-
Unlike the other font classes, BakomaFont and UnicodeFont, this
716-
one requires the Ps backend.
717-
"""
718-
basepath = str(cbook._get_data_path('fonts/afm'))
719-
720-
fontmap = {
721-
'cal': 'pzcmi8a', # Zapf Chancery
722-
'rm': 'pncr8a', # New Century Schoolbook
723-
'tt': 'pcrr8a', # Courier
724-
'it': 'pncri8a', # New Century Schoolbook Italic
725-
'sf': 'phvr8a', # Helvetica
726-
'bf': 'pncb8a', # New Century Schoolbook Bold
727-
None: 'psyr', # Symbol
728-
}
729-
730-
def __init__(self, default_font_prop, mathtext_backend=None):
731-
if mathtext_backend is None:
732-
# Circular import, can be dropped after public access to
733-
# StandardPsFonts is removed and mathtext_backend made a required
734-
# parameter.
735-
from . import mathtext
736-
mathtext_backend = mathtext.MathtextBackendPath()
737-
super().__init__(default_font_prop, mathtext_backend)
738-
self.glyphd = {}
739-
self.fonts = {}
740-
741-
filename = findfont(default_font_prop, fontext='afm',
742-
directory=self.basepath)
743-
if filename is None:
744-
filename = findfont('Helvetica', fontext='afm',
745-
directory=self.basepath)
746-
with open(filename, 'rb') as fd:
747-
default_font = AFM(fd)
748-
default_font.fname = filename
749-
750-
self.fonts['default'] = default_font
751-
self.fonts['regular'] = default_font
752-
753-
def _get_font(self, font):
754-
if font in self.fontmap:
755-
basename = self.fontmap[font]
756-
else:
757-
basename = font
758-
759-
cached_font = self.fonts.get(basename)
760-
if cached_font is None:
761-
fname = os.path.join(self.basepath, basename + ".afm")
762-
with open(fname, 'rb') as fd:
763-
cached_font = AFM(fd)
764-
cached_font.fname = fname
765-
self.fonts[basename] = cached_font
766-
self.fonts[cached_font.get_fontname()] = cached_font
767-
return cached_font
768-
769-
def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True):
770-
"""Load the cmfont, metrics and glyph with caching."""
771-
key = fontname, sym, fontsize, dpi
772-
tup = self.glyphd.get(key)
773-
774-
if tup is not None:
775-
return tup
776-
777-
# Only characters in the "Letter" class should really be italicized.
778-
# This class includes greek letters, so we're ok
779-
if (fontname == 'it' and
780-
(len(sym) > 1
781-
or not unicodedata.category(sym).startswith("L"))):
782-
fontname = 'rm'
783-
784-
found_symbol = False
785-
786-
if sym in latex_to_standard:
787-
fontname, num = latex_to_standard[sym]
788-
glyph = chr(num)
789-
found_symbol = True
790-
elif len(sym) == 1:
791-
glyph = sym
792-
num = ord(glyph)
793-
found_symbol = True
794-
else:
795-
_log.warning(
796-
"No TeX to built-in Postscript mapping for {!r}".format(sym))
797-
798-
slanted = (fontname == 'it')
799-
font = self._get_font(fontname)
800-
801-
if found_symbol:
802-
try:
803-
glyph_name = font.get_name_char(glyph)
804-
except KeyError:
805-
_log.warning(
806-
"No glyph in standard Postscript font {!r} for {!r}"
807-
.format(font.get_fontname(), sym))
808-
found_symbol = False
809-
810-
if not found_symbol:
811-
glyph = '?'
812-
num = ord(glyph)
813-
glyph_name = font.get_name_char(glyph)
814-
815-
offset = 0
816-
817-
scale = 0.001 * fontsize
818-
819-
xmin, ymin, xmax, ymax = [val * scale
820-
for val in font.get_bbox_char(glyph)]
821-
metrics = types.SimpleNamespace(
822-
advance = font.get_width_char(glyph) * scale,
823-
width = font.get_width_char(glyph) * scale,
824-
height = font.get_height_char(glyph) * scale,
825-
xmin = xmin,
826-
xmax = xmax,
827-
ymin = ymin+offset,
828-
ymax = ymax+offset,
829-
# iceberg is the equivalent of TeX's "height"
830-
iceberg = ymax + offset,
831-
slanted = slanted
832-
)
833-
834-
self.glyphd[key] = types.SimpleNamespace(
835-
font = font,
836-
fontsize = fontsize,
837-
postscript_name = font.get_fontname(),
838-
metrics = metrics,
839-
glyph_name = glyph_name,
840-
symbol_name = glyph_name, # Backcompat alias.
841-
num = num,
842-
glyph = glyph,
843-
offset = offset
844-
)
845-
846-
return self.glyphd[key]
847-
848-
def get_kern(self, font1, fontclass1, sym1, fontsize1,
849-
font2, fontclass2, sym2, fontsize2, dpi):
850-
if font1 == font2 and fontsize1 == fontsize2:
851-
info1 = self._get_info(font1, fontclass1, sym1, fontsize1, dpi)
852-
info2 = self._get_info(font2, fontclass2, sym2, fontsize2, dpi)
853-
font = info1.font
854-
return (font.get_kern_dist(info1.glyph, info2.glyph)
855-
* 0.001 * fontsize1)
856-
return super().get_kern(font1, fontclass1, sym1, fontsize1,
857-
font2, fontclass2, sym2, fontsize2, dpi)
858-
859-
def get_xheight(self, font, fontsize, dpi):
860-
font = self._get_font(font)
861-
return font.get_xheight() * 0.001 * fontsize
862-
863-
def get_underline_thickness(self, font, fontsize, dpi):
864-
font = self._get_font(font)
865-
return font.get_underline_thickness() * 0.001 * fontsize
866-
867-
868706
##############################################################################
869707
# TeX-LIKE BOX MODEL
870708

lib/matplotlib/_mathtext_data.py

Lines changed: 0 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -236,173 +236,6 @@
236236
'\\_' : ('cmtt10', 0x5f)
237237
}
238238

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-
406239
# Automatically generated.
407240

408241
type12uni = {

0 commit comments

Comments
 (0)