Skip to content

Commit e291ff6

Browse files
akiyksJonathan Corbet
authored andcommitted
docs: pdfdocs: Add CJK-language-specific font settings
zh_TW, ko_KR, and ja_JP translations have their preferred glyph sets different from that of zh_CN. To switch CJK font in the middle of the translations, introduce custom LaTeX macros listed below: \kerneldocBeginSC \kerneldocEndSC \kerneldocBeginTC \kerneldocEndTC \kerneldocBeginKR \kerneldocEndKR \kerneldocBeginJP \kerneldocEndJP , and embed a pair of macros in each language's index.rst. NOTE 1: Update of zh_TW/index.rst is deferred to a follow-up change. NOTE 2: Custom macros added here do not imply \kerneldocCJK(on|off). This is intentional. For example, \kerneldocCJKoff needs to be at the top of Italian translations' index.rst for the footer of final zh_TW page to be properly typeset. Signed-off-by: Akira Yokosawa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Corbet <[email protected]>
1 parent 659653c commit e291ff6

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

Documentation/conf.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,66 @@
361361
% This is needed for translations
362362
\\usepackage{xeCJK}
363363
\\setCJKmainfont{Noto Sans CJK SC}
364+
\\setCJKsansfont{Noto Sans CJK SC}
365+
\\setCJKmonofont{Noto Sans Mono CJK SC}
366+
% CJK Language-specific font choices
367+
\\newCJKfontfamily[SCmain]\\scmain{Noto Sans CJK SC}
368+
\\newCJKfontfamily[SCsans]\\scsans{Noto Sans CJK SC}
369+
\\newCJKfontfamily[SCmono]\\scmono{Noto Sans Mono CJK SC}
370+
\\newCJKfontfamily[TCmain]\\tcmain{Noto Sans CJK TC}
371+
\\newCJKfontfamily[TCsans]\\tcsans{Noto Sans CJK TC}
372+
\\newCJKfontfamily[TCmono]\\tcmono{Noto Sans Mono CJK TC}
373+
\\newCJKfontfamily[KRmain]\\krmain{Noto Sans CJK KR}
374+
\\newCJKfontfamily[KRsans]\\krsans{Noto Sans CJK KR}
375+
\\newCJKfontfamily[KRmono]\\krmono{Noto Sans Mono CJK KR}
376+
\\newCJKfontfamily[JPmain]\\jpmain{Noto Sans CJK JP}
377+
\\newCJKfontfamily[JPsans]\\jpsans{Noto Sans CJK JP}
378+
\\newCJKfontfamily[JPmono]\\jpmono{Noto Sans Mono CJK JP}
364379
% Define custom macros to on/off CJK
365380
\\newcommand{\\kerneldocCJKon}{\\makexeCJKactive}
366381
\\newcommand{\\kerneldocCJKoff}{\\makexeCJKinactive}
367-
% To customize \sphinxtableofcontents
382+
\\newcommand{\\kerneldocBeginSC}{%
383+
\\begingroup%
384+
\\scmain%
385+
}
386+
\\newcommand{\\kerneldocEndSC}{\\endgroup}
387+
\\newcommand{\\kerneldocBeginTC}{%
388+
\\begingroup%
389+
\\tcmain%
390+
\\renewcommand{\\CJKsfdefault}{TCsans}%
391+
\\renewcommand{\\CJKttdefault}{TCmono}%
392+
}
393+
\\newcommand{\\kerneldocEndTC}{\\endgroup}
394+
\\newcommand{\\kerneldocBeginKR}{%
395+
\\begingroup%
396+
\\krmain%
397+
\\renewcommand{\\CJKsfdefault}{KRsans}%
398+
\\renewcommand{\\CJKttdefault}{KRmono}%
399+
}
400+
\\newcommand{\\kerneldocEndKR}{\\endgroup}
401+
\\newcommand{\\kerneldocBeginJP}{%
402+
\\begingroup%
403+
\\jpmain%
404+
\\renewcommand{\\CJKsfdefault}{JPsans}%
405+
\\renewcommand{\\CJKttdefault}{JPmono}%
406+
}
407+
\\newcommand{\\kerneldocEndJP}{\\endgroup}
408+
% To customize \\sphinxtableofcontents
368409
\\usepackage{etoolbox}
369410
% Inactivate CJK after tableofcontents
370411
\\apptocmd{\\sphinxtableofcontents}{\\kerneldocCJKoff}{}{}
371412
}{ % No CJK font found
372413
% Custom macros to on/off CJK (Dummy)
373414
\\newcommand{\\kerneldocCJKon}{}
374415
\\newcommand{\\kerneldocCJKoff}{}
416+
\\newcommand{\\kerneldocBeginSC}{}
417+
\\newcommand{\\kerneldocEndSC}{}
418+
\\newcommand{\\kerneldocBeginTC}{}
419+
\\newcommand{\\kerneldocEndTC}{}
420+
\\newcommand{\\kerneldocBeginKR}{}
421+
\\newcommand{\\kerneldocEndKR}{}
422+
\\newcommand{\\kerneldocBeginSC}{}
423+
\\newcommand{\\kerneldocEndKR}{}
375424
}
376425
'''
377426

Documentation/translations/ja_JP/index.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
\renewcommand\thesection*
44
\renewcommand\thesubsection*
55
\kerneldocCJKon
6+
\kerneldocBeginJP
67

78
Japanese translations
89
=====================
@@ -11,3 +12,7 @@ Japanese translations
1112
:maxdepth: 1
1213

1314
howto
15+
16+
.. raw:: latex
17+
18+
\kerneldocEndJP

Documentation/translations/ko_KR/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
\renewcommand\thesection*
44
\renewcommand\thesubsection*
55
\kerneldocCJKon
6+
\kerneldocBeginKR
67

78
한국어 번역
89
===========
@@ -26,3 +27,4 @@
2627
.. raw:: latex
2728

2829
\normalsize
30+
\kerneldocEndKR

Documentation/translations/zh_CN/index.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
\renewcommand\thesection*
66
\renewcommand\thesubsection*
77
\kerneldocCJKon
8+
\kerneldocBeginSC
89

910
.. _linux_doc_zh:
1011

@@ -189,3 +190,7 @@ TODOList:
189190
----------
190191

191192
* :ref:`genindex`
193+
194+
.. raw:: latex
195+
196+
\kerneldocEndSC

0 commit comments

Comments
 (0)