--- xfs.init.old 2003-09-18 19:15:34.000000000 -0400 +++ xfs.init 2003-10-09 00:47:00.000000000 -0400 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # xfs: Starts the X Font Server # @@ -29,28 +29,46 @@ if [ -d "$d" ]; then cd $d # Check if we need to rerun mkfontdir - NEEDED=no + REGEN_FONTS_DIR=no if ! [ -e fonts.dir ]; then - NEEDED=yes - elif [ "$(find . -type f -cnewer fonts.dir 2>/dev/null)" != "" ];then - NEEDED=yes + REGEN_FONTS_DIR=yes + elif [ "$(find . -type f -cnewer fonts.dir -not -name "fonts.cache*" 2>/dev/null)" != "" ];then + REGEN_FONTS_DIR=yes fi - if [ "$NEEDED" = "yes" ]; then + if [ "$REGEN_FONTS_DIR" = "yes" ]; then rm -f fonts.dir &>/dev/null - if ls | grep -i "\.tt[cf]$" &>/dev/null; then - # TrueType fonts found... + if ls | grep -iqs "\.tt[cf]$" ; then + # TrueType fonts found, generate fonts.scale and fonts.dir ttmkfdir -d . -o fonts.scale mkfontdir . &>/dev/null [ -e fonts.dir ] && chmod 644 fonts.scale fonts.dir fi - if [ "$(ls |egrep -iv '\.tt[cf]$|^fonts\.|^encodings\.')" != "" ]; then - # This directory contains fonts that are not TrueType... + if ls | grep -iqs "\.ot[cf]$" ; then + # Opentype fonts found, generate fonts.scale and fonts.dir + mkfontscale . + mkfontdir . &>/dev/null + [ -e fonts.dir ] && chmod 644 fonts.scale fonts.dir + fi + if ls |grep -Eiqsv '(^fonts\.(scale|alias|cache.*)$|.+(\.[ot]t[cf]|dir)$)' ; then + # This directory contains non-TrueType/non-Opentype fonts mkfontdir . &>/dev/null [ -e fonts.dir ] && chmod 644 fonts.dir fi fi fi done + # Recreating fonts.dir files above may result in stale fonts.cache-1 + # files since the directory mtimes change, so we run fc-cache to + # update any necessary fonts.cache files. + FC_CACHE=/usr/bin/fc-cache + if [ "$REGEN_FONTS_DIR" = "yes" -a -x $FC_CACHE ] + # fc-cache 1.0.2 as included in Red Hat Linux 8.0 will SEGV when executed + # by this initscript, so we don't run fc-cache for version 1.0.2 since + # even if fc-cache were fixed, we can't guarantee the user would have the + # fixed version installed. Yes, this is an ugly, but necessary hack for + # the time being. + [ $FC_CACHE --version 2>&1 | grep -q '1\.0\.2' ] || $FC_CACHE + fi popd &> /dev/null }