lkml.org 
[lkml]   [2021]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[RFC PATCH v2 6/7] docs: pdfdocs: Add optional choices for Korean monospace font
From
Date
Candidates of alternative choices of a *true* monospace font would
be "D2Coding", "Sarasa Mono K", or "Unifont" font.

The alignment of Korean ascii-art figures matters when the optional
conf.py under Dodumentation/translations/ is effective.
So, add conditional settings in the local config so that when one of
the candidate fonts is found, it is used instead of "Noto Sans Mono
CJK KR".

As xeCJK does not provide a macro to redefine an existing CJK font
family, define a wrapper macro "\setKRmono" and use it in the
"\kerneldocBeginKR" macro.

Also mention the nice-to-have monospace Hangul fonts in the header
comment in conf.py.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
---
Documentation/conf.py | 4 +++-
Documentation/translations/conf.py | 34 +++++++++++++++++++++++++++++-
2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/Documentation/conf.py b/Documentation/conf.py
index 8a715765dada..1368c64e3993 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -382,6 +382,8 @@ latex_elements['preamble'] += '''
\\scserif%
}
\\newcommand{\\kerneldocEndSC}{\\endgroup}
+ \\newcommand{\\setKRmono}{% For alternative Hangul monospace font
+ \\renewcommand{\\CJKttdefault}{KRmono}}
\\newcommand{\\kerneldocBeginKR}{%
\\begingroup%
\\xeCJKDeclareCharClass{HalfLeft}{`“,`‘}%
@@ -389,7 +391,7 @@ latex_elements['preamble'] += '''
\\krserif%
\\renewcommand{\\CJKrmdefault}{KRserif}%
\\renewcommand{\\CJKsfdefault}{KRsans}%
- \\renewcommand{\\CJKttdefault}{KRmono}%
+ \\setKRmono%
\\xeCJKsetup{CJKspace = true} % For inter-phrase space
}
\\newcommand{\\kerneldocEndKR}{\\endgroup}
diff --git a/Documentation/translations/conf.py b/Documentation/translations/conf.py
index 92cdbba74229..0e171eed1862 100644
--- a/Documentation/translations/conf.py
+++ b/Documentation/translations/conf.py
@@ -3,10 +3,42 @@

# -- Additinal options for LaTeX output ----------------------------------
# font config for ascii-art alignment
-
+#
+# Note: Ascii-art figures involving Hangul characters need optional
+# monospace font. (Hangul in "Noto Sans Mono CJK" is slightly narrow.)
+# If you'd like to see properly aligned ascii-art figures in Korean
+# translations, you need to install a *true* monospace Hangul font.
+#
+# Candidates of such a monospace font which covers Hangul:
+# 1) D2Coding: Availabe at
+# https://github.com/naver/d2codingfont/releases/latest
+# 2) Sarasa Mono K: Available at
+# https://github.com/be5invis/Sarasa-Gothic/releases/latest
+# 3) Unifont: (easy to install but poor quality)
+# Available as distro packages, e.g.:
+# Ubuntu/Debian: ttf-unifont
+# Fedora: unifont-fonts
+#
latex_elements['preamble'] += '''
\\IfFontExistsTF{Noto Sans CJK SC}{
% For CJK ascii-art alignment
\\setmonofont{Noto Sans Mono CJK SC}[AutoFakeSlant]
+ \\IfFontExistsTF{D2Coding}{
+ \\newCJKfontfamily[KRtruemono]\\krtruemono{D2Coding}[AutoFakeSlant]
+ \\renewcommand{\\setKRmono}{%
+ \\renewcommand{\\CJKttdefault}{KRtruemono}}
+ }{
+ \\IfFontExistsTF{Sarasa Mono K}{
+ \\newCJKfontfamily[KRtruemono]\\krtruemono{Sarasa Mono K}
+ \\renewcommand{\\setKRmono}{%
+ \\renewcommand{\\CJKttdefault}{KRtruemono}}
+ }{
+ \\IfFontExistsTF{Unifont}{
+ \\newCJKfontfamily[KRtruemono]\\krtruemono{Unifont}[AutoFakeSlant,AutoFakeBold]
+ \\renewcommand{\\setKRmono}{%
+ \\renewcommand{\\CJKttdefault}{KRtruemono}}
+ }{}
+ }
+ }
}{}
'''
--
2.17.1


\
 
 \ /
  Last update: 2021-07-19 13:19    [W:0.078 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site