| 1 |
dirtyepic |
1.26 |
# Copyright 1999-2007 Gentoo Foundation |
| 2 |
foser |
1.1 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
dirtyepic |
1.32 |
# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.31 2007/09/16 07:07:52 dirtyepic Exp $ |
| 4 |
foser |
1.1 |
|
| 5 |
|
|
# Author: foser <foser@gentoo.org> |
| 6 |
|
|
|
| 7 |
|
|
# Font Eclass |
| 8 |
|
|
# |
| 9 |
foser |
1.19 |
# Eclass to make font installation uniform |
| 10 |
foser |
1.1 |
|
| 11 |
kugelfang |
1.7 |
inherit eutils |
| 12 |
|
|
|
| 13 |
foser |
1.1 |
# |
| 14 |
|
|
# Variable declarations |
| 15 |
|
|
# |
| 16 |
|
|
|
| 17 |
|
|
FONT_SUFFIX="" # Space delimited list of font suffixes to install |
| 18 |
|
|
|
| 19 |
foser |
1.2 |
FONT_S="${S}" # Dir containing the fonts |
| 20 |
|
|
|
| 21 |
robbat2 |
1.18 |
FONT_PN="${PN}" # Last part of $FONTDIR |
| 22 |
|
|
|
| 23 |
dirtyepic |
1.24 |
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 |
robbat2 |
1.18 |
|
| 27 |
foser |
1.1 |
DOCS="" # Docs to install |
| 28 |
|
|
|
| 29 |
swegener |
1.15 |
IUSE="X" |
| 30 |
foser |
1.1 |
|
| 31 |
genstef |
1.22 |
DEPEND="X? ( x11-apps/mkfontdir ) |
| 32 |
robbat2 |
1.18 |
media-libs/fontconfig" |
| 33 |
foser |
1.1 |
|
| 34 |
swegener |
1.15 |
# |
| 35 |
foser |
1.2 |
# Public functions |
| 36 |
foser |
1.1 |
# |
| 37 |
|
|
|
| 38 |
foser |
1.2 |
font_xfont_config() { |
| 39 |
foser |
1.1 |
# create Xfont files |
| 40 |
foser |
1.11 |
if use X ; then |
| 41 |
vapier |
1.10 |
einfo "Creating fonts.scale & fonts.dir ..." |
| 42 |
robbat2 |
1.18 |
mkfontscale "${D}${FONTDIR}" |
| 43 |
foser |
1.1 |
mkfontdir \ |
| 44 |
|
|
-e /usr/share/fonts/encodings \ |
| 45 |
|
|
-e /usr/share/fonts/encodings/large \ |
| 46 |
robbat2 |
1.18 |
"${D}${FONTDIR}" |
| 47 |
foser |
1.11 |
if [ -e "${FONT_S}/fonts.alias" ] ; then |
| 48 |
usata |
1.8 |
doins "${FONT_S}/fonts.alias" |
| 49 |
usata |
1.3 |
fi |
| 50 |
foser |
1.1 |
fi |
| 51 |
foser |
1.2 |
} |
| 52 |
|
|
|
| 53 |
|
|
font_xft_config() { |
| 54 |
foser |
1.19 |
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 |
foser |
1.2 |
} |
| 61 |
|
|
|
| 62 |
dirtyepic |
1.24 |
font_fontconfig() { |
| 63 |
|
|
local conffile |
| 64 |
dirtyepic |
1.25 |
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 |
dirtyepic |
1.24 |
fi |
| 72 |
|
|
} |
| 73 |
|
|
|
| 74 |
foser |
1.2 |
# |
| 75 |
|
|
# Public inheritable functions |
| 76 |
|
|
# |
| 77 |
|
|
|
| 78 |
|
|
font_src_install() { |
| 79 |
dirtyepic |
1.23 |
local suffix commondoc |
| 80 |
foser |
1.2 |
|
| 81 |
usata |
1.8 |
cd "${FONT_S}" |
| 82 |
foser |
1.2 |
|
| 83 |
robbat2 |
1.18 |
insinto "${FONTDIR}" |
| 84 |
swegener |
1.15 |
|
| 85 |
foser |
1.2 |
for suffix in ${FONT_SUFFIX}; do |
| 86 |
dirtyepic |
1.28 |
doins *.${suffix} |
| 87 |
foser |
1.2 |
done |
| 88 |
|
|
|
| 89 |
|
|
rm -f fonts.{dir,scale} encodings.dir |
| 90 |
|
|
|
| 91 |
|
|
font_xfont_config |
| 92 |
|
|
font_xft_config |
| 93 |
dirtyepic |
1.24 |
font_fontconfig |
| 94 |
foser |
1.2 |
|
| 95 |
usata |
1.8 |
cd "${S}" |
| 96 |
dberkholz |
1.20 |
dodoc ${DOCS} 2> /dev/null |
| 97 |
foser |
1.11 |
|
| 98 |
dirtyepic |
1.23 |
# install common docs |
| 99 |
|
|
for commondoc in COPYRIGHT README NEWS AUTHORS BUGS ChangeLog; do |
| 100 |
dirtyepic |
1.24 |
[[ -s ${commondoc} ]] && dodoc ${commondoc} |
| 101 |
dirtyepic |
1.23 |
done |
| 102 |
foser |
1.1 |
} |
| 103 |
|
|
|
| 104 |
foser |
1.12 |
font_pkg_setup() { |
| 105 |
dirtyepic |
1.24 |
# make sure we get no collisions |
| 106 |
foser |
1.12 |
# setup is not the nicest place, but preinst doesn't cut it |
| 107 |
dberkholz |
1.20 |
[[ -e "${FONTDIR}/fonts.cache-1" ]] && rm -f "${FONTDIR}/fonts.cache-1" |
| 108 |
foser |
1.19 |
} |
| 109 |
|
|
|
| 110 |
|
|
font_pkg_postinst() { |
| 111 |
dirtyepic |
1.31 |
# unreadable font files = fontconfig segfaults |
| 112 |
dirtyepic |
1.32 |
find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ |
| 113 |
|
|
| xargs -r -0 chmod -v 0644 |
| 114 |
dirtyepic |
1.30 |
|
| 115 |
foser |
1.19 |
if has_version '>=media-libs/fontconfig-2.4'; then |
| 116 |
|
|
if [ ${ROOT} == "/" ]; then |
| 117 |
|
|
ebegin "Updating global fontcache" |
| 118 |
dirtyepic |
1.26 |
fc-cache -fs |
| 119 |
foser |
1.19 |
eend $? |
| 120 |
|
|
fi |
| 121 |
|
|
fi |
| 122 |
|
|
} |
| 123 |
|
|
|
| 124 |
|
|
font_pkg_postrm() { |
| 125 |
dirtyepic |
1.31 |
# unreadable font files = fontconfig segfaults |
| 126 |
dirtyepic |
1.32 |
find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ |
| 127 |
|
|
| xargs -r -0 chmod -v 0644 |
| 128 |
dirtyepic |
1.30 |
|
| 129 |
foser |
1.19 |
if has_version '>=media-libs/fontconfig-2.4'; then |
| 130 |
|
|
if [ ${ROOT} == "/" ]; then |
| 131 |
|
|
ebegin "Updating global fontcache" |
| 132 |
dirtyepic |
1.26 |
fc-cache -fs |
| 133 |
foser |
1.19 |
eend $? |
| 134 |
|
|
fi |
| 135 |
|
|
fi |
| 136 |
foser |
1.12 |
} |
| 137 |
|
|
|
| 138 |
foser |
1.19 |
EXPORT_FUNCTIONS src_install pkg_setup pkg_postinst pkg_postrm |