From nobody Thu Oct 2 14:26:17 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A00E43043B8; Tue, 16 Sep 2025 10:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758018215; cv=none; b=hAWrKCxfeka5gErkFcgw3FLU7Sd9DKVv8KuwuwUlHAhJGMjRMMmwdLE4XFvTKGURxm8iV7RUaUF+hj2nXbFI0F/l5dGtBwHR0aEY63swEXsFMM4eFsF3w6CDmUFN5GeMXPeF2aR06YYEeWeYIs2CkaR6YEd5kwnUZx2IwC7EyzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758018215; c=relaxed/simple; bh=IedbeYwhGQo/8+db2YoLieE5Rt2kNjiHQ4pk5A+mit8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=gK6/neX68NXjWa8bjHDMTwGiQsoOxgeFkXfnyfFhyM5YReL3VRprULJm4Xy58Q7yAccdroDqTUruyB8X73wWiTg7yXA+HaBgAz8OTvZV1AwfVlDXmTF4Kl/YtgUU1KEvooNez6Miwn8nkEGJ1YLXs/NCgKhlMuAOoooFQWJ6jBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=shYzsQ8x; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="shYzsQ8x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82E53C4CEFC; Tue, 16 Sep 2025 10:23:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758018215; bh=IedbeYwhGQo/8+db2YoLieE5Rt2kNjiHQ4pk5A+mit8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=shYzsQ8xouvLC1n6giYdpcusnEFM9/JqIjxZG0ctsxc/FyhJLkMLISucUFS+fjfwa XLe+i9XJG+ZVxdq9+x89JbrrKKpUjQb+OOZdIGbfOh7zpsfZDOZBE3rlD6IWKIR2Mj GBvCbmzxbyMhlGWjOl5zuyRw5bjXR4KiYVR5fADtR32CdJ+OtJ6gwTvoBN0KLDCld4 jItQoLPX/gqRHZbYsUy4qcuVj1R2CmNPVCqe4eZ65MUF3mtut6fnL4FwuqHbnJB6f6 SYQursWs9ut20DHy2nV8VNkgasbG/AxZQopJRZ0DCQSVavS5AyD2bsqfe7y5Qt6YRL 5lyP+QX48WgJA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1uySqS-0000000BBOm-2yTP; Tue, 16 Sep 2025 12:23:32 +0200 From: Mauro Carvalho Chehab To: Jonathan Corbet , Linux Doc Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v6 04/21] scripts: check-variable-fonts.sh: convert to Python Date: Tue, 16 Sep 2025 12:22:40 +0200 Message-ID: <8a77212d5459eac2a98db442691930425a2cbefd.1758018030.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab 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 --- MAINTAINERS | 2 +- ...iable-fonts.sh =3D> check-variable-fonts.py} | 104 +++++++++++++----- 2 files changed, 78 insertions(+), 28 deletions(-) rename scripts/{check-variable-fonts.sh =3D> check-variable-fonts.py} (61%) diff --git a/MAINTAINERS b/MAINTAINERS index ef87548b8f88..88d8f7435e6d 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". =20 -# Default per-user fontconfig path (overridden by env variable) -: ${FONTS_CONF_DENY_VF:=3D$HOME/deny-vf} - -export XDG_CONFIG_HOME=3D${FONTS_CONF_DENY_VF} - -notocjkvffonts=3D`fc-list : file family variable | \ - grep 'variable=3DTrue' | \ - grep -E -e 'Noto (Sans|Sans Mono|Serif) CJK' | \ - sed -e 's/^/ /' -e 's/: Noto S.*$//' | sort | uniq` - -if [ "x$notocjkvffonts" !=3D "x" ] ; then - echo '=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D' - 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 denylist= ing.' - 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 '=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D' -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 =3D os.environ.get('FONTS_CONF_DENY_VF', "~/deny-vf") + + self.environ =3D os.environ.copy() + self.environ['XDG_CONFIG_HOMEF'] =3D os.path.expanduser(deny_vf) + + self.re_cjk =3D re.compile(r"([^:]+):\s*Noto\s+(Sans|Sans Mono|Ser= if) CJK") + + def get_noto_cjk_vf_fonts(self): + """Get Noto CJK fonts""" + + cjk_fonts =3D set() + cmd =3D ["fc-list", ":", "file", "family", "variable"] + try: + result =3D subprocess.run(cmd,stdout=3Dsubprocess.PIPE, + stderr=3Dsubprocess.PIPE, + universal_newlines=3DTrue, + env=3Dself.environ, + check=3DTrue) + + except subprocess.CalledProcessError as exc: + sys.exit(f"Error running fc-list: {repr(exc)}") + + for line in result.stdout.splitlines(): + if 'variable=3DTrue' not in line: + continue + + match =3D 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 =3D textwrap.indent("\n".join(self.get_noto_cjk_vf_fonts()),= " ") + if not fonts: + return None + + rel_file =3D os.path.relpath(__file__, os.getcwd()) + + msg =3D "=3D" * 77 + "\n" + msg +=3D 'XeTeX is confused by "variable font" files listed below:= \n' + msg +=3D fonts + "\n" + msg +=3D 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 +=3D "=3D" * 77 + + return msg + +if __name__ =3D=3D "__main__": + msg =3D LatexFontChecker().check() + if msg: + print(msg) + + sys.exit(1) --=20 2.51.0