Skip to content

Commit cee7db1

Browse files
akiyksJonathan Corbet
authored andcommitted
docs: kerneldoc-preamble: Test xeCJK.sty before loading
On distros whose texlive packaging is fine-grained, texlive-xecjk can be installed/removed independently of other texlive packages. Conditionally loading xeCJK depending only on the existence of the "Noto Sans CJK SC" font might end up in xelatex error of "xeCJK.sty not found!". Improve the situation by testing existence of xeCJK.sty before loading it. This is useful on RHEL 9 and its clone distros where texlive-xecjk doesn't work at the moment due to a missing dependency [1]. "make pdfdocs" for non-CJK contents should work after removing texlive-xecjk. Link: [1] https://bugzilla.redhat.com/show_bug.cgi?id=2086254 Fixes: 398f7ab ("docs: pdfdocs: Pull LaTeX preamble part out of conf.py") Cc: stable@vger.kernel.org # v5.18+ Signed-off-by: Akira Yokosawa <akiyks@gmail.com> Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org> Link: https://lore.kernel.org/r/c24c2a87-70b2-5342-bcc9-de467940466e@gmail.com Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 568035b commit cee7db1

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Documentation/sphinx/kerneldoc-preamble.sty

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,16 @@
7070

7171
% Translations have Asian (CJK) characters which are only displayed if
7272
% xeCJK is used
73+
\usepackage{ifthen}
74+
\newboolean{enablecjk}
75+
\setboolean{enablecjk}{false}
7376
\IfFontExistsTF{Noto Sans CJK SC}{
74-
% Load xeCJK when CJK font is available
77+
\IfFileExists{xeCJK.sty}{
78+
\setboolean{enablecjk}{true}
79+
}{}
80+
}{}
81+
\ifthenelse{\boolean{enablecjk}}{
82+
% Load xeCJK when both the Noto Sans CJK font and xeCJK.sty are available.
7583
\usepackage{xeCJK}
7684
% Noto CJK fonts don't provide slant shape. [AutoFakeSlant] permits
7785
% its emulation.
@@ -196,22 +204,24 @@
196204
% Inactivate CJK after tableofcontents
197205
\apptocmd{\sphinxtableofcontents}{\kerneldocCJKoff}{}{}
198206
\xeCJKsetup{CJKspace = true}% For inter-phrase space of Korean TOC
199-
}{ % No CJK font found
207+
}{ % Don't enable CJK
200208
% Custom macros to on/off CJK and switch CJK fonts (Dummy)
201209
\newcommand{\kerneldocCJKon}{}
202210
\newcommand{\kerneldocCJKoff}{}
203211
%% By defining \kerneldocBegin(SC|TC|KR|JP) as commands with an argument
204212
%% and ignore the argument (#1) in their definitions, whole contents of
205213
%% CJK chapters can be ignored.
206214
\newcommand{\kerneldocBeginSC}[1]{%
207-
%% Put a note on missing CJK fonts in place of zh_CN translation.
208-
\begin{sphinxadmonition}{note}{Note on missing fonts:}
215+
%% Put a note on missing CJK fonts or the xecjk package in place of
216+
%% zh_CN translation.
217+
\begin{sphinxadmonition}{note}{Note on missing fonts and a package:}
209218
Translations of Simplified Chinese (zh\_CN), Traditional Chinese
210219
(zh\_TW), Korean (ko\_KR), and Japanese (ja\_JP) were skipped
211-
due to the lack of suitable font families.
220+
due to the lack of suitable font families and/or the texlive-xecjk
221+
package.
212222

213223
If you want them, please install ``Noto Sans CJK'' font families
214-
by following instructions from
224+
along with the texlive-xecjk package by following instructions from
215225
\sphinxcode{./scripts/sphinx-pre-install}.
216226
Having optional ``Noto Serif CJK'' font families will improve
217227
the looks of those translations.

0 commit comments

Comments
 (0)