1 # $NetBSD: fonts,v 1.5 2007/07/12 19:41:46 jlam Exp $
3 # Generate a +FONTS script that updates font databases for the package.
7 ${CAT} > ./+FONTS << 'EOF'
10 # +FONTS - font database management script
12 # Usage: ./+FONTS [metadatadir]
14 # This scripts rebuilds font databases needed by the package associated
17 # Lines starting with "# FONTS: " are data read by this script that name
18 # the directories in which the font database will be rebuilt.
20 # # FONTS: /usr/pkg/lib/X11/fonts/TTF ttf
21 # # FONTS: /usr/pkg/lib/X11/fonts/Type1 type1
22 # # FONTS: /usr/pkg/lib/X11/fonts/misc x11
24 # For each FONTS entry, if the path is relative, that it is taken to be
25 # relative to ${PKG_PREFIX}.
31 MKFONTDIR="@MKFONTDIR@"
39 TTF_INDEX_CMD="@TTF_INDEX_CMD@"
40 TYPE1_INDEX_CMD="@TYPE1_INDEX_CMD@"
41 TYPE1_POSTINDEX_CMD="@TYPE1_POSTINDEX_CMD@"
42 X11_ENCODINGSDIR="@X11_ENCODINGSDIR@"
47 PKG_METADATA_DIR="${1-${CURDIR}}"
48 : ${PKGNAME=${PKG_METADATA_DIR##*/}}
49 : ${PKG_PREFIX=@PREFIX@}
51 case "${PKG_UPDATE_FONTS_DB:-@PKG_UPDATE_FONTS_DB@}" in
52 [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
53 _PKG_UPDATE_FONTS_DB=yes
55 [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
56 _PKG_UPDATE_FONTS_DB=no
60 case "${FONTS_VERBOSE:-@FONTS_VERBOSE@}" in
61 [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
64 [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
69 ${SED} -n "/^\# FONTS: /{s/^\# FONTS: //;p;}" ${SELF} | ${SORT} -u |
70 while read dir font_type; do
71 case ${_PKG_UPDATE_FONTS_DB} in
76 [!/]*) dir="${PKG_PREFIX}/$dir" ;;
78 ${TEST} -d "$dir" || continue
79 ( $echo "${PKGNAME}: updating font database in $dir ($font_type)"
84 [tT][tT][fF]) update_cmd="${TTF_INDEX_CMD}" ;;
85 [tT][yY][pP][eE]1) update_cmd="${TYPE1_INDEX_CMD}"
86 post_update_cmd="${TYPE1_POSTINDEX_CMD}" ;;
87 [xX]11) update_cmd="${MKFONTDIR}"
88 [ ! -z "${X11_ENCODINGSDIR}" ] && update_args="-e ${X11_ENCODINGSDIR}" ;;
90 ${TEST} -f "$update_cmd" || update_cmd="${TRUE}"
91 $update_cmd $update_args >/dev/null
94 # Remove fonts databases if there are no fonts in the directory.
95 # We filter out the encodings.dir, fonts.{dirs,scale}, and
96 # Fontmap database files from the directory listing. Also remove
97 # the directory if it turns out to be empty.
99 if ${FIND} . -type f | ${GREP} -v "/encodings.dir" | ${GREP} -v "/fonts\.scale" | \
100 ${GREP} -v "/fonts\.dir" | ${GREP} -v "/Fontmap" >/dev/null
102 : # Directory not empty; do nothing.
104 ${RM} -f fonts.dir fonts.scale Fontmap* encodings.dir
105 ${RMDIR} -p $dir 2>/dev/null
111 ${SED} -n "/^\# FONTS: /p" ${SELF} >> ./+FONTS