| 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.40 2009/01/01 09:36:36 pva Exp $
|
| 4 |
|
| 5 |
# @ECLASS: font.eclass
|
| 6 |
# @MAINTAINER:
|
| 7 |
# fonts@gentoo.org
|
| 8 |
#
|
| 9 |
# Author: foser <foser@gentoo.org>
|
| 10 |
# @BLURB: Eclass to make font installation uniform
|
| 11 |
|
| 12 |
inherit eutils
|
| 13 |
|
| 14 |
#
|
| 15 |
# Variable declarations
|
| 16 |
#
|
| 17 |
|
| 18 |
# @ECLASS-VARIABLE: FONT_SUFFIX
|
| 19 |
# @DESCRIPTION:
|
| 20 |
# Space delimited list of font suffixes to install
|
| 21 |
FONT_SUFFIX=""
|
| 22 |
|
| 23 |
# @ECLASS-VARIABLE: FONT_S
|
| 24 |
# @DESCRIPTION:
|
| 25 |
# Dir containing the fonts
|
| 26 |
FONT_S=${S}
|
| 27 |
|
| 28 |
# @ECLASS-VARIABLE: FONT_PN
|
| 29 |
# @DESCRIPTION:
|
| 30 |
# Last part of $FONTDIR
|
| 31 |
FONT_PN=${PN}
|
| 32 |
|
| 33 |
# @ECLASS-VARIABLE: FONTDIR
|
| 34 |
# @DESCRIPTION:
|
| 35 |
# This is where the fonts are installed
|
| 36 |
FONTDIR=/usr/share/fonts/${FONT_PN}
|
| 37 |
|
| 38 |
# @ECLASS-VARIABLE: FONT_CONF
|
| 39 |
# @DESCRIPTION:
|
| 40 |
# Array, which element(s) is(are) path(s) of fontconfig-2.4 file(s) to install
|
| 41 |
FONT_CONF=( "" )
|
| 42 |
|
| 43 |
# @ECLASS-VARIABLE: DOCS
|
| 44 |
# @DESCRIPTION:
|
| 45 |
# Docs to install
|
| 46 |
DOCS=""
|
| 47 |
|
| 48 |
IUSE="X"
|
| 49 |
|
| 50 |
DEPEND="X? ( x11-apps/mkfontdir
|
| 51 |
media-fonts/encodings )
|
| 52 |
media-libs/fontconfig"
|
| 53 |
|
| 54 |
#
|
| 55 |
# Public functions
|
| 56 |
#
|
| 57 |
|
| 58 |
# @FUNCTION: font_xfont_config
|
| 59 |
# @DESCRIPTION:
|
| 60 |
# Creates the Xfont files.
|
| 61 |
font_xfont_config() {
|
| 62 |
# create Xfont files
|
| 63 |
if use X ; then
|
| 64 |
einfo "Creating fonts.scale & fonts.dir ..."
|
| 65 |
rm -f "${D}${FONTDIR}"/fonts.{dir,scale}
|
| 66 |
mkfontscale "${D}${FONTDIR}"
|
| 67 |
mkfontdir \
|
| 68 |
-e /usr/share/fonts/encodings \
|
| 69 |
-e /usr/share/fonts/encodings/large \
|
| 70 |
"${D}${FONTDIR}"
|
| 71 |
if [ -e "${FONT_S}/fonts.alias" ] ; then
|
| 72 |
doins "${FONT_S}/fonts.alias"
|
| 73 |
fi
|
| 74 |
fi
|
| 75 |
}
|
| 76 |
|
| 77 |
# @FUNCTION: font_xft_config
|
| 78 |
# @DESCRIPTION:
|
| 79 |
# Creates the fontconfig cache if necessary.
|
| 80 |
font_xft_config() {
|
| 81 |
if ! has_version '>=media-libs/fontconfig-2.4'; then
|
| 82 |
# create fontconfig cache
|
| 83 |
einfo "Creating fontconfig cache ..."
|
| 84 |
# Mac OS X has fc-cache at /usr/X11R6/bin
|
| 85 |
fc-cache -sf "${D}${FONTDIR}"
|
| 86 |
fi
|
| 87 |
}
|
| 88 |
|
| 89 |
# @FUNCTION: font_fontconfig
|
| 90 |
# @DESCRIPTION:
|
| 91 |
# Installs the fontconfig config files of FONT_CONF.
|
| 92 |
font_fontconfig() {
|
| 93 |
local conffile
|
| 94 |
if [[ -n ${FONT_CONF[@]} ]]; then
|
| 95 |
if has_version '>=media-libs/fontconfig-2.4'; then
|
| 96 |
insinto /etc/fonts/conf.avail/
|
| 97 |
for conffile in "${FONT_CONF[@]}"; do
|
| 98 |
[[ -e ${conffile} ]] && doins ${conffile}
|
| 99 |
done
|
| 100 |
fi
|
| 101 |
fi
|
| 102 |
}
|
| 103 |
|
| 104 |
#
|
| 105 |
# Public inheritable functions
|
| 106 |
#
|
| 107 |
|
| 108 |
# @FUNCTION: font_src_install
|
| 109 |
# @DESCRIPTION:
|
| 110 |
# The font src_install function, which is exported.
|
| 111 |
font_src_install() {
|
| 112 |
local suffix commondoc
|
| 113 |
|
| 114 |
cd "${FONT_S}"
|
| 115 |
|
| 116 |
insinto "${FONTDIR}"
|
| 117 |
|
| 118 |
for suffix in ${FONT_SUFFIX}; do
|
| 119 |
doins *.${suffix}
|
| 120 |
done
|
| 121 |
|
| 122 |
rm -f fonts.{dir,scale} encodings.dir
|
| 123 |
|
| 124 |
font_xfont_config
|
| 125 |
font_xft_config
|
| 126 |
font_fontconfig
|
| 127 |
|
| 128 |
cd "${S}"
|
| 129 |
dodoc ${DOCS} 2> /dev/null
|
| 130 |
|
| 131 |
# install common docs
|
| 132 |
for commondoc in COPYRIGHT README{,.txt} NEWS AUTHORS BUGS ChangeLog FONTLOG.txt; do
|
| 133 |
[[ -s ${commondoc} ]] && dodoc ${commondoc}
|
| 134 |
done
|
| 135 |
}
|
| 136 |
|
| 137 |
# @FUNCTION: font_pkg_setup
|
| 138 |
# @DESCRIPTION:
|
| 139 |
# The font pkg_setup function, which is exported.
|
| 140 |
font_pkg_setup() {
|
| 141 |
# make sure we get no collisions
|
| 142 |
# setup is not the nicest place, but preinst doesn't cut it
|
| 143 |
[[ -e "${FONTDIR}/fonts.cache-1" ]] && rm -f "${FONTDIR}/fonts.cache-1"
|
| 144 |
}
|
| 145 |
|
| 146 |
# @FUNCTION: font_pkg_postinst
|
| 147 |
# @DESCRIPTION:
|
| 148 |
# The font pkg_postinst function, which is exported.
|
| 149 |
font_pkg_postinst() {
|
| 150 |
# unreadable font files = fontconfig segfaults
|
| 151 |
find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \
|
| 152 |
| xargs -0 chmod -v 0644 2>/dev/null
|
| 153 |
|
| 154 |
if has_version '>=media-libs/fontconfig-2.4'; then
|
| 155 |
if [ ${ROOT} == "/" ]; then
|
| 156 |
ebegin "Updating global fontcache"
|
| 157 |
fc-cache -fs
|
| 158 |
eend $?
|
| 159 |
fi
|
| 160 |
fi
|
| 161 |
}
|
| 162 |
|
| 163 |
# @FUNCTION: font_pkg_postrm
|
| 164 |
# @DESCRIPTION:
|
| 165 |
# The font pkg_postrm function, which is exported.
|
| 166 |
font_pkg_postrm() {
|
| 167 |
# unreadable font files = fontconfig segfaults
|
| 168 |
find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \
|
| 169 |
| xargs -0 chmod -v 0644 2>/dev/null
|
| 170 |
|
| 171 |
if has_version '>=media-libs/fontconfig-2.4'; then
|
| 172 |
if [ ${ROOT} == "/" ]; then
|
| 173 |
ebegin "Updating global fontcache"
|
| 174 |
fc-cache -fs
|
| 175 |
eend $?
|
| 176 |
fi
|
| 177 |
fi
|
| 178 |
}
|
| 179 |
|
| 180 |
EXPORT_FUNCTIONS src_install pkg_setup pkg_postinst pkg_postrm
|