Skip to content

Commit

Permalink
docs: pdfdocs: Switch default CJK font to KR variants
Browse files Browse the repository at this point in the history
xeCJK is enabled in Table of Contents (TOC) so that translations.pdf
built by top-level "make pdfdocs" can have its TOC typeset properly.

This causes quotation marks and apostrophe symbols appear too wide in
Latin-script docs.
This is because (1) Sphinx converts ASCII symbols into multi-byte
UTF-8 ones in LaTeX and (2) in the SC variant of "Noto CJK" font
families, those UTF-8 symbols have full-width glyph.

The KR variant of the font families has half-width glyph for those
symbols and TOC pages should look nicer when it is used instead.

Switch the default CJK font families to the KR variant and teach
xeCJK of those symbols' widths.
To compensate the switch, teach xeCJK of the width in the SC and
TC variants.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/0c8ea878-0a6f-ea01-ab45-4e66c5facee9@gmail.com
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
  • Loading branch information
Akira Yokosawa authored and Jonathan Corbet committed Feb 15, 2022
1 parent 8716ef4 commit 66939df
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Documentation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,15 @@
\\IfFontExistsTF{Noto Sans CJK SC}{
% This is needed for translations
\\usepackage{xeCJK}
\\IfFontExistsTF{Noto Serif CJK SC}{
\\setCJKmainfont{Noto Serif CJK SC}[AutoFakeSlant]
\\IfFontExistsTF{Noto Serif CJK KR}{
\\setCJKmainfont{Noto Serif CJK KR}[AutoFakeSlant]
}{
\\setCJKmainfont{Noto Sans CJK SC}[AutoFakeSlant]
\\setCJKmainfont{Noto Sans CJK KR}[AutoFakeSlant]
}
\\setCJKsansfont{Noto Sans CJK SC}[AutoFakeSlant]
\\setCJKmonofont{Noto Sans Mono CJK SC}[AutoFakeSlant]
\\setCJKsansfont{Noto Sans CJK KR}[AutoFakeSlant]
\\setCJKmonofont{Noto Sans Mono CJK KR}[AutoFakeSlant]
\\xeCJKDeclareCharClass{HalfLeft}{`“,`‘}
\\xeCJKDeclareCharClass{HalfRight}{`”,`’}
% CJK Language-specific font choices
\\IfFontExistsTF{Noto Serif CJK SC}{
\\newCJKfontfamily[SCmain]\\scmain{Noto Serif CJK SC}[AutoFakeSlant]
Expand Down Expand Up @@ -513,20 +515,25 @@
\\newcommand{\\kerneldocBeginSC}{%
\\begingroup%
\\scmain%
\\xeCJKDeclareCharClass{FullLeft}{`“,`‘}%
\\xeCJKDeclareCharClass{FullRight}{`”,`’}%
\\renewcommand{\\CJKrmdefault}{SCserif}%
\\renewcommand{\\CJKsfdefault}{SCsans}%
\\renewcommand{\\CJKttdefault}{SCmono}%
}
\\newcommand{\\kerneldocEndSC}{\\endgroup}
\\newcommand{\\kerneldocBeginTC}{%
\\begingroup%
\\tcmain%
\\xeCJKDeclareCharClass{FullLeft}{`“,`‘}%
\\xeCJKDeclareCharClass{FullRight}{`”,`’}%
\\renewcommand{\\CJKrmdefault}{TCserif}%
\\renewcommand{\\CJKsfdefault}{TCsans}%
\\renewcommand{\\CJKttdefault}{TCmono}%
}
\\newcommand{\\kerneldocEndTC}{\\endgroup}
\\newcommand{\\kerneldocBeginKR}{%
\\begingroup%
\\xeCJKDeclareCharClass{HalfLeft}{`“,`‘}%
\\xeCJKDeclareCharClass{HalfRight}{`”,`’}%
\\krmain%
\\renewcommand{\\CJKrmdefault}{KRserif}%
\\renewcommand{\\CJKsfdefault}{KRsans}%
Expand All @@ -536,8 +543,6 @@
\\newcommand{\\kerneldocEndKR}{\\endgroup}
\\newcommand{\\kerneldocBeginJP}{%
\\begingroup%
\\xeCJKDeclareCharClass{HalfLeft}{`“,`‘}%
\\xeCJKDeclareCharClass{HalfRight}{`”,`’}%
\\jpmain%
\\renewcommand{\\CJKrmdefault}{JPserif}%
\\renewcommand{\\CJKsfdefault}{JPsans}%
Expand Down

0 comments on commit 66939df

Please sign in to comment.