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