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

Contents of /eclass/font.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.44 - (hide annotations) (download)
Sun Feb 8 18:22:39 2009 UTC (5 years, 6 months ago) by pva
Branch: MAIN
Changes since 1.43: +3 -3 lines
Fixed unquoted variables, bug #258164, thank Markus Meier for report.

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

  ViewVC Help
Powered by ViewVC 1.1.20