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

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

  ViewVC Help
Powered by ViewVC 1.1.20