Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 09c5cb3

Browse filesBrowse files
committed
Do not add default matplotlib font, but rely on the default LaTeX font.
1 parent 89331ee commit 09c5cb3
Copy full SHA for 09c5cb3

File tree

2 files changed

+14
-5
lines changed
Filter options

2 files changed

+14
-5
lines changed

‎examples/userdemo/pgf_fonts.py

Copy file name to clipboardExpand all lines: examples/userdemo/pgf_fonts.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
=========
55
"""
66

7+
import matplotlib as mpl
78
import matplotlib.pyplot as plt
9+
mpl.use("pgf")
810
plt.rcParams.update({
911
"font.family": "serif",
1012
# Use LaTeX default serif font.

‎lib/matplotlib/backends/backend_pgf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pgf.py
+12-5Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,18 @@ def _get_preamble():
6565
families = ["serif", "sans\\-serif", "monospace"]
6666
commands = ["setmainfont", "setsansfont", "setmonofont"]
6767
for family, command in zip(families, commands):
68-
# 1) Forward slashes also work on Windows, so don't mess with
69-
# backslashes. 2) The dirname needs to include a separator.
70-
path = pathlib.Path(fm.findfont(family))
71-
preamble.append(r"\%s{%s}[Path=\detokenize{%s/}]" % (
72-
command, path.name, path.parent.as_posix()))
68+
try:
69+
# 1) Forward slashes also work on Windows, so do not mess
70+
# with backslashes.
71+
# 2) The dirname needs to include a separator.
72+
path = pathlib.Path(fm.findfont(family,
73+
fallback_to_default=False))
74+
except ValueError:
75+
# Use default LaTeX font instead
76+
pass
77+
else:
78+
preamble.append(r"\%s{%s}[Path=\detokenize{%s}]" % (
79+
command, path.name, path.parent.as_posix() + "/"))
7380
return "\n".join(preamble)
7481

7582

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.