summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2022-10-15 03:36:04 +0100
committerSam James <sam@gentoo.org>2022-11-20 01:02:38 +0000
commita9eb1de2e795d8a8b2e99d64a3c9567744bb0f41 (patch)
treedbf4c1aeb6526bf07684fd2c6cb3800c785447dc
parentsci-mathematics/gmp-ecm: drop 7.0.4-r4 (diff)
downloadgentoo-a9eb1de2e795d8a8b2e99d64a3c9567744bb0f41.tar.gz
gentoo-a9eb1de2e795d8a8b2e99d64a3c9567744bb0f41.tar.bz2
gentoo-a9eb1de2e795d8a8b2e99d64a3c9567744bb0f41.zip
font.eclass: introduce FONT_OPENTYPE_COMPAT for converting old bitmap fonts
>=x11-libs/pango-1.44 dropped support for old bitmap fonts. We can convert (or really, wrap/embed) fonts from the legacy .bdf and .pcf formats into the OTB wrapper format using x11-apps/fonttosfnt. This commit adds FONT_OPENTYPE_COMPAT to font.eclass which packages installing bitmap fonts can set to opt-in to conversion/wrapping. 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=+opentype-compat to any ebuilds which set FONT_OPENTYPE_COMPAT; enabled by default given discoverability of this issue may be difficult and presumably any font package enabling FONT_OPENTYPE_COMPAT 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>
-rw-r--r--eclass/font.eclass35
1 files changed, 35 insertions, 0 deletions
diff --git a/eclass/font.eclass b/eclass/font.eclass
index 0196755ce3e1..e772409fe201 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_OPENTYPE_COMPAT
+# @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_OPENTYPE_COMPAT} ]] ; then
+ IUSE+=" +opentype-compat"
+ BDEPEND+=" opentype-compat? ( x11-apps/fonttosfnt )"
+fi
+
+# @FUNCTION: font_wrap_opentype_compat
+# @DESCRIPTION:
+# Converts .bdf and .pcf fonts detected within ${ED} to the OTB wrapper format
+# using x11-apps/fonttosfnt. Handles optional .gz extension.
+font_wrap_opentype_compat() {
+ 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_OPENTYPE_COMPAT} ]] && in_iuse opentype-compat && use opentype-compat ; then
+ font_wrap_opentype_compat
+ 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