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