# Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 # $Header: /home/cvsroot/gentoo-x86/eclass/font.eclass,v 1.2 2003/11/17 00:40:59 usata Exp $ # # Author: MATSUU Takuto # Author: Mamoru KOMACHI # # The font eclass is used for installation and configuration of various # fonts within the Portage system. # # Variables: # FONTPATH Defines the path to which bdf/pcf fonts are installed. # TTFONTPATH Defines the path to which ttf fonts are installed. ECLASS="font" INHERITED="$INHERITED $ECLASS" DESCRIPTION="Based on the ${ECLASS} eclass" EXPORT_FUNCTIONS pkg_setup src_install src_compile pkg_postinst pkg_postrm \ efontdir efontinstall IUSE="X truetype" SLOT="0" if [ -n "`use X`" ] ; then newdepend media-fonts/chkfontpath newdepend virtual/x11 fi if [ -n "`use truetype`" ] ; then newdepend media-libs/fontconfig fi # # pkg_setup() : Checks if mkfontdir, encodings dir(USE="X"), mkfontscale # and fc-cache (USE="truetype") exist # pkg_setup() { if [ -n "`use X`" -a ! -x /usr/X11R6/bin/mkfontdir ] ; then ewarn "Could not find the mkfontdir binary!" die "Please install mkfontdir." fi if [ -n "`use truetype`" ] ; then if [ ! -x /usr/X11R6/bin/mkfontscale -o ! -x /usr/bin/fc-cache ] ; then ewarn "Could not find the mkfontscale or fc-cache binaries!" die "Please reinstall xfree distribution." fi fi if [ -n "`use X`" -a ! -d /usr/X11R6/lib/X11/fonts/encodings ] ; then ewarn "Encodings directory are missing!" die "Please restore /usr/X11R6/lib/X11/fonts/encodings." fi } # # src_compile() : Converts BDF fonts into PCF format # src_compile() { if [ -x ./configure ] ; then econf || die emake || die else if [ -n "${FONTPATH}" ] ; then for f in "`find ${S} -name '*.bdf'`" ; do echo "Converting ${f} into ${f%.*}.pcf ..." bdftopcf -o ${f%.*}.pcf ${f} echo "Gzipping ${f%.*}.pcf ..." gzip -9 ${f%.*}.pcf done fi fi } # # src_install() : Installs fonts # src_install() { [ -n "${FONTPATH}" ] && efontinstall pcf [ -n "${TTFONTPATH}" ] && efontinstall ttf [ -n "${DOCS}" ] && dodoc ${DOCS} } # # pkg_postinst() : Adds FONTPATH and TTFONTPATH to XF86Config and xfs # pkg_postinst() { if [ -n "`use X`" ] ; then if [ -n "${FONTPATH}" ] ; then for fp in "${FONTPATH}" ; do if [ -z "`chkfontpath -l | grep " ${fp}"`" ]; then ebegin "Adding ${fp} to XF86Config and xfs..." chkfontpath -qa ${fp} eend $? fi done fi if [ -n "${TTFONTPATH}" ] ; then for fp in "${TTFONTPATH}" ; do if [ -z "`chkfontpath -l | grep " ${fp}"`" ]; then ebegin "Adding ${fp} to XF86Config and xfs..." chkfontpath -qa ${fp} eend $? fi done fi fi efontdir } # # pkg_postrm() : Removes FONTPATH and TTFONTPATH from XF86Config and xfs # pkg_postrm() { if [ -n "`use X`" ] ; then if [ -n "${FONTPATH}" ] ; then for fp in "${FONTPATH}" ; do if [ ! -f "${fp}/fonts.dir" -o `head -n 1 "${fp}/fonts.dir"` = "0" ] ; then ebegin "Removing ${fp} from XF86Config and xfs..." chkfontpath -qr ${fp} eend $? fi done fi if [ -n "${TTFONTPATH}" ] ; then for fp in "${TTFONTPATH}" ; do echo ${fp} if [ ! -f "${fp}/fonts.dir" -o $(head -n 1 "${fp}/fonts.dir") = "0" ] ; then ebegin "Removing ${fp} from XF86Config and xfs..." chkfontpath -qr ${fp} eend $? fi done fi fi efontdir } # # efontinstall() : Installs fonts, arguments should be bdf, pcf and/or ttf # efontinstall() { for action in "$@" ; do case $action in bdf) einfo "Installing bdf fonts..." insinto ${FONTPATH:-/usr/share/fonts/${PN}/} for f in `find ${S} -name '*.bdf'` ; do doins $f done ;; pcf) einfo "Installing pcf fonts..." insinto ${FONTPATH:-/usr/share/fonts/${PN}/} for f in `find ${S} -name '*.pcf' -o -name '*.pcf.gz'` ; do echo "${f##*/}" if [ "${f##*.}" = "pcf" ] ; then gzip -9 $f doins ${f}.gz else doins $f fi done ;; ttf) einfo "Installing ttf fonts..." insinto ${TTFONTPATH:-/usr/share/fonts/ttf/${PN}/} for f in `find ${S} -name '*.ttf'` ; do doins $f done ;; *) ewarn "Unsupported font format." ;; esac done } # # efontdir() : Updates X and TrueType fontdir respectively # efontdir() { # Generate the encodings.dir ... /usr/X11R6/bin/mkfontdir -n \ -e /usr/X11R6/lib/X11/fonts/encodings \ -e /usr/X11R6/lib/X11/fonts/encodings/large \ -- /usr/X11R6/lib/X11/fonts/encodings ebegin "Scanning font directories" if [ -n "${FONTPATH}" ] ; then for fp in "${FONTPATH}" ; do ebegin " ${fp}" # Now generate fonts.dir files ... /usr/X11R6/bin/mkfontdir \ -e /usr/X11R6/lib/X11/fonts/encodings \ -e /usr/X11R6/lib/X11/fonts/encodings/large \ -- ${fp} > /dev/null eend $? done fi if [ -n "${TTFONTPATH}" ] ; then for fp in "${TTFONTPATH}" ; do ebegin " ${fp}" # Now generate fonts.dir files ... /usr/X11R6/bin/mkfontdir \ -e /usr/X11R6/lib/X11/fonts/encodings \ -e /usr/X11R6/lib/X11/fonts/encodings/large \ -- ${fp} > /dev/null /usr/X11R6/bin/mkfontscale \ -e /usr/X11R6/lib/X11/fonts/encodings/encodings.dir \ ${fp} > /dev/null cp ${fp}/fonts.scale ${fp}/fonts.dir if [ -x /usr/X11R6/bin/xftcache ] ; then ebegin "Updating XFT cache" # xftcache is broken, but run it anyhow ... /usr/X11R6/bin/xftcache ${fp} &> /dev/null eend $? fi eend $? done fi # While we at it, update fontconfig's cache as well if [ -n "`use truetype`" -a -x /usr/bin/fc-cache ] ; then ebegin "Updating FC cache" HOME="/root" /usr/bin/fc-cache eend $? fi eend $? # Scanning directories done }