Skip to content

Commit

Permalink
Fix sphinx-doc#11756 (PDF build crash with 2023+ TeXLive and T2A font…
Browse files Browse the repository at this point in the history
…enc option)
  • Loading branch information
jfbu committed Nov 15, 2023
1 parent 2d1e607 commit 04cbd81
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Bugs fixed
Patch by James Addison.
* #11678: Fix a possible ``ZeroDivisionError`` in ``sphinx.ext.coverage``.
Patch by Stephen Finucane.
* #11756: LaTeX: build error with recent TeXLive due to missing ``substitutefont``
package (triggered if using ``fontenc`` with ``T2A`` option and document
language is not a Cyrillic one).
Patch by Jean-François B.

Testing
-------
Expand Down
9 changes: 6 additions & 3 deletions sphinx/builders/latex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,18 @@ def init_multilingual(self) -> None:
if self.context['latex_engine'] == 'pdflatex':
if not self.babel.uses_cyrillic():
if 'X2' in self.context['fontenc']:
self.context['substitutefont'] = '\\usepackage{substitutefont}'
self.context['substitutefont'] = ('\\usepackage'
'{sphinxpackagesubstitutefont}')
self.context['textcyrillic'] = ('\\usepackage[Xtwo]'
'{sphinxpackagecyrillic}')
elif 'T2A' in self.context['fontenc']:
self.context['substitutefont'] = '\\usepackage{substitutefont}'
self.context['substitutefont'] = ('\\usepackage'
'{sphinxpackagesubstitutefont}')
self.context['textcyrillic'] = ('\\usepackage[TtwoA]'
'{sphinxpackagecyrillic}')
if 'LGR' in self.context['fontenc']:
self.context['substitutefont'] = '\\usepackage{substitutefont}'
self.context['substitutefont'] = ('\\usepackage'
'{sphinxpackagesubstitutefont}')
else:
self.context['textgreek'] = ''
if self.context['substitutefont'] == '':
Expand Down
1 change: 0 additions & 1 deletion sphinx/texinputs/sphinx.sty
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,6 @@ will be set to white}%
% Support hlist directive
\RequirePackage{multicol}


%% GRAPHICS
%
% It will always be needed, so let's load it here
Expand Down
21 changes: 21 additions & 0 deletions sphinx/texinputs/sphinxpackagesubstitutefont.sty
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
%% a stub for obsoleted LaTeX package substitutefont
% The package substitutefont stopped being distributed with TeXLive
% around August 2023 and was moved to "obsolete" section.
% cf https://ctan.org/pkg/substitutefont
% Trying to load it raises a LaTeX build error since.

% The \substitutefont has a LaTeX kernel replacement
% \DeclareFontFamilySubstitution
% which was added to LaTeX 2020-02-02
% The aim of this stub is to do that replacement silently.

% change this info string if making any custom modification
\ProvidesPackage{sphinxpackagesubstitutefont}[2023/15/11 v7.3.0 advanced colored boxes]

\ifdefined\DeclareFontFamilySubstitution
\def\substitutefont{\DeclareFontFamilySubstitution}
\else
\usepackage{substitutefont}
\fi

\endinput

0 comments on commit 04cbd81

Please sign in to comment.