/[gentoo-x86]/eclass/font.eclass
Gentoo

Diff of /eclass/font.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.24

  ViewVC Help
Powered by ViewVC 1.1.20