File tree 2 files changed +12
-6
lines changed
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 5
5
6
6
"""
7
7
8
+ import matplotlib as mpl
8
9
import matplotlib .pyplot as plt
10
+ mpl .use ("pgf" )
9
11
plt .rcParams .update ({
10
12
"font.family" : "serif" ,
11
13
# Use LaTeX default serif font.
Original file line number Diff line number Diff line change @@ -48,12 +48,16 @@ def get_fontspec():
48
48
families = ["serif" , "sans\\ -serif" , "monospace" ]
49
49
commands = ["setmainfont" , "setsansfont" , "setmonofont" ]
50
50
for family , command in zip (families , commands ):
51
- # 1) Forward slashes also work on Windows, so don't mess with
52
- # backslashes. 2) The dirname needs to include a separator.
53
- path = pathlib .Path (fm .findfont (family ))
54
- latex_fontspec .append (r"\%s{%s}[Path=\detokenize{%s}]" % (
55
- command , path .name , path .parent .as_posix () + "/" ))
56
-
51
+ try :
52
+ # 1) Forward slashes also work on Windows, so don't mess with
53
+ # backslashes. 2) The dirname needs to include a separator.
54
+ path = pathlib .Path (fm .findfont (family ,
55
+ fallback_to_default = False ))
56
+ latex_fontspec .append (r"\%s{%s}[Path=\detokenize{%s}]" % (
57
+ command , path .name , path .parent .as_posix () + "/" ))
58
+ except ValueError :
59
+ # Use default LaTeX font instead
60
+ pass
57
61
return "\n " .join (latex_fontspec )
58
62
59
63
You can’t perform that action at this time.
0 commit comments