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

Diff of /eclass/font.eclass

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

Revision 1.23 Revision 1.48
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2010 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.23 2007/06/24 06:15:21 dirtyepic Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.48 2010/02/09 17:15:08 scarabeus Exp $
4 4
5# @ECLASS: font.eclass
6# @MAINTAINER:
7# fonts@gentoo.org
8
9# Author: Tomáš Chvátal <scarabeus@gentoo.org>
5# Author: foser <foser@gentoo.org> 10# Author: foser <foser@gentoo.org>
6
7# Font Eclass
8#
9# Eclass to make font installation uniform 11# @BLURB: Eclass to make font installation uniform
10 12
11inherit eutils 13inherit eutils
12 14
13# 15EXPORT_FUNCTIONS pkg_setup src_install pkg_postinst pkg_postrm
14# Variable declarations
15#
16 16
17# @ECLASS-VARIABLE: FONT_SUFFIX
18# @DESCRIPTION:
17FONT_SUFFIX="" # Space delimited list of font suffixes to install 19# Space delimited list of font suffixes to install
20FONT_SUFFIX=${FONT_SUFFIX:=}
18 21
22# @ECLASS-VARIABLE: FONT_S
23# @DESCRIPTION:
19FONT_S="${S}" # Dir containing the fonts 24# Dir containing the fonts
25FONT_S=${FONT_S:=${S}}
20 26
21FONT_PN="${PN}" # Last part of $FONTDIR 27# @ECLASS-VARIABLE: FONT_PN
28# @DESCRIPTION:
29# Last part of $FONTDIR
30FONT_PN=${FONT_PN:=${PN}}
22 31
23FONTDIR="/usr/share/fonts/${FONT_PN}" # this is where the fonts are installed 32# @ECLASS-VARIABLE: FONTDIR
33# @DESCRIPTION:
34# This is where the fonts are installed
35FONTDIR=${FONTDIR:-/usr/share/fonts/${FONT_PN}}
24 36
37# @ECLASS-VARIABLE: FONT_CONF
38# @DESCRIPTION:
39# Array, which element(s) is(are) path(s) of fontconfig-2.4 file(s) to install
40FONT_CONF=( "" )
41
42# @ECLASS-VARIABLE: DOCS
43# @DESCRIPTION:
25DOCS="" # Docs to install 44# Docs to install
45DOCS=${DOCS:-}
26 46
27IUSE="X" 47IUSE="X"
28 48
29DEPEND="X? ( x11-apps/mkfontdir ) 49DEPEND="X? (
50 x11-apps/mkfontdir
51 media-fonts/encodings
52 )
30 media-libs/fontconfig" 53 >=media-libs/fontconfig-2.4.0"
31 54
32# 55# @FUNCTION: font_xfont_config
33# Public functions 56# @DESCRIPTION:
34# 57# Creates the Xfont files.
35
36font_xfont_config() { 58font_xfont_config() {
37
38 # create Xfont files 59 # create Xfont files
39 if use X ; then 60 if has X ${IUSE//+} && use X ; then
40 einfo "Creating fonts.scale & fonts.dir ..." 61 ebegin "Creating fonts.scale & fonts.dir"
62 rm -f "${ED}${FONTDIR}"/fonts.{dir,scale}
41 mkfontscale "${D}${FONTDIR}" 63 mkfontscale "${ED}${FONTDIR}"
42 mkfontdir \ 64 mkfontdir \
43 -e /usr/share/fonts/encodings \ 65 -e ${EPREFIX}/usr/share/fonts/encodings \
44 -e /usr/share/fonts/encodings/large \ 66 -e ${EPREFIX}/usr/share/fonts/encodings/large \
45 "${D}${FONTDIR}" 67 "${ED}${FONTDIR}"
68 eend $?
46 if [ -e "${FONT_S}/fonts.alias" ] ; then 69 if [ -e "${FONT_S}/fonts.alias" ] ; then
47 doins "${FONT_S}/fonts.alias" 70 doins "${FONT_S}/fonts.alias"
48 fi 71 fi
49 fi 72 fi
50
51} 73}
52 74
75# @FUNCTION: font_fontconfig
76# @DESCRIPTION:
77# Installs the fontconfig config files of FONT_CONF.
53font_xft_config() { 78font_fontconfig() {
54 79 local conffile
55 if ! has_version '>=media-libs/fontconfig-2.4'; then 80 if [[ -n ${FONT_CONF[@]} ]]; then
56 # create fontconfig cache 81 insinto /etc/fonts/conf.avail/
57 einfo "Creating fontconfig cache ..." 82 for conffile in "${FONT_CONF[@]}"; do
58 # Mac OS X has fc-cache at /usr/X11R6/bin 83 [[ -e ${conffile} ]] && doins ${conffile}
59 HOME="/root" fc-cache -f "${D}${FONTDIR}" 84 done
60 fi 85 fi
61} 86}
62 87
63# 88# @FUNCTION: font_src_install
64# Public inheritable functions 89# @DESCRIPTION:
65# 90# The font src_install function.
66
67font_src_install() { 91font_src_install() {
68
69 local suffix commondoc 92 local suffix commondoc
70 93
71 cd "${FONT_S}" 94 pushd "${FONT_S}" > /dev/null
72 95
73 insinto "${FONTDIR}" 96 insinto "${FONTDIR}"
74 97
75 for suffix in ${FONT_SUFFIX}; do 98 for suffix in ${FONT_SUFFIX}; do
76 doins *.${suffix} 99 doins *.${suffix}
77 done 100 done
78 101
79 rm -f fonts.{dir,scale} encodings.dir 102 rm -f fonts.{dir,scale} encodings.dir
80 103
81 font_xfont_config 104 font_xfont_config
82 font_xft_config 105 font_fontconfig
83 106
84 cd "${S}" 107 popd > /dev/null
85 dodoc ${DOCS} 2> /dev/null 108
109 [[ -n ${DOCS} ]] && { dodoc ${DOCS} || die "docs installation failed" ; }
86 110
87 # install common docs 111 # install common docs
88 for commondoc in COPYRIGHT README NEWS AUTHORS BUGS ChangeLog; do 112 for commondoc in COPYRIGHT README{,.txt} NEWS AUTHORS BUGS ChangeLog FONTLOG.txt; do
89 [ -s ${commondoc} ] && dodoc ${commondoc} 113 [[ -s ${commondoc} ]] && dodoc ${commondoc}
90 done 114 done
91} 115}
92 116
117# @FUNCTION: font_pkg_setup
118# @DESCRIPTION:
119# The font pkg_setup function.
120# Collision portection and Prefix compat for eapi < 3.
93font_pkg_setup() { 121font_pkg_setup() {
122 # Prefix compat
123 case ${EAPI:-0} in
124 0|1|2)
125 if ! use prefix; then
126 EPREFIX=
127 ED=${D}
128 EROOT=${ROOT}
129 [[ ${EROOT} = */ ]] || EROOT+="/"
130 fi
131 ;;
132 esac
94 133
95 # make sure we get no colissions 134 # make sure we get no collisions
96 # setup is not the nicest place, but preinst doesn't cut it 135 # setup is not the nicest place, but preinst doesn't cut it
97 [[ -e "${FONTDIR}/fonts.cache-1" ]] && rm -f "${FONTDIR}/fonts.cache-1" 136 [[ -e "${EROOT}/${FONTDIR}/fonts.cache-1" ]] && rm -f "${EROOT}/${FONTDIR}/fonts.cache-1"
98
99} 137}
100 138
139# @FUNCTION: font_pkg_postinst
140# @DESCRIPTION:
141# The font pkg_postinst function.
142# Update global font cache and fix permissions.
101font_pkg_postinst() { 143font_pkg_postinst() {
144 # unreadable font files = fontconfig segfaults
145 find "${EROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \
146 | xargs -0 chmod -v 0644 2>/dev/null
102 147
103 if has_version '>=media-libs/fontconfig-2.4'; then 148 if [[ -n ${FONT_CONF[@]} ]]; then
104 if [ ${ROOT} == "/" ]; then 149 local conffile
105 ebegin "Updating global fontcache" 150 echo
106 fc-cache -s 151 elog "The following fontconfig configuration files have been installed:"
107 eend $? 152 elog
153 for conffile in "${FONT_CONF[@]}"; do
154 if [[ -e ${EROOT}etc/fonts/conf.avail/$(basename ${conffile}) ]]; then
155 elog " $(basename ${conffile})"
108 fi 156 fi
157 done
158 elog
159 elog "Use \`eselect fontconfig\` to enable/disable them."
160 echo
109 fi 161 fi
110 162
163 if [[ ${ROOT} == / ]]; then
164 ebegin "Updating global fontcache"
165 fc-cache -fs
166 eend $?
167 fi
111} 168}
112 169
170# @FUNCTION: font_pkg_postrm
171# @DESCRIPTION:
172# The font pkg_postrm function.
173# Updates global font cache
113font_pkg_postrm() { 174font_pkg_postrm() {
175 # unreadable font files = fontconfig segfaults
176 find "${EROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \
177 | xargs -0 chmod -v 0644 2>/dev/null
114 178
115 if has_version '>=media-libs/fontconfig-2.4'; then
116 if [ ${ROOT} == "/" ]; then 179 if [[ ${ROOT} == / ]]; then
117 ebegin "Updating global fontcache" 180 ebegin "Updating global fontcache"
118 fc-cache -s 181 fc-cache -fs
119 eend $? 182 eend $?
120 fi
121 fi 183 fi
122
123} 184}
124
125EXPORT_FUNCTIONS src_install pkg_setup pkg_postinst pkg_postrm

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.48

  ViewVC Help
Powered by ViewVC 1.1.20