Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commit09c5cb3

Browse files
committed
Do not add default matplotlib font, but rely on the default LaTeX font.
1 parent89331ee commit09c5cb3

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

‎examples/userdemo/pgf_fonts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
=========
55
"""
66

7+
importmatplotlibasmpl
78
importmatplotlib.pyplotasplt
9+
mpl.use("pgf")
810
plt.rcParams.update({
911
"font.family":"serif",
1012
# Use LaTeX default serif font.

‎lib/matplotlib/backends/backend_pgf.py

Lines 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
forfamily,commandinzip(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+
exceptValueError:
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)

[8]ページ先頭

©2009-2025 Movatter.jp