tools/lib/python/kdoc/latex_fonts.py

Source file repositories/reference/linux-study-clean/tools/lib/python/kdoc/latex_fonts.py

File Facts

System
Linux kernel
Corpus path
tools/lib/python/kdoc/latex_fonts.py
Extension
.py
Size
5919 bytes
Lines
185
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/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.

.. [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

Annotation

Implementation Notes