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.31 |
# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.30 2007/09/16 06:21:05 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 |
|
|
badperms="$( find /usr/share/fonts/ -type f \! -perm 0644 -print )" |
113 |
|
|
if [[ -n ${badperms} ]]; then |
114 |
|
|
echo |
115 |
|
|
for fontfile in ${badperms}; do |
116 |
|
|
ewarn $( chmod -v 0644 ${fontfile} ) |
117 |
|
|
done |
118 |
|
|
echo |
119 |
|
|
fi |
120 |
dirtyepic |
1.30 |
|
121 |
foser |
1.19 |
if has_version '>=media-libs/fontconfig-2.4'; then |
122 |
|
|
if [ ${ROOT} == "/" ]; then |
123 |
|
|
ebegin "Updating global fontcache" |
124 |
dirtyepic |
1.26 |
fc-cache -fs |
125 |
foser |
1.19 |
eend $? |
126 |
|
|
fi |
127 |
|
|
fi |
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
font_pkg_postrm() { |
131 |
dirtyepic |
1.31 |
# unreadable font files = fontconfig segfaults |
132 |
|
|
badperms="$( find /usr/share/fonts/ -type f \! -perm 0644 -print )" |
133 |
|
|
if [[ -n ${badperms} ]]; then |
134 |
|
|
echo |
135 |
|
|
for fontfile in ${badperms}; do |
136 |
|
|
ewarn $( chmod -v 0644 ${fontfile} ) |
137 |
|
|
done |
138 |
|
|
echo |
139 |
|
|
fi |
140 |
dirtyepic |
1.30 |
|
141 |
foser |
1.19 |
if has_version '>=media-libs/fontconfig-2.4'; then |
142 |
|
|
if [ ${ROOT} == "/" ]; then |
143 |
|
|
ebegin "Updating global fontcache" |
144 |
dirtyepic |
1.26 |
fc-cache -fs |
145 |
foser |
1.19 |
eend $? |
146 |
|
|
fi |
147 |
|
|
fi |
148 |
foser |
1.12 |
} |
149 |
|
|
|
150 |
foser |
1.19 |
EXPORT_FUNCTIONS src_install pkg_setup pkg_postinst pkg_postrm |