mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-23 16:53:58 -05:00
docs: pdfdocs: Refactor config for CJK document
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 run Sphinx on one machine/container and run latexmk on other machines/containers. Remove import of check_output as it is unused any more. Signed-off-by: Akira Yokosawa <akiyks@gmail.com> Link: https://lore.kernel.org/r/4baf88af-316d-8aee-240f-6ccbc20907d7@gmail.com Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:
parent
bed4ed3057
commit
659653c9e5
1 changed files with 9 additions and 13 deletions
|
@ -16,8 +16,6 @@ import sys
|
||||||
import os
|
import os
|
||||||
import sphinx
|
import sphinx
|
||||||
|
|
||||||
from subprocess import check_output
|
|
||||||
|
|
||||||
# Get Sphinx version
|
# Get Sphinx version
|
||||||
major, minor, patch = sphinx.version_info[:3]
|
major, minor, patch = sphinx.version_info[:3]
|
||||||
|
|
||||||
|
@ -355,12 +353,11 @@ latex_elements = {
|
||||||
''',
|
''',
|
||||||
}
|
}
|
||||||
|
|
||||||
# At least one book (translations) may have Asian characters
|
# Translations have Asian (CJK) characters which are only displayed if
|
||||||
# with are only displayed if xeCJK is used
|
# xeCJK is used
|
||||||
|
|
||||||
cjk_cmd = check_output(['fc-list', '--format="%{family[0]}\n"']).decode('utf-8', 'ignore')
|
latex_elements['preamble'] += '''
|
||||||
if cjk_cmd.find("Noto Sans CJK SC") >= 0:
|
\\IfFontExistsTF{Noto Sans CJK SC}{
|
||||||
latex_elements['preamble'] += '''
|
|
||||||
% This is needed for translations
|
% This is needed for translations
|
||||||
\\usepackage{xeCJK}
|
\\usepackage{xeCJK}
|
||||||
\\setCJKmainfont{Noto Sans CJK SC}
|
\\setCJKmainfont{Noto Sans CJK SC}
|
||||||
|
@ -371,13 +368,12 @@ if cjk_cmd.find("Noto Sans CJK SC") >= 0:
|
||||||
\\usepackage{etoolbox}
|
\\usepackage{etoolbox}
|
||||||
% Inactivate CJK after tableofcontents
|
% Inactivate CJK after tableofcontents
|
||||||
\\apptocmd{\\sphinxtableofcontents}{\\kerneldocCJKoff}{}{}
|
\\apptocmd{\\sphinxtableofcontents}{\\kerneldocCJKoff}{}{}
|
||||||
'''
|
}{ % No CJK font found
|
||||||
else:
|
|
||||||
latex_elements['preamble'] += '''
|
|
||||||
% Custom macros to on/off CJK (Dummy)
|
% Custom macros to on/off CJK (Dummy)
|
||||||
\\newcommand{\\kerneldocCJKon}{}
|
\\newcommand{\\kerneldocCJKon}{}
|
||||||
\\newcommand{\\kerneldocCJKoff}{}
|
\\newcommand{\\kerneldocCJKoff}{}
|
||||||
'''
|
}
|
||||||
|
'''
|
||||||
|
|
||||||
# Fix reference escape troubles with Sphinx 1.4.x
|
# Fix reference escape troubles with Sphinx 1.4.x
|
||||||
if major == 1:
|
if major == 1:
|
||||||
|
|
Loading…
Add table
Reference in a new issue