11e596d5eSAkira Yokosawa#!/bin/sh 21e596d5eSAkira Yokosawa# SPDX-License-Identifier: GPL-2.0-only 31e596d5eSAkira Yokosawa# Copyright (C) Akira Yokosawa, 2024 41e596d5eSAkira Yokosawa# 51e596d5eSAkira Yokosawa# For "make pdfdocs", reports of build errors of translations.pdf started 61e596d5eSAkira Yokosawa# arriving early 2024 [1, 2]. It turned out that Fedora and openSUSE 71e596d5eSAkira Yokosawa# tumbleweed have started deploying variable-font [3] format of "Noto CJK" 81e596d5eSAkira Yokosawa# fonts [4, 5]. For PDF, a LaTeX package named xeCJK is used for CJK 91e596d5eSAkira Yokosawa# (Chinese, Japanese, Korean) pages. xeCJK requires XeLaTeX/XeTeX, which 101e596d5eSAkira Yokosawa# does not (and likely never will) understand variable fonts for historical 111e596d5eSAkira Yokosawa# reasons. 121e596d5eSAkira Yokosawa# 131e596d5eSAkira Yokosawa# The build error happens even when both of variable- and non-variable-format 141e596d5eSAkira Yokosawa# fonts are found on the build system. To make matters worse, Fedora enlists 151e596d5eSAkira Yokosawa# variable "Noto CJK" fonts in the requirements of langpacks-ja, -ko, -zh_CN, 161e596d5eSAkira Yokosawa# -zh_TW, etc. Hence developers who have interest in CJK pages are more 171e596d5eSAkira Yokosawa# likely to encounter the build errors. 181e596d5eSAkira Yokosawa# 191e596d5eSAkira Yokosawa# This script is invoked from the error path of "make pdfdocs" and emits 201e596d5eSAkira Yokosawa# suggestions if variable-font files of "Noto CJK" fonts are in the list of 211e596d5eSAkira Yokosawa# fonts accessible from XeTeX. 221e596d5eSAkira Yokosawa# 231e596d5eSAkira Yokosawa# References: 241e596d5eSAkira Yokosawa# [1]: https://lore.kernel.org/r/8734tqsrt7.fsf@meer.lwn.net/ 251e596d5eSAkira Yokosawa# [2]: https://lore.kernel.org/r/1708585803.600323099@f111.i.mail.ru/ 261e596d5eSAkira Yokosawa# [3]: https://en.wikipedia.org/wiki/Variable_font 271e596d5eSAkira Yokosawa# [4]: https://fedoraproject.org/wiki/Changes/Noto_CJK_Variable_Fonts 281e596d5eSAkira Yokosawa# [5]: https://build.opensuse.org/request/show/1157217 291e596d5eSAkira Yokosawa# 301e596d5eSAkira Yokosawa#=========================================================================== 311e596d5eSAkira Yokosawa# Workarounds for building translations.pdf 321e596d5eSAkira Yokosawa#=========================================================================== 331e596d5eSAkira Yokosawa# 341e596d5eSAkira Yokosawa# * Denylist "variable font" Noto CJK fonts. 351e596d5eSAkira Yokosawa# - Create $HOME/deny-vf/fontconfig/fonts.conf from template below, with 361e596d5eSAkira Yokosawa# tweaks if necessary. Remove leading "# ". 371e596d5eSAkira Yokosawa# - Path of fontconfig/fonts.conf can be overridden by setting an env 381e596d5eSAkira Yokosawa# variable FONTS_CONF_DENY_VF. 391e596d5eSAkira Yokosawa# 401e596d5eSAkira Yokosawa# * Template: 411e596d5eSAkira Yokosawa# ----------------------------------------------------------------- 421e596d5eSAkira Yokosawa# <?xml version="1.0"?> 431e596d5eSAkira Yokosawa# <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd"> 441e596d5eSAkira Yokosawa# <fontconfig> 451e596d5eSAkira Yokosawa# <!-- 461e596d5eSAkira Yokosawa# Ignore variable-font glob (not to break xetex) 471e596d5eSAkira Yokosawa# --> 481e596d5eSAkira Yokosawa# <selectfont> 491e596d5eSAkira Yokosawa# <rejectfont> 501e596d5eSAkira Yokosawa# <!-- 511e596d5eSAkira Yokosawa# for Fedora 521e596d5eSAkira Yokosawa# --> 531e596d5eSAkira Yokosawa# <glob>/usr/share/fonts/google-noto-*-cjk-vf-fonts</glob> 541e596d5eSAkira Yokosawa# <!-- 551e596d5eSAkira Yokosawa# for openSUSE tumbleweed 561e596d5eSAkira Yokosawa# --> 571e596d5eSAkira Yokosawa# <glob>/usr/share/fonts/truetype/Noto*CJK*-VF.otf</glob> 581e596d5eSAkira Yokosawa# </rejectfont> 591e596d5eSAkira Yokosawa# </selectfont> 601e596d5eSAkira Yokosawa# </fontconfig> 611e596d5eSAkira Yokosawa# ----------------------------------------------------------------- 621e596d5eSAkira Yokosawa# 631e596d5eSAkira Yokosawa# The denylisting is activated for "make pdfdocs". 641e596d5eSAkira Yokosawa# 651e596d5eSAkira Yokosawa# * For skipping CJK pages in PDF 661e596d5eSAkira Yokosawa# - Uninstall texlive-xecjk. 671e596d5eSAkira Yokosawa# Denylisting is not needed in this case. 681e596d5eSAkira Yokosawa# 691e596d5eSAkira Yokosawa# * For printing CJK pages in PDF 701e596d5eSAkira Yokosawa# - Need non-variable "Noto CJK" fonts. 711e596d5eSAkira Yokosawa# * Fedora 721e596d5eSAkira Yokosawa# - google-noto-sans-cjk-fonts 731e596d5eSAkira Yokosawa# - google-noto-serif-cjk-fonts 741e596d5eSAkira Yokosawa# * openSUSE tumbleweed 751e596d5eSAkira Yokosawa# - Non-variable "Noto CJK" fonts are not available as distro packages 761e596d5eSAkira Yokosawa# as of April, 2024. Fetch a set of font files from upstream Noto 771e596d5eSAkira Yokosawa# CJK Font released at: 781e596d5eSAkira Yokosawa# https://github.com/notofonts/noto-cjk/tree/main/Sans#super-otc 791e596d5eSAkira Yokosawa# and at: 801e596d5eSAkira Yokosawa# https://github.com/notofonts/noto-cjk/tree/main/Serif#super-otc 811e596d5eSAkira Yokosawa# , then uncompress and deploy them. 821e596d5eSAkira Yokosawa# - Remember to update fontconfig cache by running fc-cache. 831e596d5eSAkira Yokosawa# 841e596d5eSAkira Yokosawa# !!! Caution !!! 851e596d5eSAkira Yokosawa# Uninstalling "variable font" packages can be dangerous. 861e596d5eSAkira Yokosawa# They might be depended upon by other packages important for your work. 871e596d5eSAkira Yokosawa# Denylisting should be less invasive, as it is effective only while 881e596d5eSAkira Yokosawa# XeLaTeX runs in "make pdfdocs". 891e596d5eSAkira Yokosawa 901e596d5eSAkira Yokosawa# Default per-user fontconfig path (overridden by env variable) 911e596d5eSAkira Yokosawa: ${FONTS_CONF_DENY_VF:=$HOME/deny-vf} 921e596d5eSAkira Yokosawa 931e596d5eSAkira Yokosawaexport XDG_CONFIG_HOME=${FONTS_CONF_DENY_VF} 941e596d5eSAkira Yokosawa 95*5384258fSAkira Yokosawanotocjkvffonts=`fc-list : file family variable | \ 96*5384258fSAkira Yokosawa grep 'variable=True' | \ 97*5384258fSAkira Yokosawa grep -E -e 'Noto (Sans|Sans Mono|Serif) CJK' | \ 98*5384258fSAkira Yokosawa sed -e 's/^/ /' -e 's/: Noto S.*$//' | sort | uniq` 991e596d5eSAkira Yokosawa 100*5384258fSAkira Yokosawaif [ "x$notocjkvffonts" != "x" ] ; then 1011e596d5eSAkira Yokosawa echo '=============================================================================' 1021e596d5eSAkira Yokosawa echo 'XeTeX is confused by "variable font" files listed below:' 103*5384258fSAkira Yokosawa echo "$notocjkvffonts" 1041e596d5eSAkira Yokosawa echo 1051e596d5eSAkira Yokosawa echo 'For CJK pages in PDF, they need to be hidden from XeTeX by denylisting.' 1061e596d5eSAkira Yokosawa echo 'Or, CJK pages can be skipped by uninstalling texlive-xecjk.' 1071e596d5eSAkira Yokosawa echo 1081e596d5eSAkira Yokosawa echo 'For more info on denylisting, other options, and variable font, see header' 1091e596d5eSAkira Yokosawa echo 'comments of scripts/check-variable-fonts.sh.' 1101e596d5eSAkira Yokosawa echo '=============================================================================' 1111e596d5eSAkira Yokosawafi 1121e596d5eSAkira Yokosawa 1131e596d5eSAkira Yokosawa# As this script is invoked from Makefile's error path, always error exit 1141e596d5eSAkira Yokosawa# regardless of whether any variable font is discovered or not. 1151e596d5eSAkira Yokosawaexit 1 116