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

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

  ViewVC Help
Powered by ViewVC 1.1.20