1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-only 3# Copyright (C) Akira Yokosawa, 2024 4# 5# For "make pdfdocs", reports of build errors of translations.pdf started 6# arriving early 2024 [1, 2]. It turned out that Fedora and openSUSE 7# tumbleweed have started deploying variable-font [3] format of "Noto CJK" 8# fonts [4, 5]. For PDF, a LaTeX package named xeCJK is used for CJK 9# (Chinese, Japanese, Korean) pages. xeCJK requires XeLaTeX/XeTeX, which 10# does not (and likely never will) understand variable fonts for historical 11# reasons. 12# 13# The build error happens even when both of variable- and non-variable-format 14# fonts are found on the build system. To make matters worse, Fedora enlists 15# variable "Noto CJK" fonts in the requirements of langpacks-ja, -ko, -zh_CN, 16# -zh_TW, etc. Hence developers who have interest in CJK pages are more 17# likely to encounter the build errors. 18# 19# This script is invoked from the error path of "make pdfdocs" and emits 20# suggestions if variable-font files of "Noto CJK" fonts are in the list of 21# fonts accessible from XeTeX. 22# 23# Assumption: 24# File names are not modified from those of upstream Noto CJK fonts: 25# https://github.com/notofonts/noto-cjk/ 26# 27# References: 28# [1]: https://lore.kernel.org/r/[email protected]/ 29# [2]: https://lore.kernel.org/r/[email protected]/ 30# [3]: https://en.wikipedia.org/wiki/Variable_font 31# [4]: https://fedoraproject.org/wiki/Changes/Noto_CJK_Variable_Fonts 32# [5]: https://build.opensuse.org/request/show/1157217 33# 34#=========================================================================== 35# Workarounds for building translations.pdf 36#=========================================================================== 37# 38# * Denylist "variable font" Noto CJK fonts. 39# - Create $HOME/deny-vf/fontconfig/fonts.conf from template below, with 40# tweaks if necessary. Remove leading "# ". 41# - Path of fontconfig/fonts.conf can be overridden by setting an env 42# variable FONTS_CONF_DENY_VF. 43# 44# * Template: 45# ----------------------------------------------------------------- 46# <?xml version="1.0"?> 47# <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd"> 48# <fontconfig> 49# <!-- 50# Ignore variable-font glob (not to break xetex) 51# --> 52# <selectfont> 53# <rejectfont> 54# <!-- 55# for Fedora 56# --> 57# <glob>/usr/share/fonts/google-noto-*-cjk-vf-fonts</glob> 58# <!-- 59# for openSUSE tumbleweed 60# --> 61# <glob>/usr/share/fonts/truetype/Noto*CJK*-VF.otf</glob> 62# </rejectfont> 63# </selectfont> 64# </fontconfig> 65# ----------------------------------------------------------------- 66# 67# The denylisting is activated for "make pdfdocs". 68# 69# * For skipping CJK pages in PDF 70# - Uninstall texlive-xecjk. 71# Denylisting is not needed in this case. 72# 73# * For printing CJK pages in PDF 74# - Need non-variable "Noto CJK" fonts. 75# * Fedora 76# - google-noto-sans-cjk-fonts 77# - google-noto-serif-cjk-fonts 78# * openSUSE tumbleweed 79# - Non-variable "Noto CJK" fonts are not available as distro packages 80# as of April, 2024. Fetch a set of font files from upstream Noto 81# CJK Font released at: 82# https://github.com/notofonts/noto-cjk/tree/main/Sans#super-otc 83# and at: 84# https://github.com/notofonts/noto-cjk/tree/main/Serif#super-otc 85# , then uncompress and deploy them. 86# - Remember to update fontconfig cache by running fc-cache. 87# 88# !!! Caution !!! 89# Uninstalling "variable font" packages can be dangerous. 90# They might be depended upon by other packages important for your work. 91# Denylisting should be less invasive, as it is effective only while 92# XeLaTeX runs in "make pdfdocs". 93 94# Default per-user fontconfig path (overridden by env variable) 95: ${FONTS_CONF_DENY_VF:=$HOME/deny-vf} 96 97export XDG_CONFIG_HOME=${FONTS_CONF_DENY_VF} 98 99vffonts=`fc-list -b | grep -iE 'file: .*noto.*cjk.*-vf' | \ 100 sed -e 's/\tfile:/ file:/' -e 's/(s)$//' | sort | uniq` 101 102if [ "x$vffonts" != "x" ] ; then 103 echo '=============================================================================' 104 echo 'XeTeX is confused by "variable font" files listed below:' 105 echo "$vffonts" 106 echo 107 echo 'For CJK pages in PDF, they need to be hidden from XeTeX by denylisting.' 108 echo 'Or, CJK pages can be skipped by uninstalling texlive-xecjk.' 109 echo 110 echo 'For more info on denylisting, other options, and variable font, see header' 111 echo 'comments of scripts/check-variable-fonts.sh.' 112 echo '=============================================================================' 113fi 114 115# As this script is invoked from Makefile's error path, always error exit 116# regardless of whether any variable font is discovered or not. 117exit 1 118