* [PATCH 0/3] Drop another script used during doc builds
@ 2025-09-12 14:27 Mauro Carvalho Chehab
2025-09-12 14:27 ` [PATCH 1/3] scripts/check-variable-fonts.sh: convert to Python Mauro Carvalho Chehab
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2025-09-12 14:27 UTC (permalink / raw)
To: Jonathan Corbet, Linux Doc Mailing List
Cc: Mauro Carvalho Chehab, linux-kernel, Akira Yokosawa
Hi Jon,
Heh, with all those scripts and hacks that were accumulated with time
for docs makefile, placing them there with absolutely no documentation,
I ended missing scripts/check-variable-fonts.sh.
I only realized today when searching for the "|| exit" hack we added
in 2017 to fix an issue where make pdfdocs were always returning
errors (again, not documented).
This series comes after(*):
https://lore.kernel.org/linux-doc/cover.1757677427.git.mchehab+huawei@kernel.org/T/#t
(*) I should probably have named such series as:
"Move the trick-or-treat build hacks accumulated over time into a single place and document them."
This specific script is called only when PDF build fails. Re-add
it at sphinx-build-wrapper logic. After it, problematic PDF
builds will warn again about possible issues with CJK variable
fonts:
$ make SPHINXDIRS=translations pdfdocs
Summary
=======
translations: FAILED
=============================================================================
XeTeX is confused by "variable font" files listed below:
/usr/share/fonts/google-noto-sans-cjk-vf-fonts/NotoSansCJK-VF.ttc
/usr/share/fonts/google-noto-sans-mono-cjk-vf-fonts/NotoSansMonoCJK-VF.ttc
/usr/share/fonts/google-noto-serif-cjk-vf-fonts/NotoSerifCJK-VF.ttc
For CJK pages in PDF, they need to be hidden from XeTeX by denylisting.
Or, CJK pages can be skipped by uninstalling texlive-xecjk.
For more info on denylisting, other options, and variable font, see header
comments of tools/docs/lib/latex_fonts.py.
=============================================================================
PDF build failed: not all PDF files were created.
make[2]: *** [Documentation/Makefile:58: pdfdocs] Error 1
make[1]: *** [/new_devel/docs/Makefile:1806: pdfdocs] Error 2
make: *** [Makefile:248: __sub-make] Error 2
The output message is identical, except that it now uses __file__ to get the
actual location of the verify code (which is now part of a docs lib).
All comments from the original code were preserved, but I opted to use
python docstring to store it. This way, we may even add something like
print(__doc__) in the future, if needed.
I also opted to preserve a command-line interface, which does nothing but
call the check function:
$ ./tools/docs/check-variable-fonts.py
=============================================================================
XeTeX is confused by "variable font" files listed below:
/usr/share/fonts/google-noto-sans-cjk-vf-fonts/NotoSansCJK-VF.ttc
/usr/share/fonts/google-noto-sans-mono-cjk-vf-fonts/NotoSansMonoCJK-VF.ttc
/usr/share/fonts/google-noto-serif-cjk-vf-fonts/NotoSerifCJK-VF.ttc
For CJK pages in PDF, they need to be hidden from XeTeX by denylisting.
Or, CJK pages can be skipped by uninstalling texlive-xecjk.
For more info on denylisting, other options, and variable font, see header
comments of tools/docs/lib/latex_fonts.py.
=============================================================================
I opted to place it into a class, as we can one day add more functions there,
for instance to create the proposed XML file under ~/deny-vc, as the script's
documentation proposes.
By using a class, we only need to import the class: all functions from
such class are automatically imported altogether. Plus, we don't have to
deal with namespaces for a function called "check()".
Mauro Carvalho Chehab (3):
scripts/check-variable-fonts.sh: convert to Python
scripts: check-variable-fonts.py: split into a lib and an exec file
tools/docs: sphinx-build-wrapper: warn about broken PDF fonts
MAINTAINERS | 1 -
scripts/check-variable-fonts.sh | 115 --------------------
tools/docs/check-variable-fonts.py | 23 ++++
tools/docs/lib/latex_fonts.py | 162 +++++++++++++++++++++++++++++
tools/docs/sphinx-build-wrapper | 9 +-
5 files changed, 192 insertions(+), 118 deletions(-)
delete mode 100755 scripts/check-variable-fonts.sh
create mode 100755 tools/docs/check-variable-fonts.py
create mode 100755 tools/docs/lib/latex_fonts.py
--
2.50.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] scripts/check-variable-fonts.sh: convert to Python
2025-09-12 14:27 [PATCH 0/3] Drop another script used during doc builds Mauro Carvalho Chehab
@ 2025-09-12 14:27 ` Mauro Carvalho Chehab
2025-09-12 14:27 ` [PATCH 2/3] scripts: check-variable-fonts.py: split into a lib and an exec file Mauro Carvalho Chehab
2025-09-12 14:27 ` [PATCH 3/3] tools/docs: sphinx-build-wrapper: warn about broken PDF fonts Mauro Carvalho Chehab
2 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2025-09-12 14:27 UTC (permalink / raw)
To: Jonathan Corbet, Linux Doc Mailing List
Cc: Mauro Carvalho Chehab, Akira Yokosawa, linux-kernel
This script handle errors when trying to build translations
with make pdfdocs.
As part of our cleanup work to remove hacks from docs Makefile,
convert this to python, preparing it to be part of a library
to be called by sphinx-build-wrapper.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
MAINTAINERS | 2 +-
...iable-fonts.sh => check-variable-fonts.py} | 104 +++++++++++++-----
2 files changed, 78 insertions(+), 28 deletions(-)
rename scripts/{check-variable-fonts.sh => check-variable-fonts.py} (61%)
diff --git a/MAINTAINERS b/MAINTAINERS
index 06bbed30b788..8cc14c85fdf5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7301,7 +7301,7 @@ S: Maintained
P: Documentation/doc-guide/maintainer-profile.rst
T: git git://git.lwn.net/linux.git docs-next
F: Documentation/
-F: scripts/check-variable-fonts.sh
+F: scripts/check-variable-fonts.py
F: scripts/checktransupdate.py
F: scripts/documentation-file-ref-check
F: scripts/get_abi.py
diff --git a/scripts/check-variable-fonts.sh b/scripts/check-variable-fonts.py
similarity index 61%
rename from scripts/check-variable-fonts.sh
rename to scripts/check-variable-fonts.py
index ce63f0acea5f..71b88b680a73 100755
--- a/scripts/check-variable-fonts.sh
+++ b/scripts/check-variable-fonts.py
@@ -1,7 +1,9 @@
-#!/bin/sh
+#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (C) Akira Yokosawa, 2024
#
+# Ported to Python by (c) Mauro Carvalho Chehab, 2025
+#
# For "make pdfdocs", reports of build errors of translations.pdf started
# arriving early 2024 [1, 2]. It turned out that Fedora and openSUSE
# tumbleweed have started deploying variable-font [3] format of "Noto CJK"
@@ -87,29 +89,77 @@
# Denylisting should be less invasive, as it is effective only while
# XeLaTeX runs in "make pdfdocs".
-# Default per-user fontconfig path (overridden by env variable)
-: ${FONTS_CONF_DENY_VF:=$HOME/deny-vf}
-
-export XDG_CONFIG_HOME=${FONTS_CONF_DENY_VF}
-
-notocjkvffonts=`fc-list : file family variable | \
- grep 'variable=True' | \
- grep -E -e 'Noto (Sans|Sans Mono|Serif) CJK' | \
- sed -e 's/^/ /' -e 's/: Noto S.*$//' | sort | uniq`
-
-if [ "x$notocjkvffonts" != "x" ] ; then
- echo '============================================================================='
- echo 'XeTeX is confused by "variable font" files listed below:'
- echo "$notocjkvffonts"
- echo
- echo 'For CJK pages in PDF, they need to be hidden from XeTeX by denylisting.'
- echo 'Or, CJK pages can be skipped by uninstalling texlive-xecjk.'
- echo
- echo 'For more info on denylisting, other options, and variable font, see header'
- echo 'comments of scripts/check-variable-fonts.sh.'
- echo '============================================================================='
-fi
-
-# As this script is invoked from Makefile's error path, always error exit
-# regardless of whether any variable font is discovered or not.
-exit 1
+import os
+import re
+import subprocess
+import sys
+import textwrap
+
+class LatexFontChecker:
+ """
+ Detect problems with CJK variable fonts that affect PDF builds for
+ translations.
+ """
+
+ def __init__(self):
+ deny_vf = os.environ.get('FONTS_CONF_DENY_VF', "~/deny-vf")
+
+ self.environ = os.environ.copy()
+ self.environ['XDG_CONFIG_HOMEF'] = os.path.expanduser(deny_vf)
+
+ self.re_cjk = re.compile(r"([^:]+):\s*Noto\s+(Sans|Sans Mono|Serif) CJK")
+
+ def get_noto_cjk_vf_fonts(self):
+ """Get Noto CJK fonts"""
+
+ cjk_fonts = set()
+ cmd = ["fc-list", ":", "file", "family", "variable"]
+ try:
+ result = subprocess.run(cmd,stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ universal_newlines=True,
+ env=self.environ,
+ check=True)
+
+ except subprocess.CalledProcessError as exc:
+ sys.exit(f"Error running fc-list: {repr(exc)}")
+
+ for line in result.stdout.splitlines():
+ if 'variable=True' not in line:
+ continue
+
+ match = self.re_cjk.search(line)
+ if match:
+ cjk_fonts.add(match.group(1))
+
+ return sorted(cjk_fonts)
+
+ def check(self):
+ """Check for problems with CJK fonts"""
+
+ fonts = textwrap.indent("\n".join(self.get_noto_cjk_vf_fonts()), " ")
+ if not fonts:
+ return None
+
+ rel_file = os.path.relpath(__file__, os.getcwd())
+
+ msg = "=" * 77 + "\n"
+ msg += 'XeTeX is confused by "variable font" files listed below:\n'
+ msg += fonts + "\n"
+ msg += textwrap.dedent(f"""
+ For CJK pages in PDF, they need to be hidden from XeTeX by denylisting.
+ Or, CJK pages can be skipped by uninstalling texlive-xecjk.
+
+ For more info on denylisting, other options, and variable font, see header
+ comments of {rel_file}.
+ """)
+ msg += "=" * 77
+
+ return msg
+
+if __name__ == "__main__":
+ msg = LatexFontChecker().check()
+ if msg:
+ print(msg)
+
+ sys.exit(1)
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] scripts: check-variable-fonts.py: split into a lib and an exec file
2025-09-12 14:27 [PATCH 0/3] Drop another script used during doc builds Mauro Carvalho Chehab
2025-09-12 14:27 ` [PATCH 1/3] scripts/check-variable-fonts.sh: convert to Python Mauro Carvalho Chehab
@ 2025-09-12 14:27 ` Mauro Carvalho Chehab
2025-09-12 14:27 ` [PATCH 3/3] tools/docs: sphinx-build-wrapper: warn about broken PDF fonts Mauro Carvalho Chehab
2 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2025-09-12 14:27 UTC (permalink / raw)
To: Jonathan Corbet, Linux Doc Mailing List
Cc: Mauro Carvalho Chehab, Akira Yokosawa, linux-kernel
As we'll be using the actual code inside sphinx-build-wrapper,
split the library from the executable, placing the exec at
the new place we've been using:
tools/docs
No functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
MAINTAINERS | 1 -
scripts/check-variable-fonts.py | 165 -----------------------------
tools/docs/check-variable-fonts.py | 23 ++++
tools/docs/lib/latex_fonts.py | 162 ++++++++++++++++++++++++++++
4 files changed, 185 insertions(+), 166 deletions(-)
delete mode 100755 scripts/check-variable-fonts.py
create mode 100755 tools/docs/check-variable-fonts.py
create mode 100755 tools/docs/lib/latex_fonts.py
diff --git a/MAINTAINERS b/MAINTAINERS
index 8cc14c85fdf5..16a5d6ab627d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7301,7 +7301,6 @@ S: Maintained
P: Documentation/doc-guide/maintainer-profile.rst
T: git git://git.lwn.net/linux.git docs-next
F: Documentation/
-F: scripts/check-variable-fonts.py
F: scripts/checktransupdate.py
F: scripts/documentation-file-ref-check
F: scripts/get_abi.py
diff --git a/scripts/check-variable-fonts.py b/scripts/check-variable-fonts.py
deleted file mode 100755
index 71b88b680a73..000000000000
--- a/scripts/check-variable-fonts.py
+++ /dev/null
@@ -1,165 +0,0 @@
-#!/usr/bin/env python3
-# SPDX-License-Identifier: GPL-2.0-only
-# Copyright (C) Akira Yokosawa, 2024
-#
-# Ported to Python by (c) Mauro Carvalho Chehab, 2025
-#
-# For "make pdfdocs", reports of build errors of translations.pdf started
-# arriving early 2024 [1, 2]. It turned out that Fedora and openSUSE
-# tumbleweed have started deploying variable-font [3] format of "Noto CJK"
-# fonts [4, 5]. For PDF, a LaTeX package named xeCJK is used for CJK
-# (Chinese, Japanese, Korean) pages. xeCJK requires XeLaTeX/XeTeX, which
-# does not (and likely never will) understand variable fonts for historical
-# reasons.
-#
-# The build error happens even when both of variable- and non-variable-format
-# fonts are found on the build system. To make matters worse, Fedora enlists
-# variable "Noto CJK" fonts in the requirements of langpacks-ja, -ko, -zh_CN,
-# -zh_TW, etc. Hence developers who have interest in CJK pages are more
-# likely to encounter the build errors.
-#
-# This script is invoked from the error path of "make pdfdocs" and emits
-# suggestions if variable-font files of "Noto CJK" fonts are in the list of
-# fonts accessible from XeTeX.
-#
-# References:
-# [1]: https://lore.kernel.org/r/8734tqsrt7.fsf@meer.lwn.net/
-# [2]: https://lore.kernel.org/r/1708585803.600323099@f111.i.mail.ru/
-# [3]: https://en.wikipedia.org/wiki/Variable_font
-# [4]: https://fedoraproject.org/wiki/Changes/Noto_CJK_Variable_Fonts
-# [5]: https://build.opensuse.org/request/show/1157217
-#
-#===========================================================================
-# Workarounds for building translations.pdf
-#===========================================================================
-#
-# * Denylist "variable font" Noto CJK fonts.
-# - Create $HOME/deny-vf/fontconfig/fonts.conf from template below, with
-# tweaks if necessary. Remove leading "# ".
-# - Path of fontconfig/fonts.conf can be overridden by setting an env
-# variable FONTS_CONF_DENY_VF.
-#
-# * Template:
-# -----------------------------------------------------------------
-# <?xml version="1.0"?>
-# <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
-# <fontconfig>
-# <!--
-# Ignore variable-font glob (not to break xetex)
-# -->
-# <selectfont>
-# <rejectfont>
-# <!--
-# for Fedora
-# -->
-# <glob>/usr/share/fonts/google-noto-*-cjk-vf-fonts</glob>
-# <!--
-# for openSUSE tumbleweed
-# -->
-# <glob>/usr/share/fonts/truetype/Noto*CJK*-VF.otf</glob>
-# </rejectfont>
-# </selectfont>
-# </fontconfig>
-# -----------------------------------------------------------------
-#
-# The denylisting is activated for "make pdfdocs".
-#
-# * For skipping CJK pages in PDF
-# - Uninstall texlive-xecjk.
-# Denylisting is not needed in this case.
-#
-# * For printing CJK pages in PDF
-# - Need non-variable "Noto CJK" fonts.
-# * Fedora
-# - google-noto-sans-cjk-fonts
-# - google-noto-serif-cjk-fonts
-# * openSUSE tumbleweed
-# - Non-variable "Noto CJK" fonts are not available as distro packages
-# as of April, 2024. Fetch a set of font files from upstream Noto
-# CJK Font released at:
-# https://github.com/notofonts/noto-cjk/tree/main/Sans#super-otc
-# and at:
-# https://github.com/notofonts/noto-cjk/tree/main/Serif#super-otc
-# , then uncompress and deploy them.
-# - Remember to update fontconfig cache by running fc-cache.
-#
-# !!! Caution !!!
-# Uninstalling "variable font" packages can be dangerous.
-# They might be depended upon by other packages important for your work.
-# Denylisting should be less invasive, as it is effective only while
-# XeLaTeX runs in "make pdfdocs".
-
-import os
-import re
-import subprocess
-import sys
-import textwrap
-
-class LatexFontChecker:
- """
- Detect problems with CJK variable fonts that affect PDF builds for
- translations.
- """
-
- def __init__(self):
- deny_vf = os.environ.get('FONTS_CONF_DENY_VF', "~/deny-vf")
-
- self.environ = os.environ.copy()
- self.environ['XDG_CONFIG_HOMEF'] = os.path.expanduser(deny_vf)
-
- self.re_cjk = re.compile(r"([^:]+):\s*Noto\s+(Sans|Sans Mono|Serif) CJK")
-
- def get_noto_cjk_vf_fonts(self):
- """Get Noto CJK fonts"""
-
- cjk_fonts = set()
- cmd = ["fc-list", ":", "file", "family", "variable"]
- try:
- result = subprocess.run(cmd,stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- universal_newlines=True,
- env=self.environ,
- check=True)
-
- except subprocess.CalledProcessError as exc:
- sys.exit(f"Error running fc-list: {repr(exc)}")
-
- for line in result.stdout.splitlines():
- if 'variable=True' not in line:
- continue
-
- match = self.re_cjk.search(line)
- if match:
- cjk_fonts.add(match.group(1))
-
- return sorted(cjk_fonts)
-
- def check(self):
- """Check for problems with CJK fonts"""
-
- fonts = textwrap.indent("\n".join(self.get_noto_cjk_vf_fonts()), " ")
- if not fonts:
- return None
-
- rel_file = os.path.relpath(__file__, os.getcwd())
-
- msg = "=" * 77 + "\n"
- msg += 'XeTeX is confused by "variable font" files listed below:\n'
- msg += fonts + "\n"
- msg += textwrap.dedent(f"""
- For CJK pages in PDF, they need to be hidden from XeTeX by denylisting.
- Or, CJK pages can be skipped by uninstalling texlive-xecjk.
-
- For more info on denylisting, other options, and variable font, see header
- comments of {rel_file}.
- """)
- msg += "=" * 77
-
- return msg
-
-if __name__ == "__main__":
- msg = LatexFontChecker().check()
- if msg:
- print(msg)
-
- sys.exit(1)
diff --git a/tools/docs/check-variable-fonts.py b/tools/docs/check-variable-fonts.py
new file mode 100755
index 000000000000..79b28f0f7d85
--- /dev/null
+++ b/tools/docs/check-variable-fonts.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright (C) Akira Yokosawa, 2024
+#
+# Ported to Python by (c) Mauro Carvalho Chehab, 2025
+#
+# pylint: disable=C0103
+
+"""
+Detect problematic Noto CJK variable fonts.
+
+or more details, see lib/latex_fonts.py.
+"""
+
+import sys
+
+from lib.latex_fonts import LatexFontChecker
+
+msg = LatexFontChecker().check()
+if msg:
+ print(msg)
+
+sys.exit(1)
diff --git a/tools/docs/lib/latex_fonts.py b/tools/docs/lib/latex_fonts.py
new file mode 100755
index 000000000000..e03412e3947e
--- /dev/null
+++ b/tools/docs/lib/latex_fonts.py
@@ -0,0 +1,162 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright (C) Akira Yokosawa, 2024
+#
+# Ported to Python by (c) Mauro Carvalho Chehab, 2025
+
+"""
+Detect problematic Noto CJK variable fonts.
+
+For "make pdfdocs", reports of build errors of translations.pdf started
+arriving early 2024 [1, 2]. It turned out that Fedora and openSUSE
+tumbleweed have started deploying variable-font [3] format of "Noto CJK"
+fonts [4, 5]. For PDF, a LaTeX package named xeCJK is used for CJK
+(Chinese, Japanese, Korean) pages. xeCJK requires XeLaTeX/XeTeX, which
+does not (and likely never will) understand variable fonts for historical
+reasons.
+
+The build error happens even when both of variable- and non-variable-format
+fonts are found on the build system. To make matters worse, Fedora enlists
+variable "Noto CJK" fonts in the requirements of langpacks-ja, -ko, -zh_CN,
+-zh_TW, etc. Hence developers who have interest in CJK pages are more
+likely to encounter the build errors.
+
+This script is invoked from the error path of "make pdfdocs" and emits
+suggestions if variable-font files of "Noto CJK" fonts are in the list of
+fonts accessible from XeTeX.
+
+References:
+[1]: https://lore.kernel.org/r/8734tqsrt7.fsf@meer.lwn.net/
+[2]: https://lore.kernel.org/r/1708585803.600323099@f111.i.mail.ru/
+[3]: https://en.wikipedia.org/wiki/Variable_font
+[4]: https://fedoraproject.org/wiki/Changes/Noto_CJK_Variable_Fonts
+[5]: https://build.opensuse.org/request/show/1157217
+
+#===========================================================================
+Workarounds for building translations.pdf
+#===========================================================================
+
+* Denylist "variable font" Noto CJK fonts.
+ - Create $HOME/deny-vf/fontconfig/fonts.conf from template below, with
+ tweaks if necessary. Remove leading "".
+ - Path of fontconfig/fonts.conf can be overridden by setting an env
+ variable FONTS_CONF_DENY_VF.
+
+ * Template:
+-----------------------------------------------------------------
+<?xml version="1.0"?>
+<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
+<fontconfig>
+<!--
+ Ignore variable-font glob (not to break xetex)
+-->
+ <selectfont>
+ <rejectfont>
+ <!--
+ for Fedora
+ -->
+ <glob>/usr/share/fonts/google-noto-*-cjk-vf-fonts</glob>
+ <!--
+ for openSUSE tumbleweed
+ -->
+ <glob>/usr/share/fonts/truetype/Noto*CJK*-VF.otf</glob>
+ </rejectfont>
+ </selectfont>
+</fontconfig>
+-----------------------------------------------------------------
+
+ The denylisting is activated for "make pdfdocs".
+
+* For skipping CJK pages in PDF
+ - Uninstall texlive-xecjk.
+ Denylisting is not needed in this case.
+
+* For printing CJK pages in PDF
+ - Need non-variable "Noto CJK" fonts.
+ * Fedora
+ - google-noto-sans-cjk-fonts
+ - google-noto-serif-cjk-fonts
+ * openSUSE tumbleweed
+ - Non-variable "Noto CJK" fonts are not available as distro packages
+ as of April, 2024. Fetch a set of font files from upstream Noto
+ CJK Font released at:
+ https://github.com/notofonts/noto-cjk/tree/main/Sans#super-otc
+ and at:
+ https://github.com/notofonts/noto-cjk/tree/main/Serif#super-otc
+ , then uncompress and deploy them.
+ - Remember to update fontconfig cache by running fc-cache.
+
+!!! Caution !!!
+ Uninstalling "variable font" packages can be dangerous.
+ They might be depended upon by other packages important for your work.
+ Denylisting should be less invasive, as it is effective only while
+ XeLaTeX runs in "make pdfdocs".
+"""
+
+import os
+import re
+import subprocess
+import textwrap
+import sys
+
+class LatexFontChecker:
+ """
+ Detect problems with CJK variable fonts that affect PDF builds for
+ translations.
+ """
+
+ def __init__(self):
+ deny_vf = os.environ.get('FONTS_CONF_DENY_VF', "~/deny-vf")
+
+ self.environ = os.environ.copy()
+ self.environ['XDG_CONFIG_HOMEF'] = os.path.expanduser(deny_vf)
+
+ self.re_cjk = re.compile(r"([^:]+):\s*Noto\s+(Sans|Sans Mono|Serif) CJK")
+
+ def get_noto_cjk_vf_fonts(self):
+ """Get Noto CJK fonts"""
+
+ cjk_fonts = set()
+ cmd = ["fc-list", ":", "file", "family", "variable"]
+ try:
+ result = subprocess.run(cmd,stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ universal_newlines=True,
+ env=self.environ,
+ check=True)
+
+ except subprocess.CalledProcessError as exc:
+ sys.exit(f"Error running fc-list: {repr(exc)}")
+
+ for line in result.stdout.splitlines():
+ if 'variable=True' not in line:
+ continue
+
+ match = self.re_cjk.search(line)
+ if match:
+ cjk_fonts.add(match.group(1))
+
+ return sorted(cjk_fonts)
+
+ def check(self):
+ """Check for problems with CJK fonts"""
+
+ fonts = textwrap.indent("\n".join(self.get_noto_cjk_vf_fonts()), " ")
+ if not fonts:
+ return None
+
+ rel_file = os.path.relpath(__file__, os.getcwd())
+
+ msg = "=" * 77 + "\n"
+ msg += 'XeTeX is confused by "variable font" files listed below:\n'
+ msg += fonts + "\n"
+ msg += textwrap.dedent(f"""
+ For CJK pages in PDF, they need to be hidden from XeTeX by denylisting.
+ Or, CJK pages can be skipped by uninstalling texlive-xecjk.
+
+ For more info on denylisting, other options, and variable font, see header
+ comments of {rel_file}.
+ """)
+ msg += "=" * 77
+
+ return msg
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] tools/docs: sphinx-build-wrapper: warn about broken PDF fonts
2025-09-12 14:27 [PATCH 0/3] Drop another script used during doc builds Mauro Carvalho Chehab
2025-09-12 14:27 ` [PATCH 1/3] scripts/check-variable-fonts.sh: convert to Python Mauro Carvalho Chehab
2025-09-12 14:27 ` [PATCH 2/3] scripts: check-variable-fonts.py: split into a lib and an exec file Mauro Carvalho Chehab
@ 2025-09-12 14:27 ` Mauro Carvalho Chehab
2 siblings, 0 replies; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2025-09-12 14:27 UTC (permalink / raw)
To: Jonathan Corbet, Linux Doc Mailing List
Cc: Mauro Carvalho Chehab, Akira Yokosawa, linux-kernel
Depending on the latex install environment, translations can
be broken because of CJK variable fonts. Add a warning in
the end.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
tools/docs/sphinx-build-wrapper | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/docs/sphinx-build-wrapper b/tools/docs/sphinx-build-wrapper
index c47f723391b9..d40fc25071c6 100755
--- a/tools/docs/sphinx-build-wrapper
+++ b/tools/docs/sphinx-build-wrapper
@@ -54,10 +54,11 @@ import subprocess
import sys
from concurrent import futures
-
-from lib.python_version import PythonVersion
from glob import glob
+from lib.python_version import PythonVersion
+from lib.latex_fonts import LatexFontChecker
+
LIB_DIR = "../../scripts/lib"
SRC_DIR = os.path.dirname(os.path.realpath(__file__))
@@ -476,6 +477,10 @@ class SphinxBuilder:
print()
if build_failed:
+ msg = LatexFontChecker().check()
+ if msg:
+ print(msg)
+
sys.exit("PDF build failed: not all PDF files were created.")
else:
print("All PDF files were built.")
--
2.50.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-12 14:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-12 14:27 [PATCH 0/3] Drop another script used during doc builds Mauro Carvalho Chehab
2025-09-12 14:27 ` [PATCH 1/3] scripts/check-variable-fonts.sh: convert to Python Mauro Carvalho Chehab
2025-09-12 14:27 ` [PATCH 2/3] scripts: check-variable-fonts.py: split into a lib and an exec file Mauro Carvalho Chehab
2025-09-12 14:27 ` [PATCH 3/3] tools/docs: sphinx-build-wrapper: warn about broken PDF fonts Mauro Carvalho Chehab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).