From: Akira Yokosawa <akiyks@gmail.com>
To: Jonathan Corbet <corbet@lwn.net>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: "Wu X.C." <bobwxc@email.cn>, SeongJae Park <sj38.park@gmail.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Akira Yokosawa <akiyks@gmail.com>
Subject: [RFC PATCH 1/3] docs: pdfdocs: Refactor config for CJK document
Date: Thu, 24 Jun 2021 21:08:49 +0900 [thread overview]
Message-ID: <45a7b96a-bc27-ade4-716a-c319715e1b4d@gmail.com> (raw)
In-Reply-To: <386938dc-6290-239c-4b4f-c6153f3d98c5@gmail.com>
To make generated LaTeX code portable across systems with different sets
of available fonts, convert font-availability check in python code to
LaTeX code by using a conditional command provided by the "fontspec"
package.
This will help those who want to run Sphinx on one machine/container
and run latexmk on other machines/containers with different font
configurations.
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
Documentation/conf.py | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/Documentation/conf.py b/Documentation/conf.py
index 7d92ec3e5b6e..22f083bafaae 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -358,26 +358,23 @@ latex_elements = {
# At least one book (translations) may have Asian characters
# with are only displayed if xeCJK is used
-cjk_cmd = check_output(['fc-list', '--format="%{family[0]}\n"']).decode('utf-8', 'ignore')
-if cjk_cmd.find("Noto Sans CJK SC") >= 0:
- latex_elements['preamble'] += '''
+latex_elements['preamble'] += '''
+ \\IfFontExistsTF{Noto Sans CJK SC}{
% This is needed for translations
- \\usepackage{xeCJK}
- \\setCJKmainfont{Noto Sans CJK SC}
+ \\usepackage{xeCJK}
+ \\setCJKmainfont{Noto Sans CJK SC}
% Define custom macros to on/off CJK
\\newcommand{\\kerneldocCJKon}{\\makexeCJKactive}
\\newcommand{\\kerneldocCJKoff}{\\makexeCJKinactive}
- % To customize \sphinxtableofcontents
+ % Inactivate CJK after tableofcontents (using etoolbox)
\\usepackage{etoolbox}
- % Inactivate CJK after tableofcontents
\\apptocmd{\\sphinxtableofcontents}{\\kerneldocCJKoff}{}{}
- '''
-else:
- latex_elements['preamble'] += '''
+ }{ % No CJK font
% Custom macros to on/off CJK (Dummy)
\\newcommand{\\kerneldocCJKon}{}
\\newcommand{\\kerneldocCJKoff}{}
- '''
+ }
+'''
# Fix reference escape troubles with Sphinx 1.4.x
if major == 1:
--
2.17.1
next prev parent reply other threads:[~2021-06-24 12:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-24 12:06 [RFC PATCH 0/3] docs: pdfdocs: Improve alignment of CJK ascii-art Akira Yokosawa
2021-06-24 12:08 ` Akira Yokosawa [this message]
2021-06-24 12:11 ` [RFC PATCH 2/3] docs: pdfdocs: Add font settings for " Akira Yokosawa
2021-06-24 12:14 ` [RFC PATCH 3/3] docs: ko_KR: Use white spaces behind CJK characters in ascii-art Akira Yokosawa
2021-06-24 12:59 ` [RFC PATCH 0/3] docs: pdfdocs: Improve alignment of CJK ascii-art Mauro Carvalho Chehab
2021-06-25 6:55 ` Wu X.C.
2021-06-25 7:50 ` Mauro Carvalho Chehab
2021-06-25 9:22 ` Akira Yokosawa
2021-06-25 10:24 ` Mauro Carvalho Chehab
2021-06-25 11:32 ` Akira Yokosawa
2021-06-25 17:17 ` Wu X.C.
2021-06-25 18:11 ` Mauro Carvalho Chehab
2021-06-26 2:32 ` Akira Yokosawa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45a7b96a-bc27-ade4-716a-c319715e1b4d@gmail.com \
--to=akiyks@gmail.com \
--cc=bobwxc@email.cn \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sj38.park@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®