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

Appearance settings

Commit 2fd6983

Browse filesBrowse files
committed
DOC: Add explicit font filenames for some TeX systems.
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 mostly better to continue to specify the font name, as different distros ship different extensions. This should still work on systems that don't do this, using the same fallback as macOS.
1 parent 2bec173 commit 2fd6983
Copy full SHA for 2fd6983

File tree

Expand file treeCollapse file tree

1 file changed

+28
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-8
lines changed

‎doc/conf.py

Copy file name to clipboardExpand all lines: doc/conf.py
+28-8Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,32 +358,52 @@ 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-
\setmainfont{XITS}[
365+
fontpkg = r"""
366+
\IfFontExistsTF{XITS}{
367+
\setmainfont{XITS}
368+
}{
369+
\setmainfont{XITS}[
370+
Extension = .otf,
366371
UprightFont = *-Regular,
367372
ItalicFont = *-Italic,
368373
BoldFont = *-Bold,
369374
BoldItalicFont = *-BoldItalic,
370-
]
371-
\setsansfont{FreeSans}[
375+
]}
376+
\IfFontExistsTF{FreeSans}{
377+
\setsansfont{FreeSans}
378+
}{
379+
\setsansfont{FreeSans}[
380+
Extension = .otf,
372381
UprightFont = *,
373382
ItalicFont = *Oblique,
374383
BoldFont = *Bold,
375384
BoldItalicFont = *BoldOblique,
376-
]
377-
\setmonofont{FreeMono}[
385+
]}
386+
\IfFontExistsTF{FreeMono}{
387+
\setmonofont{FreeMono}
388+
}{
389+
\setmonofont{FreeMono}[
390+
Extension = .otf,
378391
UprightFont = *,
379392
ItalicFont = *Oblique,
380393
BoldFont = *Bold,
381394
BoldItalicFont = *BoldOblique,
382-
]
395+
]}
383396
% needed for \mathbb (blackboard alphabet) to actually work
384397
\usepackage{unicode-math}
385-
\setmathfont{XITS Math}
398+
\IfFontExistsTF{XITS Math}{
399+
\setmathfont{XITS Math}
400+
}{
401+
\setmathfont{XITSMath-Regular}[
402+
Extension = .otf,
403+
]}
386404
"""
405+
latex_elements['fontpkg'] = fontpkg
406+
387407
# Sphinx <1.8.0 or >=2.0.0 does this by default, but the 1.8.x series
388408
# did not for latex_engine = 'xelatex' (as it used Latin Modern font).
389409
# We need this for code-blocks as FreeMono has wide glyphs.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.