diff --git a/CHANGES.rst b/CHANGES.rst index 7f80c70f20c..f0872e6dc85 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 ------- diff --git a/sphinx/builders/latex/__init__.py b/sphinx/builders/latex/__init__.py index 3ece571c031..52fd6b2c647 100644 --- a/sphinx/builders/latex/__init__.py +++ b/sphinx/builders/latex/__init__.py @@ -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'] == '': diff --git a/sphinx/texinputs/sphinxpackagesubstitutefont.sty b/sphinx/texinputs/sphinxpackagesubstitutefont.sty new file mode 100644 index 00000000000..974e45e138b --- /dev/null +++ b/sphinx/texinputs/sphinxpackagesubstitutefont.sty @@ -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