Add "fc", "fcfontsdir", "fontsdir", and "none" arguments to USES=fonts.

They controls whether fc-cache and/or mkfontdir run in
post-{,de}install targets.

japanese/font-* use manually generates fonts.dir entries to utilize
special modifiers which are useful for CJK fonts.  Because mkfontdir
does not understand and silently remove them from fonts.dir,
options like fonts:fc or fonts:none is required.

Approved by:	portmgr (bapt)
This commit is contained in:
Hiroki Sato 2015-09-13 23:30:21 +00:00
parent ad82069793
commit c716728e4a
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=396872
3 changed files with 67 additions and 5 deletions

19
Keywords/fc.ucl Normal file
View file

@ -0,0 +1,19 @@
# $FreeBSD$
#
# MAINTAINER: x11@FreeBSD.org
actions: [dir]
post-install: <<EOD
case "%@" in
/*) fontsdir="%@" ;;
*) fontsdir="%D/%@" ;;
esac
fc-cache -fs ${fontsdir} 2>/dev/null || true
EOD
post-deinstall: <<EOD
case "%@" in
/*) fontsdir="%@" ;;
*) fontsdir="%D/%@" ;;
esac
fc-cache -fs ${fontsdir} 2>/dev/null || true
EOD

27
Keywords/fontsdir.ucl Normal file
View file

@ -0,0 +1,27 @@
# $FreeBSD$
#
# MAINTAINER: x11@FreeBSD.org
actions: [dir]
post-install: <<EOD
case "%@" in
/*) fontsdir="%@" ;;
*) fontsdir="%D/%@" ;;
esac
mkfontscale ${fontsdir} 2>/dev/null || true
mkfontdir ${fontsdir} 2>/dev/null || true
EOD
post-deinstall: <<EOD
case "%@" in
/*) fontsdir="%@" ;;
*) fontsdir="%D/%@" ;;
esac
mkfontscale ${fontsdir} 2>/dev/null || true
if [ -e ${fontsdir}/fonts.scale -a "`stat -f '%%z' ${fontsdir}/fonts.scale 2>/dev/null`" = '2' ]; then
rm ${fontsdir}/fonts.scale
fi
mkfontdir ${fontsdir} 2>/dev/null || true
if [ -e ${fontsdir}/fonts.dir -a "`stat -f '%%z' ${fontsdir}/fonts.dir 2>/dev/null`" = '2' ]; then
rm ${fontsdir}/fonts.dir
fi
EOD

View file

@ -3,21 +3,37 @@
# handle fonts
# Feature: fonts
# Usage: USES=fonts
# Valid ARGS: fc, fontsdir, fcfontsdir, none (empty means fcfontsdir)
# fc Add @fc ${FONTSDIR} to PLIST_FILES
# fontsdir Add @fontsdir ${FONTSDIR} to PLIST_FILES
# fcfontsdir Add @fcfontsdir ${FONTSDIR} to PLIST_FILES
# none No special handling of ${FONTSDIR} in PLIST_FILES
.if !defined(_INCLUDE_USES_FONTS_MK)
_INCLUDE_USES_FONTS_MK= yes
.if !empty(fonts_ARGS)
IGNORE= USES=fonts - expecting no arguments
.if empty(fonts_ARGS)
fonts_ARGS= fcfontsdir
.endif
RUN_DEPENDS+= fc-cache:${PORTSDIR}/x11-fonts/fontconfig \
mkfontdir:${PORTSDIR}/x11-fonts/mkfontdir \
.if !empty(fonts_ARGS:Nfc:Nfontsdir:Nfcfontsdir:Nnone)
IGNORE= USES=fonts - invalid ARGS (${fonts_ARGS)
.endif
.if !empty(fonts_ARGS:Mfc) || !empty(fonts_ARGS:Mfcfontsdir)
RUN_DEPENDS+= fc-cache:${PORTSDIR}/x11-fonts/fontconfig
.endif
.if !empty(fonts_ARGS:Mfontsdir) || !empty(fonts_ARGS:Mfcfontsdir)
RUN_DEPENDS+= mkfontdir:${PORTSDIR}/x11-fonts/mkfontdir \
mkfontscale:${PORTSDIR}/x11-fonts/mkfontscale
.endif
FONTNAME?= ${PORTNAME}
FONTSDIR?= ${PREFIX}/share/fonts/${FONTNAME}
PLIST_FILES+= "@fcfontsdir ${FONTSDIR}"
.if !empty(fonts_ARGS:Nnone)
PLIST_FILES+= "@${fonts_ARGS} ${FONTSDIR}"
.endif
SUB_LIST+= FONTSDIR="${FONTSDIR}"
PLIST_SUB+= FONTSDIR="${FONTSDIR}"
.endif