/[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.45
1# Copyright 1999-2004 Gentoo Technologies, Inc. 1# Copyright 1999-2007 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.45 2009/09/07 21:07:11 dirtyepic Exp $
4 4
5# @ECLASS: font.eclass
6# @MAINTAINER:
7# fonts@gentoo.org
8#
5# Author: foser <foser@gentoo.org> 9# Author: foser <foser@gentoo.org>
10# @BLURB: Eclass to make font installation uniform
6 11
7# Font Eclass 12inherit eutils
8#
9# Eclass to make font installation more uniform
10 13
11ECLASS="font" 14
12INHERITED="$INHERITED $ECLASS" 15EXPORT_FUNCTIONS pkg_setup src_install pkg_postinst pkg_postrm
13 16
14# 17#
15# Variable declarations 18# Variable declarations
16# 19#
17 20
21# @ECLASS-VARIABLE: FONT_SUFFIX
22# @DESCRIPTION:
18FONT_SUFFIX="" # Space delimited list of font suffixes to install 23# Space delimited list of font suffixes to install
24FONT_SUFFIX=""
19 25
26# @ECLASS-VARIABLE: FONT_S
27# @DESCRIPTION:
20FONT_S="${S}" # Dir containing the fonts 28# Dir containing the fonts
29FONT_S=${S}
21 30
22DOCS="" # Docs to install 31# @ECLASS-VARIABLE: FONT_PN
32# @DESCRIPTION:
33# Last part of $FONTDIR
34FONT_PN=${PN}
23 35
24IUSE="${IUSE} X" 36# @ECLASS-VARIABLE: FONTDIR
37# @DESCRIPTION:
38# This is where the fonts are installed
39FONTDIR=/usr/share/fonts/${FONT_PN}
25 40
26DEPEND="${DEPEND} \ 41# @ECLASS-VARIABLE: FONT_CONF
27 X? ( virtual/x11 ) \ 42# @DESCRIPTION:
43# Array, which element(s) is(are) path(s) of fontconfig-2.4 file(s) to install
44FONT_CONF=( "" )
45
46# @ECLASS-VARIABLE: DOCS
47# @DESCRIPTION:
48# Docs to install
49DOCS=""
50
51IUSE="X"
52
53DEPEND="X? ( x11-apps/mkfontdir
54 media-fonts/encodings )
28 media-libs/fontconfig" 55 media-libs/fontconfig"
29 56
30# 57#
31# Public functions 58# Public functions
32# 59#
33 60
61# @FUNCTION: font_xfont_config
62# @DESCRIPTION:
63# Creates the Xfont files.
34font_xfont_config() { 64font_xfont_config() {
35
36 # create Xfont files 65 # create Xfont files
37 if [ -n "`use X`" ] ; 66 if use X ; then
38 then
39 einfo "Creating fonts.scale & fonts.dir..." 67 einfo "Creating fonts.scale & fonts.dir ..."
40 mkfontscale ${D}/usr/share/fonts/${PN} 68 rm -f "${D}${FONTDIR}"/fonts.{dir,scale}
69 mkfontscale "${D}${FONTDIR}"
41 mkfontdir \ 70 mkfontdir \
42 -e /usr/share/fonts/encodings \ 71 -e /usr/share/fonts/encodings \
43 -e /usr/share/fonts/encodings/large \ 72 -e /usr/share/fonts/encodings/large \
44 -e /usr/X11R6/lib/X11/fonts/encodings \ 73 "${D}${FONTDIR}"
45 ${D}/usr/share/fonts/${PN} 74 if [ -e "${FONT_S}/fonts.alias" ] ; then
46 doins ${FONT_S}/fonts.alias 75 doins "${FONT_S}/fonts.alias"
76 fi
47 fi 77 fi
48
49} 78}
50 79
80# @FUNCTION: font_xft_config
81# @DESCRIPTION:
82# Creates the fontconfig cache if necessary.
51font_xft_config() { 83font_xft_config() {
84 if ! has_version '>=media-libs/fontconfig-2.4'; then
85 # create fontconfig cache
86 einfo "Creating fontconfig cache ..."
87 fc-cache -sf "${D}${FONTDIR}"
88 fi
89}
52 90
53 # create fontconfig cache 91# @FUNCTION: font_fontconfig
54 einfo "Creating fontconfig cache..." 92# @DESCRIPTION:
55 HOME="/root" /usr/bin/fc-cache -f ${D}/usr/share/fonts/${PN} 93# Installs the fontconfig config files of FONT_CONF.
56 94font_fontconfig() {
95 local conffile
96 if [[ -n ${FONT_CONF[@]} ]]; then
97 if has_version '>=media-libs/fontconfig-2.4'; then
98 insinto /etc/fonts/conf.avail/
99 for conffile in "${FONT_CONF[@]}"; do
100 [[ -e ${conffile} ]] && doins ${conffile}
101 done
102 fi
103 fi
57} 104}
58 105
59# 106#
60# Public inheritable functions 107# Public inheritable functions
61# 108#
62 109
110# @FUNCTION: font_src_install
111# @DESCRIPTION:
112# The font src_install function, which is exported.
63font_src_install() { 113font_src_install() {
114 local suffix commondoc
64 115
65 local suffix doc 116 cd "${FONT_S}"
66 117
67 cd ${FONT_S} 118 insinto "${FONTDIR}"
68 119
69 insinto /usr/share/fonts/${PN}
70
71 for suffix in ${FONT_SUFFIX}; do 120 for suffix in ${FONT_SUFFIX}; do
72 doins *.${suffix} 121 doins *.${suffix}
73 done 122 done
74 123
75 rm -f fonts.{dir,scale} encodings.dir 124 rm -f fonts.{dir,scale} encodings.dir
76 125
77 font_xfont_config 126 font_xfont_config
78 font_xft_config 127 font_xft_config
128 font_fontconfig
79 129
80 cd ${S} 130 cd "${S}"
131 dodoc ${DOCS} 2> /dev/null
132
81 # try to install some common docs 133 # install common docs
82 DOCS="${DOCS} COPYRIGHT README NEWS" 134 for commondoc in COPYRIGHT README{,.txt} NEWS AUTHORS BUGS ChangeLog FONTLOG.txt; do
83 for doc in ${DOCS}; do 135 [[ -s ${commondoc} ]] && dodoc ${commondoc}
84 dodoc ${doc}
85 done 136 done
86
87} 137}
88 138
89EXPORT_FUNCTIONS src_install 139# @FUNCTION: font_pkg_setup
140# @DESCRIPTION:
141# The font pkg_setup function, which is exported.
142font_pkg_setup() {
143 # make sure we get no collisions
144 # setup is not the nicest place, but preinst doesn't cut it
145 [[ -e "${FONTDIR}/fonts.cache-1" ]] && rm -f "${FONTDIR}/fonts.cache-1"
146}
147
148# @FUNCTION: font_pkg_postinst
149# @DESCRIPTION:
150# The font pkg_postinst function, which is exported.
151font_pkg_postinst() {
152 # unreadable font files = fontconfig segfaults
153 find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \
154 | xargs -0 chmod -v 0644 2>/dev/null
155
156 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 if has_version '>=media-libs/fontconfig-2.4'; then
174 if [[ ${ROOT} == "/" ]]; then
175 ebegin "Updating global fontcache"
176 fc-cache -fs
177 eend $?
178 fi
179 fi
180}
181
182# @FUNCTION: font_pkg_postrm
183# @DESCRIPTION:
184# The font pkg_postrm function, which is exported.
185font_pkg_postrm() {
186 # unreadable font files = fontconfig segfaults
187 find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \
188 | xargs -0 chmod -v 0644 2>/dev/null
189
190 if has_version '>=media-libs/fontconfig-2.4'; then
191 if [[ ${ROOT} == "/" ]]; then
192 ebegin "Updating global fontcache"
193 fc-cache -fs
194 eend $?
195 fi
196 fi
197}
198

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

  ViewVC Help
Powered by ViewVC 1.1.20