File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 44=========
55"""
66
7+ import matplotlib as mpl
78import matplotlib .pyplot as plt
9+ mpl .use ("pgf" )
810plt .rcParams .update ({
911 "font.family" : "serif" ,
1012 # Use LaTeX default serif font.
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments