| 1 |
# Copyright 1999-2007 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.27 2007/08/16 00:54:11 dirtyepic Exp $
|
| 4 |
|
| 5 |
# Author: foser <foser@gentoo.org>
|
| 6 |
|
| 7 |
# Font Eclass
|
| 8 |
#
|
| 9 |
# Eclass to make font installation uniform
|
| 10 |
|
| 11 |
inherit eutils
|
| 12 |
|
| 13 |
#
|
| 14 |
# Variable declarations
|
| 15 |
#
|
| 16 |
|
| 17 |
FONT_SUFFIX="" # Space delimited list of font suffixes to install
|
| 18 |
|
| 19 |
FONT_S="${S}" # Dir containing the fonts
|
| 20 |
|
| 21 |
FONT_PN="${PN}" # Last part of $FONTDIR
|
| 22 |
|
| 23 |
FONTDIR="/usr/share/fonts/${FONT_PN}" # This is where the fonts are installed
|
| 24 |
|
| 25 |
FONT_CONF="" # Space delimited list of fontconfig-2.4 file(s) to install
|
| 26 |
|
| 27 |
DOCS="" # Docs to install
|
| 28 |
|
| 29 |
IUSE="X"
|
| 30 |
|
| 31 |
DEPEND="X? ( x11-apps/mkfontdir )
|
| 32 |
media-libs/fontconfig"
|
| 33 |
|
| 34 |
#
|
| 35 |
# Public functions
|
| 36 |
#
|
| 37 |
|
| 38 |
font_xfont_config() {
|
| 39 |
# create Xfont files
|
| 40 |
if use X ; then
|
| 41 |
einfo "Creating fonts.scale & fonts.dir ..."
|
| 42 |
mkfontscale "${D}${FONTDIR}"
|
| 43 |
mkfontdir \
|
| 44 |
-e /usr/share/fonts/encodings \
|
| 45 |
-e /usr/share/fonts/encodings/large \
|
| 46 |
"${D}${FONTDIR}"
|
| 47 |
if [ -e "${FONT_S}/fonts.alias" ] ; then
|
| 48 |
doins "${FONT_S}/fonts.alias"
|
| 49 |
fi
|
| 50 |
fi
|
| 51 |
}
|
| 52 |
|
| 53 |
font_xft_config() {
|
| 54 |
if ! has_version '>=media-libs/fontconfig-2.4'; then
|
| 55 |
# create fontconfig cache
|
| 56 |
einfo "Creating fontconfig cache ..."
|
| 57 |
# Mac OS X has fc-cache at /usr/X11R6/bin
|
| 58 |
HOME="/root" fc-cache -f "${D}${FONTDIR}"
|
| 59 |
fi
|
| 60 |
}
|
| 61 |
|
| 62 |
font_fontconfig() {
|
| 63 |
local conffile
|
| 64 |
if [[ -n ${FONT_CONF} ]]; then
|
| 65 |
if has_version '>=media-libs/fontconfig-2.4'; then
|
| 66 |
insinto /etc/fonts/conf.avail/
|
| 67 |
for conffile in "${FONT_CONF}"; do
|
| 68 |
[[ -e ${conffile} ]] && doins ${conffile}
|
| 69 |
done
|
| 70 |
fi
|
| 71 |
fi
|
| 72 |
}
|
| 73 |
|
| 74 |
#
|
| 75 |
# Public inheritable functions
|
| 76 |
#
|
| 77 |
|
| 78 |
font_src_install() {
|
| 79 |
local suffix commondoc
|
| 80 |
|
| 81 |
cd "${FONT_S}"
|
| 82 |
|
| 83 |
insinto "${FONTDIR}"
|
| 84 |
|
| 85 |
for suffix in ${FONT_SUFFIX}; do
|
| 86 |
doins *.${suffix}
|
| 87 |
# ensure fonts are world readable to prevent fontconfig segfaults
|
| 88 |
chmod -v 0644 ${D}${FONTDIR}/*.${suffix}
|
| 89 |
done
|
| 90 |
|
| 91 |
rm -f fonts.{dir,scale} encodings.dir
|
| 92 |
|
| 93 |
font_xfont_config
|
| 94 |
font_xft_config
|
| 95 |
font_fontconfig
|
| 96 |
|
| 97 |
cd "${S}"
|
| 98 |
dodoc ${DOCS} 2> /dev/null
|
| 99 |
|
| 100 |
# install common docs
|
| 101 |
for commondoc in COPYRIGHT README NEWS AUTHORS BUGS ChangeLog; do
|
| 102 |
[[ -s ${commondoc} ]] && dodoc ${commondoc}
|
| 103 |
done
|
| 104 |
}
|
| 105 |
|
| 106 |
font_pkg_setup() {
|
| 107 |
# make sure we get no collisions
|
| 108 |
# setup is not the nicest place, but preinst doesn't cut it
|
| 109 |
[[ -e "${FONTDIR}/fonts.cache-1" ]] && rm -f "${FONTDIR}/fonts.cache-1"
|
| 110 |
}
|
| 111 |
|
| 112 |
font_pkg_postinst() {
|
| 113 |
if has_version '>=media-libs/fontconfig-2.4'; then
|
| 114 |
if [ ${ROOT} == "/" ]; then
|
| 115 |
ebegin "Updating global fontcache"
|
| 116 |
fc-cache -fs
|
| 117 |
eend $?
|
| 118 |
fi
|
| 119 |
fi
|
| 120 |
}
|
| 121 |
|
| 122 |
font_pkg_postrm() {
|
| 123 |
if has_version '>=media-libs/fontconfig-2.4'; then
|
| 124 |
if [ ${ROOT} == "/" ]; then
|
| 125 |
ebegin "Updating global fontcache"
|
| 126 |
fc-cache -fs
|
| 127 |
eend $?
|
| 128 |
fi
|
| 129 |
fi
|
| 130 |
}
|
| 131 |
|
| 132 |
EXPORT_FUNCTIONS src_install pkg_setup pkg_postinst pkg_postrm
|