8000 DOC: Add explicit font filenames for MacTeX. · matplotlib/matplotlib@a300336 · GitHub
[go: up one dir, main page]

Skip to content

Commit a300336

Browse files
committed
DOC: Add explicit font filenames for MacTeX.
On macOS, xelatex uses the system font directories, but MacTeX fonts are not added there. However, these files can be found by specifying the file name instead of the font name, so do so on macOS. On Linux, it is better to continue to specify the font name, as different distros ship different extensions.
1 parent 2bec173 commit a300336

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

doc/conf.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,11 @@ def _check_dependencies():
358358
\usepackage{fontspec}
359359
\defaultfontfeatures[\rmfamily,\sffamily,\ttfamily]{}
360360
'''
361+
361362
# Sphinx 2.0 adopts GNU FreeFont by default, but it does not have all
362363
# the Unicode codepoints needed for the section about Mathtext
363364
# "Writing mathematical expressions"
364-
latex_elements['fontpkg'] = r"""
365+
fontpkg = r"""
365366
\setmainfont{XITS}[
366367
UprightFont = *-Regular,
367368
ItalicFont = *-Italic,
@@ -382,8 +383,16 @@ def _check_dependencies():
382383
]
383384
% needed for \mathbb (blackboard alphabet) to actually work
384385
\usepackage{unicode-math}
385-
\setmathfont{XITS Math}
386+
\setmathfont{XITS Math}[
387+
]
386388
"""
389+
if sys.platform == 'darwin':
390+
# With MacTeX, fonts are not in the system path, so they must be found by
391+
# filename instead of font name, so add explicit extension and rename.
392+
fontpkg = fontpkg.replace('[', '''[
393+
Extension = .otf,''').replace('XITS Math', 'XITSMath-Regular')
394+
latex_elements['fontpkg'] = fontpkg
395+
387396
# Sphinx <1.8.0 or >=2.0.0 does this by default, but the 1.8.x series
388397
# did not for latex_engine = 'xelatex' (as it used Latin Modern font).
389398
# We need this for code-blocks as FreeMono has wide glyphs.

0 commit comments

Comments
 (0)
0