All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] docs: Detect variable fonts and suggest removing them
@ 2024-03-23 12:02 Akira Yokosawa
  2024-03-23 14:55 ` Randy Dunlap
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Akira Yokosawa @ 2024-03-23 12:02 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: linux-doc, Akira Yokosawa,
	Иван
	Иванович

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@gmail.com>
Reported-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/8734tqsrt7.fsf@meer.lwn.net/
Reported-by: "Иван Иванович" <relect@bk.ru>
Link: https://lore.kernel.org/linux-doc/1708585803.600323099@f111.i.mail.ru/
---
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@meer.lwn.net/

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@vger.kernel.org
---
 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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-04-10 23:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-23 12:02 [PATCH] docs: Detect variable fonts and suggest removing them Akira Yokosawa
2024-03-23 14:55 ` Randy Dunlap
2024-03-24  0:05   ` Akira Yokosawa
2024-03-24  0:34     ` Randy Dunlap
2024-03-29 14:35 ` Jonathan Corbet
2024-03-29 15:00   ` Akira Yokosawa
2024-04-06  2:04 ` [PATCH v2] docs: Detect variable fonts and suggest denylisting them Akira Yokosawa
2024-04-10 20:52   ` Jonathan Corbet
2024-04-10 22:57     ` Akira Yokosawa
2024-04-10 23:36       ` Jonathan Corbet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.