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

Contents of /eclass/font.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.45 - (hide annotations) (download)
Mon Sep 7 21:07:11 2009 UTC (4 years, 11 months ago) by dirtyepic
Branch: MAIN
Changes since 1.44: +21 -2 lines
Tell the user if we've installed any config files and how to use them.

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

  ViewVC Help
Powered by ViewVC 1.1.20