From 919a2d5a5359304ef866e4a0021097d29d37a427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20B?= <2589111+jfbu@users.noreply.github.com> Date: Wed, 15 Nov 2023 16:29:39 +0100 Subject: [PATCH] Fix #11756 (PDF build crash with 2023+ TeXLive and T2A fontenc option) --- CHANGES.rst | 4 ++++ sphinx/builders/latex/__init__.py | 9 +++++--- sphinx/texinputs/sphinx.sty | 1 - .../texinputs/sphinxpackagesubstitutefont.sty | 21 +++++++++++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 sphinx/texinputs/sphinxpackagesubstitutefont.sty 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/sphinx.sty b/sphinx/texinputs/sphinx.sty index 6c31f329c65..a80b42d93b7 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -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 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