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

Diff of /eclass/font.eclass

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

Revision 1.1.1.1 Revision 1.32
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.1.1.1 2005/11/30 09:59:23 chriswhite Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.32 2007/09/16 20:00:56 dirtyepic Exp $
4 4
5# Author: foser <foser@gentoo.org> 5# Author: foser <foser@gentoo.org>
6 6
7# Font Eclass 7# Font Eclass
8# 8#
9# Eclass to make font installation more uniform 9# Eclass to make font installation uniform
10 10
11inherit eutils 11inherit eutils
12
13 12
14# 13#
15# Variable declarations 14# Variable declarations
16# 15#
17 16
18FONT_SUFFIX="" # Space delimited list of font suffixes to install 17FONT_SUFFIX="" # Space delimited list of font suffixes to install
19 18
20FONT_S="${S}" # Dir containing the fonts 19FONT_S="${S}" # Dir containing the fonts
21 20
21FONT_PN="${PN}" # Last part of $FONTDIR
22
23FONTDIR="/usr/share/fonts/${FONT_PN}" # This is where the fonts are installed
24
25FONT_CONF="" # Space delimited list of fontconfig-2.4 file(s) to install
26
22DOCS="" # Docs to install 27DOCS="" # Docs to install
23 28
24IUSE="X" 29IUSE="X"
25 30
26DEPEND="X? ( virtual/x11 ) 31DEPEND="X? ( x11-apps/mkfontdir )
27 media-libs/fontconfig" 32 media-libs/fontconfig"
28 33
29# 34#
30# Public functions 35# Public functions
31# 36#
32 37
33font_xfont_config() { 38font_xfont_config() {
34
35 # create Xfont files 39 # create Xfont files
36 if use X ; then 40 if use X ; then
37 einfo "Creating fonts.scale & fonts.dir ..." 41 einfo "Creating fonts.scale & fonts.dir ..."
38 mkfontscale "${D}/usr/share/fonts/${PN}" 42 mkfontscale "${D}${FONTDIR}"
39 mkfontdir \ 43 mkfontdir \
40 -e /usr/share/fonts/encodings \ 44 -e /usr/share/fonts/encodings \
41 -e /usr/share/fonts/encodings/large \ 45 -e /usr/share/fonts/encodings/large \
42 "${D}/usr/share/fonts/${PN}" 46 "${D}${FONTDIR}"
43 if [ -e "${FONT_S}/fonts.alias" ] ; then 47 if [ -e "${FONT_S}/fonts.alias" ] ; then
44 doins "${FONT_S}/fonts.alias" 48 doins "${FONT_S}/fonts.alias"
45 fi 49 fi
46 fi 50 fi
47
48} 51}
49 52
50font_xft_config() { 53font_xft_config() {
54 if ! has_version '>=media-libs/fontconfig-2.4'; then
55 # create fontconfig cache
56 einfo "Creating fontconfig cache ..."
57 # Mac OS X has fc-cache at /usr/X11R6/bin
58 HOME="/root" fc-cache -f "${D}${FONTDIR}"
59 fi
60}
51 61
52 # create fontconfig cache 62font_fontconfig() {
53 einfo "Creating fontconfig cache ..." 63 local conffile
54 # Mac OS X has fc-cache at /usr/X11R6/bin 64 if [[ -n ${FONT_CONF} ]]; then
55 HOME="/root" fc-cache -f "${D}/usr/share/fonts/${PN}" 65 if has_version '>=media-libs/fontconfig-2.4'; then
56 66 insinto /etc/fonts/conf.avail/
67 for conffile in "${FONT_CONF}"; do
68 [[ -e ${conffile} ]] && doins ${conffile}
69 done
70 fi
71 fi
57} 72}
58 73
59# 74#
60# Public inheritable functions 75# Public inheritable functions
61# 76#
62 77
63font_src_install() { 78font_src_install() {
64 79 local suffix commondoc
65 local suffix
66 80
67 cd "${FONT_S}" 81 cd "${FONT_S}"
68 82
69 insinto "/usr/share/fonts/${PN}" 83 insinto "${FONTDIR}"
70 84
71 for suffix in ${FONT_SUFFIX}; do 85 for suffix in ${FONT_SUFFIX}; do
72 doins *.${suffix} 86 doins *.${suffix}
73 done 87 done
74 88
75 rm -f fonts.{dir,scale} encodings.dir 89 rm -f fonts.{dir,scale} encodings.dir
76 90
77 font_xfont_config 91 font_xfont_config
78 font_xft_config 92 font_xft_config
93 font_fontconfig
79 94
80 cd "${S}" 95 cd "${S}"
81 # try to install some common docs 96 dodoc ${DOCS} 2> /dev/null
82 DOCS="${DOCS} COPYRIGHT README NEWS"
83 dodoc ${DOCS}
84 97
98 # install common docs
99 for commondoc in COPYRIGHT README NEWS AUTHORS BUGS ChangeLog; do
100 [[ -s ${commondoc} ]] && dodoc ${commondoc}
101 done
85} 102}
86 103
87font_pkg_setup() { 104font_pkg_setup() {
88
89 # make sure we get no colissions 105 # make sure we get no collisions
90 # setup is not the nicest place, but preinst doesn't cut it 106 # setup is not the nicest place, but preinst doesn't cut it
91 rm "/usr/share/fonts/${PN}/fonts.cache-1" 107 [[ -e "${FONTDIR}/fonts.cache-1" ]] && rm -f "${FONTDIR}/fonts.cache-1"
92
93} 108}
94 109
110font_pkg_postinst() {
111 # unreadable font files = fontconfig segfaults
112 find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \
113 | xargs -r -0 chmod -v 0644
114
115 if has_version '>=media-libs/fontconfig-2.4'; then
116 if [ ${ROOT} == "/" ]; then
117 ebegin "Updating global fontcache"
118 fc-cache -fs
119 eend $?
120 fi
121 fi
122}
123
124font_pkg_postrm() {
125 # unreadable font files = fontconfig segfaults
126 find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \
127 | xargs -r -0 chmod -v 0644
128
129 if has_version '>=media-libs/fontconfig-2.4'; then
130 if [ ${ROOT} == "/" ]; then
131 ebegin "Updating global fontcache"
132 fc-cache -fs
133 eend $?
134 fi
135 fi
136}
137
95EXPORT_FUNCTIONS src_install pkg_setup 138EXPORT_FUNCTIONS src_install pkg_setup pkg_postinst pkg_postrm

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.32

  ViewVC Help
Powered by ViewVC 1.1.20