| 1 | # Copyright 1999-2007 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.37 2008/05/19 00:42:13 dirtyepic Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.38 2008/06/21 06:12:45 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 | |
|
|
28 | # @ECLASS-VARIABLE: FONT_PN |
|
|
29 | # @DESCRIPTION: |
| 21 | FONT_PN=${PN} # Last part of $FONTDIR |
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: |
| 25 | FONT_CONF=( "" ) # Array, which element(s) is(are) path(s) of fontconfig-2.4 file(s) to install |
40 | # Array, which element(s) is(are) path(s) of fontconfig-2.4 file(s) to install |
|
|
41 | FONT_CONF=( "" ) |
| 26 | |
42 | |
|
|
43 | # @ECLASS-VARIABLE: DOCS |
|
|
44 | # @DESCRIPTION: |
| 27 | DOCS="" # Docs to install |
45 | # Docs to install |
|
|
46 | DOCS="" |
| 28 | |
47 | |
| 29 | IUSE="X" |
48 | IUSE="X" |
| 30 | |
49 | |
| 31 | DEPEND="X? ( x11-apps/mkfontdir ) |
50 | DEPEND="X? ( x11-apps/mkfontdir ) |
| 32 | media-libs/fontconfig" |
51 | media-libs/fontconfig" |
| 33 | |
52 | |
| 34 | # |
53 | # |
| 35 | # Public functions |
54 | # Public functions |
| 36 | # |
55 | # |
| 37 | |
56 | |
|
|
57 | # @FUNCTION: font_xfont_config |
|
|
58 | # @DESCRIPTION: |
|
|
59 | # Creates the Xfont files. |
| 38 | font_xfont_config() { |
60 | font_xfont_config() { |
| 39 | # create Xfont files |
61 | # create Xfont files |
| 40 | if use X ; then |
62 | if use X ; then |
| 41 | einfo "Creating fonts.scale & fonts.dir ..." |
63 | einfo "Creating fonts.scale & fonts.dir ..." |
| 42 | mkfontscale "${D}${FONTDIR}" |
64 | mkfontscale "${D}${FONTDIR}" |
| … | |
… | |
| 48 | doins "${FONT_S}/fonts.alias" |
70 | doins "${FONT_S}/fonts.alias" |
| 49 | fi |
71 | fi |
| 50 | fi |
72 | fi |
| 51 | } |
73 | } |
| 52 | |
74 | |
|
|
75 | # @FUNCTION: font_xft_config |
|
|
76 | # @DESCRIPTION: |
|
|
77 | # Creates the fontconfig cache if necessary. |
| 53 | font_xft_config() { |
78 | font_xft_config() { |
| 54 | if ! has_version '>=media-libs/fontconfig-2.4'; then |
79 | if ! has_version '>=media-libs/fontconfig-2.4'; then |
| 55 | # create fontconfig cache |
80 | # create fontconfig cache |
| 56 | einfo "Creating fontconfig cache ..." |
81 | einfo "Creating fontconfig cache ..." |
| 57 | # Mac OS X has fc-cache at /usr/X11R6/bin |
82 | # Mac OS X has fc-cache at /usr/X11R6/bin |
| 58 | HOME="/root" fc-cache -f "${D}${FONTDIR}" |
83 | HOME="/root" fc-cache -f "${D}${FONTDIR}" |
| 59 | fi |
84 | fi |
| 60 | } |
85 | } |
| 61 | |
86 | |
|
|
87 | # @FUNCTION: font_fontconfig |
|
|
88 | # @DESCRIPTION: |
|
|
89 | # Installs the fontconfig config files of FONT_CONF. |
| 62 | font_fontconfig() { |
90 | font_fontconfig() { |
| 63 | local conffile |
91 | local conffile |
| 64 | if [[ -n ${FONT_CONF[@]} ]]; then |
92 | if [[ -n ${FONT_CONF[@]} ]]; then |
| 65 | if has_version '>=media-libs/fontconfig-2.4'; then |
93 | if has_version '>=media-libs/fontconfig-2.4'; then |
| 66 | insinto /etc/fonts/conf.avail/ |
94 | insinto /etc/fonts/conf.avail/ |
| … | |
… | |
| 73 | |
101 | |
| 74 | # |
102 | # |
| 75 | # Public inheritable functions |
103 | # Public inheritable functions |
| 76 | # |
104 | # |
| 77 | |
105 | |
|
|
106 | # @FUNCTION: font_src_install |
|
|
107 | # @DESCRIPTION: |
|
|
108 | # The font src_install function, which is exported. |
| 78 | font_src_install() { |
109 | font_src_install() { |
| 79 | local suffix commondoc |
110 | local suffix commondoc |
| 80 | |
111 | |
| 81 | cd "${FONT_S}" |
112 | cd "${FONT_S}" |
| 82 | |
113 | |
| … | |
… | |
| 99 | for commondoc in COPYRIGHT README{,.txt} NEWS AUTHORS BUGS ChangeLog FONTLOG.txt; do |
130 | for commondoc in COPYRIGHT README{,.txt} NEWS AUTHORS BUGS ChangeLog FONTLOG.txt; do |
| 100 | [[ -s ${commondoc} ]] && dodoc ${commondoc} |
131 | [[ -s ${commondoc} ]] && dodoc ${commondoc} |
| 101 | done |
132 | done |
| 102 | } |
133 | } |
| 103 | |
134 | |
|
|
135 | # @FUNCTION: font_pkg_setup |
|
|
136 | # @DESCRIPTION: |
|
|
137 | # The font pkg_setup function, which is exported. |
| 104 | font_pkg_setup() { |
138 | font_pkg_setup() { |
| 105 | # make sure we get no collisions |
139 | # make sure we get no collisions |
| 106 | # setup is not the nicest place, but preinst doesn't cut it |
140 | # setup is not the nicest place, but preinst doesn't cut it |
| 107 | [[ -e "${FONTDIR}/fonts.cache-1" ]] && rm -f "${FONTDIR}/fonts.cache-1" |
141 | [[ -e "${FONTDIR}/fonts.cache-1" ]] && rm -f "${FONTDIR}/fonts.cache-1" |
| 108 | } |
142 | } |
| 109 | |
143 | |
|
|
144 | # @FUNCTION: font_pkg_postinst |
|
|
145 | # @DESCRIPTION: |
|
|
146 | # The font pkg_postinst function, which is exported. |
| 110 | font_pkg_postinst() { |
147 | font_pkg_postinst() { |
| 111 | # unreadable font files = fontconfig segfaults |
148 | # unreadable font files = fontconfig segfaults |
| 112 | find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ |
149 | find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ |
| 113 | | xargs -0 chmod -v 0644 2>/dev/null |
150 | | xargs -0 chmod -v 0644 2>/dev/null |
| 114 | |
151 | |
| … | |
… | |
| 119 | eend $? |
156 | eend $? |
| 120 | fi |
157 | fi |
| 121 | fi |
158 | fi |
| 122 | } |
159 | } |
| 123 | |
160 | |
|
|
161 | # @FUNCTION: font_pkg_postrm |
|
|
162 | # @DESCRIPTION: |
|
|
163 | # The font pkg_postrm function, which is exported. |
| 124 | font_pkg_postrm() { |
164 | font_pkg_postrm() { |
| 125 | # unreadable font files = fontconfig segfaults |
165 | # unreadable font files = fontconfig segfaults |
| 126 | find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ |
166 | find "${ROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ |
| 127 | | xargs -0 chmod -v 0644 2>/dev/null |
167 | | xargs -0 chmod -v 0644 2>/dev/null |
| 128 | |
168 | |