File tree 2 files changed +14
-5
lines changed
2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 4
4
=========
5
5
"""
6
6
7
+ import matplotlib as mpl
7
8
import matplotlib .pyplot as plt
9
+ mpl .use ("pgf" )
8
10
plt .rcParams .update ({
9
11
"font.family" : "serif" ,
10
12
# Use LaTeX default serif font.
Original file line number Diff line number Diff line change @@ -65,11 +65,18 @@ def _get_preamble():
65
65
families = ["serif" , "sans\\ -serif" , "monospace" ]
66
66
commands = ["setmainfont" , "setsansfont" , "setmonofont" ]
67
67
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 () + "/" ))
73
80
return "\n " .join (preamble )
74
81
75
82
You can’t perform that action at this time.
0 commit comments