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