MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / TexManager

Class TexManager

lib/matplotlib/texmanager.py:55–374  ·  view source on GitHub ↗

Convert strings to dvi files using TeX, caching the results to a directory. The cache directory is called ``tex.cache`` and is located in the directory returned by `.get_cachedir`. Repeated calls to this constructor always return the same instance.

Source from the content-addressed store, hash-verified

53
54
55class TexManager:
56 """
57 Convert strings to dvi files using TeX, caching the results to a directory.
58
59 The cache directory is called ``tex.cache`` and is located in the directory
60 returned by `.get_cachedir`.
61
62 Repeated calls to this constructor always return the same instance.
63 """
64
65 _cache_dir = Path(mpl.get_cachedir(), 'tex.cache')
66 _grey_arrayd = {}
67
68 _font_families = ('serif', 'sans-serif', 'cursive', 'monospace')
69 # Check for the cm-super package (which registers unicode computer modern
70 # support just by being installed) without actually loading any package
71 # (because we already load the incompatible fix-cm).
72 _check_cmsuper_installed = (
73 r'\IfFileExists{type1ec.sty}{}{\PackageError{matplotlib-support}{'
74 r'Missing cm-super package, required by Matplotlib}{}}'
75 )
76 _font_preambles = {
77 'new century schoolbook': r'\renewcommand{\rmdefault}{pnc}',
78 'bookman': r'\renewcommand{\rmdefault}{pbk}',
79 'times': r'\usepackage{mathptmx}',
80 'palatino': r'\usepackage{mathpazo}',
81 'zapf chancery': r'\usepackage{chancery}',
82 'cursive': r'\usepackage{chancery}',
83 'charter': r'\usepackage{charter}',
84 'serif': '',
85 'sans-serif': '',
86 'helvetica': r'\usepackage{helvet}',
87 'avant garde': r'\usepackage{avant}',
88 'courier': r'\usepackage{courier}',
89 'monospace': _check_cmsuper_installed,
90 'computer modern roman': _check_cmsuper_installed,
91 'computer modern sans serif': _check_cmsuper_installed,
92 'computer modern typewriter': _check_cmsuper_installed,
93 }
94 _font_types = {
95 'new century schoolbook': 'serif',
96 'bookman': 'serif',
97 'times': 'serif',
98 'palatino': 'serif',
99 'zapf chancery': 'cursive',
100 'charter': 'serif',
101 'helvetica': 'sans-serif',
102 'avant garde': 'sans-serif',
103 'courier': 'monospace',
104 'computer modern roman': 'serif',
105 'computer modern sans serif': 'sans-serif',
106 'computer modern typewriter': 'monospace',
107 }
108
109 @functools.lru_cache # Always return the same instance.
110 def __new__(cls):
111 cls._cache_dir.mkdir(parents=True, exist_ok=True)
112 return object.__new__(cls)

Callers 6

get_glyphs_texMethod · 0.90
get_texmanagerMethod · 0.90
_convert_psfragsFunction · 0.90
test_fontconfig_preambleFunction · 0.90
test_font_selectionFunction · 0.90

Calls 1

PathClass · 0.85

Tested by 2

test_fontconfig_preambleFunction · 0.72
test_font_selectionFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…