From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-dev+bounces-98325-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A56A1158020 for <garchives@archives.gentoo.org>; Sat, 15 Oct 2022 03:10:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C88EBE086E; Sat, 15 Oct 2022 03:10:26 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 859C1E0864 for <gentoo-dev@lists.gentoo.org>; Sat, 15 Oct 2022 03:10:26 +0000 (UTC) From: Sam James <sam@gentoo.org> To: gentoo-dev@lists.gentoo.org Cc: x11@gentoo.org, fonts@gentoo.org, gnome@gentoo.org, Kerin Millar <kfm@plushkava.net>, Sam James <sam@gentoo.org> Subject: [gentoo-dev] [PATCH 1/5] font.eclass: introduce FONT_CONVERT_SFNT for converting old bitmap fonts Date: Sat, 15 Oct 2022 04:09:54 +0100 Message-Id: <20221015030958.2422501-1-sam@gentoo.org> X-Mailer: git-send-email 2.38.0 Precedence: bulk List-Post: <mailto:gentoo-dev@lists.gentoo.org> List-Help: <mailto:gentoo-dev+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-dev+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-dev+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-dev.gentoo.org> X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: fb583367-51a5-4c96-a389-e23419a80325 X-Archives-Hash: 0d35c83fae6fdbee880fb203535ee705 >=x11-libs/pango-1.44 dropped support for old bitmap fonts. We can convert fonts from the legacy .bdf and .pcf formats into the OTB wrapper format using x11-apps/fonttosfnt. This commit adds FONT_CONVERT_SFNT which packages installing bitmap fonts can set to opt-in to conversion. Note that the font conversion isn't perfect -- it's good enough in many cases, but in some cases they may require tweaking via fontconfig to get pixel size right, antialiasing settings, ... Adds IUSE=+convert-sfnt to any ebuilds which set FONT_CONVERT_SFNT; enabled by default given discoverability of this issue may be difficult and presumably any font package enabling FONT_CONVERT_SFNT will be useless without it anyway. See also https://fedoraproject.org/wiki/BitmapFontConversion. Bug: https://bugs.gentoo.org/698922 Thanks-to: Kerin Millar <kfm@plushkava.net> Signed-off-by: Sam James <sam@gentoo.org> --- eclass/font.eclass | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/eclass/font.eclass b/eclass/font.eclass index 83636ac3fed5..4b7021ee0599 100644 --- a/eclass/font.eclass +++ b/eclass/font.eclass @@ -46,6 +46,12 @@ FONTDIR=${FONTDIR:-/usr/share/fonts/${FONT_PN}} # Array containing fontconfig conf files to install. FONT_CONF=( "" ) +# @ECLASS_VARIABLE: FONT_CONVERT_SFNT +# @DEFAULT_UNSET +# @DESCRIPTION: +# Determines whether detected BDF and PCF font files should be converted +# to an SFNT wrapper, for use with newer Pango. + if [[ ${CATEGORY}/${PN} != media-fonts/encodings ]]; then IUSE="X" BDEPEND="X? ( @@ -54,6 +60,31 @@ if [[ ${CATEGORY}/${PN} != media-fonts/encodings ]]; then )" fi +if [[ -n ${FONT_CONVERT_SFNT} ]] ; then + IUSE+=" +convert-sfnt" + BDEPEND+=" convert-sfnt? ( x11-apps/fonttosfnt )" +fi + +# @FUNCTION: font_convert_sfnt +# @DESCRIPTION: +# Converts .bdf and .pcf fonts detected within ${ED} to the OTB wrapper format +# using x11-apps/fonttosfnt. Handles optional .gz extension. +font_convert_sfnt() { + local file tmpfile + + while IFS= read -rd '' file; do + if [[ ${file} != *.gz ]] ; then + tmpfile=${file%.*} + + gzip -cd -- "${file}" > "${tmpfile}" \ + && fonttosfnt -v -o "${file%.*}.otb" -- "${tmpfile}" \ + && rm -- "${tmpfile}" + else + fonttosfnt -v -o "${file%.*}.otb" -- "${file}" + fi || ! break + done < <(find "${ED}" \( -name '*.bdf' -o -name '*.bdf.gz' -o -name '*.pcf' -o -name '*.pcf.gz' \) -type f ! -type l -print0) || die +} + # @FUNCTION: font_xfont_config # @DESCRIPTION: # Generate Xorg font files (mkfontscale/mkfontdir). @@ -150,6 +181,10 @@ font_pkg_setup() { font_src_install() { local dir suffix commondoc + if [[ -n ${FONT_CONVERT_SFNT} ]] && in_iuse convert-sfnt && use convert-sfnt ; then + font_convert_sfnt + fi + if [[ $(declare -p FONT_S 2>/dev/null) == "declare -a"* ]]; then # recreate the directory structure if FONT_S is an array for dir in "${FONT_S[@]}"; do -- 2.38.0