xelatex doesn't understand variable font format. Recent deployment of variable Noto CJK fonts in Fedora and openSUSE tumbleweed breaks builds of translations.pdf. To help developers work around the build error, add a script for checking existence of variable form of those fonts and emitting suggestions. Invoke it in the error path of "make pdfdocs" so that it is activated only when PDF build actually fails. Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx> Reported-by: Jonathan Corbet <corbet@xxxxxxx> Link: https://lore.kernel.org/r/8734tqsrt7.fsf@xxxxxxxxxxxx/ Reported-by: "Иван Иванович" <relect@xxxxx> Link: https://lore.kernel.org/linux-doc/1708585803.600323099@xxxxxxxxxxxxxx/ --- This is not in line with Jon's suggestion of tweaking sphinx-pre-install and/or kerneldoc-preamble.sty [1]. [1]: https://lore.kernel.org/r/87o7ccpcob.fsf@xxxxxxxxxxxx/ It would be ideal if kerneldoc-preamble.sty can be taught about the way to detect the existence of variable fonts and to skip CJK contents. However, it seems that it would add overly complex code for choosing fonts by file names with meticulous options to select CJK variant (SC, TC, KR, or JP) to use. Furthermore, as location and names of font files can be different among distro packages, keeping portability of the preamble is impossible in practice. As for sphinx-pre-install, even if variable "Noto CJK" fonts are found, they don't matter for non-CJK PDFs. Emitting warning every time would be noisy. Therefore, as a minimal approach, to help developers find a way forward, giving suggestions after the fact sounds like a reasonable approach to me, at least for the time being. Jon, you said in [1]: >> What does >> >> fc-list | grep NotoSansCJK-VF.ttc >> >> say? > > No output at all, even though I had google-noto-sans-cjk-vf-fonts > installed. So I'm wondering if scripts/check-variable-font.sh in this patch emits useful suggestions. Could you give it a try? - Install google-noto-sans-cjk-vf-fonts - Install google-noto-serif-cjk-vf-fonts - What does "sh scripts/check-variable-font.sh" say? - Run "make cleandocs; make SPHINXDIRS=translations pdfdocs". Do you see the suggestion after the build error? - Uninstall above 2 font packages. - What does "sh scripts/check-variable-font.sh" say now? - Run "make cleandocs; make SPHINXDIRS=translations pdfdocs" again. Does it complete successfully? Thanks, Akira --- Cc: linux-doc@xxxxxxxxxxxxxxx --- Documentation/Makefile | 2 +- MAINTAINERS | 1 + scripts/check-variable-fonts.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 scripts/check-variable-fonts.sh diff --git a/Documentation/Makefile b/Documentation/Makefile index b68f8c816897..e7ff288bfd15 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -154,7 +154,7 @@ else # HAVE_PDFLATEX pdfdocs: latexdocs @$(srctree)/scripts/sphinx-pre-install --version-check $(foreach var,$(SPHINXDIRS), \ - $(MAKE) PDFLATEX="$(PDFLATEX)" LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex || exit; \ + $(MAKE) PDFLATEX="$(PDFLATEX)" LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex || sh $(srctree)/scripts/check-variable-fonts.sh || exit; \ mkdir -p $(BUILDDIR)/$(var)/pdf; \ mv $(subst .tex,.pdf,$(wildcard $(BUILDDIR)/$(var)/latex/*.tex)) $(BUILDDIR)/$(var)/pdf/; \ ) diff --git a/MAINTAINERS b/MAINTAINERS index 741d9142b343..3858416a2d67 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6346,6 +6346,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-font.sh F: scripts/documentation-file-ref-check F: scripts/kernel-doc F: scripts/sphinx-pre-install diff --git a/scripts/check-variable-fonts.sh b/scripts/check-variable-fonts.sh new file mode 100755 index 000000000000..775800edb9fc --- /dev/null +++ b/scripts/check-variable-fonts.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# For "make pdfdocs", recent trend of deploying variable type of +# "Noto Sans CJK" and "Noto Serif CJK" fonts breaks xelatex, which does +# not understand variable fonts. +# +# It is hard to distinguish variable fonts from static ones in the preamble +# of LaTeX source code. Instead, this script is invoked in the error path +# of "make pdfdocs" and emit suggestions if such font files are found. +# +# Assumption: +# File names are not changed from those of upstream Noto CJK fonts: +# https://github.com/notofonts/noto-cjk/ + +vffonts=`fc-list -b | grep -i noto | grep -i cjk | grep -F -i -e "-vf" | \ + sort | uniq | sed -e 's/\tfile:/ file:/' | sed -e 's/(s)$//'` + +if [ "x$vffonts" != "x" ] ; then + echo "=====================================================================" + echo "Detected variable form of Noto CJK fonts incompatible with xelatex:" + echo "$vffonts" + echo "If you need CJK contents in PDF, remove them and install static ones." + echo "Otherwise, get rid of texlive-xecjk." + echo "=====================================================================" +fi + +# As this script is invoked from Makefile's error path, always error exit +# even if no variable font is detected. +exit 1 base-commit: b8cfda5c9065cd619a97c17da081cbfab3b1e756 -- 2.34.1