Skip to content

Commit 4d7f631

Browse files
mchehabJonathan Corbet
authored andcommitted
docs: kdoc: latex_fonts: Improve docstrings and comments
In preparation to document kernel-doc module, improve its documentation. Among the changes, it had to place the xml template inside a code block, as otherwise doc build would break. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <6e0eb2e245eae9b4f39cf231dee32df00b9e8b7b.1768838938.git.mchehab+huawei@kernel.org>
1 parent 4b8fae7 commit 4d7f631

1 file changed

Lines changed: 56 additions & 39 deletions

File tree

tools/lib/python/kdoc/latex_fonts.py

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
# Ported to Python by (c) Mauro Carvalho Chehab, 2025
66

77
"""
8-
Detect problematic Noto CJK variable fonts.
8+
Detect problematic Noto CJK variable fonts
9+
==========================================
910
10-
For "make pdfdocs", reports of build errors of translations.pdf started
11-
arriving early 2024 [1, 2]. It turned out that Fedora and openSUSE
12-
tumbleweed have started deploying variable-font [3] format of "Noto CJK"
13-
fonts [4, 5]. For PDF, a LaTeX package named xeCJK is used for CJK
11+
For ``make pdfdocs``, reports of build errors of translations.pdf started
12+
arriving early 2024 [1]_ [2]_. It turned out that Fedora and openSUSE
13+
tumbleweed have started deploying variable-font [3]_ format of "Noto CJK"
14+
fonts [4]_ [5]_. For PDF, a LaTeX package named xeCJK is used for CJK
1415
(Chinese, Japanese, Korean) pages. xeCJK requires XeLaTeX/XeTeX, which
1516
does not (and likely never will) understand variable fonts for historical
1617
reasons.
@@ -25,68 +26,77 @@
2526
suggestions if variable-font files of "Noto CJK" fonts are in the list of
2627
fonts accessible from XeTeX.
2728
28-
References:
29-
[1]: https://lore.kernel.org/r/8734tqsrt7.fsf@meer.lwn.net/
30-
[2]: https://lore.kernel.org/r/1708585803.600323099@f111.i.mail.ru/
31-
[3]: https://en.wikipedia.org/wiki/Variable_font
32-
[4]: https://fedoraproject.org/wiki/Changes/Noto_CJK_Variable_Fonts
33-
[5]: https://build.opensuse.org/request/show/1157217
29+
.. [1] https://lore.kernel.org/r/8734tqsrt7.fsf@meer.lwn.net/
30+
.. [2] https://lore.kernel.org/r/1708585803.600323099@f111.i.mail.ru/
31+
.. [3] https://en.wikipedia.org/wiki/Variable_font
32+
.. [4] https://fedoraproject.org/wiki/Changes/Noto_CJK_Variable_Fonts
33+
.. [5] https://build.opensuse.org/request/show/1157217
3434
35-
#===========================================================================
3635
Workarounds for building translations.pdf
37-
#===========================================================================
36+
-----------------------------------------
3837
3938
* Denylist "variable font" Noto CJK fonts.
39+
4040
- Create $HOME/deny-vf/fontconfig/fonts.conf from template below, with
4141
tweaks if necessary. Remove leading "".
42+
4243
- Path of fontconfig/fonts.conf can be overridden by setting an env
4344
variable FONTS_CONF_DENY_VF.
4445
45-
* Template:
46-
-----------------------------------------------------------------
47-
<?xml version="1.0"?>
48-
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
49-
<fontconfig>
50-
<!--
51-
Ignore variable-font glob (not to break xetex)
52-
-->
53-
<selectfont>
54-
<rejectfont>
55-
<!--
56-
for Fedora
57-
-->
58-
<glob>/usr/share/fonts/google-noto-*-cjk-vf-fonts</glob>
59-
<!--
60-
for openSUSE tumbleweed
61-
-->
62-
<glob>/usr/share/fonts/truetype/Noto*CJK*-VF.otf</glob>
63-
</rejectfont>
64-
</selectfont>
65-
</fontconfig>
66-
-----------------------------------------------------------------
46+
* Template::
47+
48+
<?xml version="1.0"?>
49+
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
50+
<fontconfig>
51+
<!--
52+
Ignore variable-font glob (not to break xetex)
53+
-->
54+
<selectfont>
55+
<rejectfont>
56+
<!--
57+
for Fedora
58+
-->
59+
<glob>/usr/share/fonts/google-noto-*-cjk-vf-fonts</glob>
60+
<!--
61+
for openSUSE tumbleweed
62+
-->
63+
<glob>/usr/share/fonts/truetype/Noto*CJK*-VF.otf</glob>
64+
</rejectfont>
65+
</selectfont>
66+
</fontconfig>
6767
6868
The denylisting is activated for "make pdfdocs".
6969
7070
* For skipping CJK pages in PDF
71+
7172
- Uninstall texlive-xecjk.
7273
Denylisting is not needed in this case.
7374
7475
* For printing CJK pages in PDF
76+
7577
- Need non-variable "Noto CJK" fonts.
78+
7679
* Fedora
80+
7781
- google-noto-sans-cjk-fonts
7882
- google-noto-serif-cjk-fonts
83+
7984
* openSUSE tumbleweed
85+
8086
- Non-variable "Noto CJK" fonts are not available as distro packages
8187
as of April, 2024. Fetch a set of font files from upstream Noto
8288
CJK Font released at:
89+
8390
https://github.com/notofonts/noto-cjk/tree/main/Sans#super-otc
91+
8492
and at:
93+
8594
https://github.com/notofonts/noto-cjk/tree/main/Serif#super-otc
86-
, then uncompress and deploy them.
95+
96+
then uncompress and deploy them.
8797
- Remember to update fontconfig cache by running fc-cache.
8898
89-
!!! Caution !!!
99+
.. caution::
90100
Uninstalling "variable font" packages can be dangerous.
91101
They might be depended upon by other packages important for your work.
92102
Denylisting should be less invasive, as it is effective only while
@@ -115,10 +125,15 @@ def __init__(self, deny_vf=None):
115125
self.re_cjk = re.compile(r"([^:]+):\s*Noto\s+(Sans|Sans Mono|Serif) CJK")
116126

117127
def description(self):
128+
"""
129+
Returns module description.
130+
"""
118131
return __doc__
119132

120133
def get_noto_cjk_vf_fonts(self):
121-
"""Get Noto CJK fonts"""
134+
"""
135+
Get Noto CJK fonts.
136+
"""
122137

123138
cjk_fonts = set()
124139
cmd = ["fc-list", ":", "file", "family", "variable"]
@@ -143,7 +158,9 @@ def get_noto_cjk_vf_fonts(self):
143158
return sorted(cjk_fonts)
144159

145160
def check(self):
146-
"""Check for problems with CJK fonts"""
161+
"""
162+
Check for problems with CJK fonts.
163+
"""
147164

148165
fonts = textwrap.indent("\n".join(self.get_noto_cjk_vf_fonts()), " ")
149166
if not fonts:

0 commit comments

Comments
 (0)