Hi folks,

I recently reviewed all the fonts installed on my system and found that fontconfig cache does not include TeX OpenType or TrueType fonts installed under /usr/share/texmf-dist/fonts/{open,true}type/, non-'Microsoft Corp' Windows fonts including those labelled 'Microsoft supplied font', .TTF, .ttc, and .ot[cf], but does cache those in the Windows/Fonts/Deleted subdirectory.

I run the attached permanent postinstall local script to pick up all those fonts the official script does not, clean up old broken links, link the font files into /usr/share/fonts/windows/ and /usr/share/fonts/{open,true}type/texmf-dist/ as appropriate, then mkfontscale fonts.scale and mkfontdir fonts.dir in each.

Please consider changing the official current stable permanent postinstall script to include these font installation directories, plus any others that maintainers may be aware of outside /usr/share/fonts/.

These would include fonts in Octave, Python, Ruby package directories: not all in /usr/share/fonts/ or my texmf-dist links, and those are may be duplicated from actual font packages, so would the best approach for these require the font packages, provide a standard location font subpackage linked to the package directory, or suggestions?

/usr/lib/python2.7/site-packages/reportlab/fonts/
/usr/lib/python2.7/site-packages/sphinx_rtd_theme/static/fonts/
/usr/lib/python2.7/site-packages/sphinx_rtd_theme/static/fonts/Lato/
/usr/lib/python2.7/site-packages/sphinx_rtd_theme/static/fonts/RobotoSlab/
/usr/lib/python3.6/site-packages/sphinx_rtd_theme/static/fonts/
/usr/lib/python3.6/site-packages/sphinx_rtd_theme/static/fonts/Lato/
/usr/lib/python3.6/site-packages/sphinx_rtd_theme/static/fonts/RobotoSlab/
/usr/lib/python3.7/site-packages/sphinx_rtd_theme/static/fonts/
/usr/lib/python3.7/site-packages/sphinx_rtd_theme/static/fonts/Lato/
/usr/lib/python3.7/site-packages/sphinx_rtd_theme/static/fonts/RobotoSlab/
/usr/lib/python3.8/site-packages/sphinx_rtd_theme/static/fonts/
/usr/lib/python3.8/site-packages/sphinx_rtd_theme/static/fonts/Lato/
/usr/lib/python3.8/site-packages/sphinx_rtd_theme/static/fonts/RobotoSlab/
/usr/lib/python3.9/site-packages/matplotlib/mpl-data/fonts/ttf/
/usr/lib/python3.9/site-packages/reportlab/fonts/
/usr/lib/python3.9/site-packages/sphinx_rtd_theme/static/fonts/
/usr/lib/python3.9/site-packages/sphinx_rtd_theme/static/fonts/Lato/
/usr/lib/python3.9/site-packages/sphinx_rtd_theme/static/fonts/RobotoSlab/
/usr/share/gems/doc/activesupport-5.1.6/rdoc/fonts/
/usr/share/gems/doc/coffee-rails-4.2.2/rdoc/fonts/
/usr/share/gems/doc/coffee-script-2.4.1/rdoc/fonts/
/usr/share/gems/doc/coffee-script-source-1.10.0/rdoc/fonts/
/usr/share/gems/doc/erubis-2.7.0/rdoc/fonts/
/usr/share/gems/doc/execjs-2.5.2/rdoc/fonts/
/usr/share/gems/doc/sass-3.5.6/rdoc/fonts/
/usr/share/gems/doc/uglifier-3.1.13/rdoc/fonts/
/usr/share/gems/gems/rdoc-6.7.0/lib/rdoc/generator/template/darkfish/fonts/
/usr/share/octave/8.4.0/fonts/

--
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                -- Antoine de Saint-Exupéry
#!/bin/dash
# zp_l_fontconfig_cache.dash - update Windows non-MS Corp ttf, TTF, ttc, and 
otf font links and rebuild font cache

winfontsdir=/usr/share/fonts/windows
cache=/var/cache/fontconfig
mscorp='Microsoft Corp'
win="$(cygpath -UW)/Fonts"      # ln to /proc/cygdrive in case mount changes 
later

/bin/mkdir -p $winfontsdir

# remove any broken links (-L -type l together)
/usr/bin/find -L $winfontsdir -type l -delete

# fontconfig handles ttc TrueType collections and otf OpenType fonts and otc 
collections
# find Windows non-MS Corp .ttf, all .TTF, .ttc, .otf, and .otc fonts and link 
between fonts dirs
# Notes:
# DUBAI-*, MTEXTRA, others are 'Microsoft supplied font';
# all *.TTF are 'Microsoft Corp'; some are also 'Microsoft supplied font';
# .../Fonts may have Deleted subdirectory;
# grep -L returns names of files with no pattern matches;
/usr/bin/find "$win" -maxdepth 1 -type f                                \
       \(  -name '*.ttf' -exec /bin/grep -FaL "$mscorp" '{}' + \)       \
    -o \(  -name '*.TTF' -print \)                                      \
    -o \( -iname '*.ttc' -print \)                                      \
    -o \( -iname '*.ot[cf]' -print \)                                   | \
while read f
do
    [ -e "$winfontsdir/${f##*/}" ] || /bin/ln -st $winfontsdir/ "$f"
done

/usr/bin/mkfontscale    $winfontsdir
/usr/bin/mkfontdir      $winfontsdir

for type in opentype truetype
do
    texfontsdir=/usr/share/fonts/$type/texmf-dist

    /bin/mkdir -p $texfontsdir

    # remove any broken links (-L -type l together)
    /usr/bin/find -L $texfontsdir -type l -delete

    dist=/usr/share/texmf-dist/fonts/$type

    # fontconfig handles ttc TrueType collections and otf OpenType fonts and 
otc collections
    # find .ttf, .TTF, .ttc, .otf, .otc fonts and link between fonts dirs
    /usr/bin/find "$dist" -type f -iname '*.[ot]t[cf]'          | \
    while read f
    do
        [ -e "$texfontsdir/${f##*/}" ] || /bin/ln -rst $texfontsdir/ "$f"
    done

    /usr/bin/mkfontscale        $texfontsdir
    /usr/bin/mkfontdir          $texfontsdir
done

# get cache file suffix currently -le64.cache-9 from latest fontconfig dll
dll=$(/bin/ls -rv /bin/cygfontconfig-*.dll | /usr/bin/head -n1)
suf=$(/bin/grep -Eao '[[:graph:]]*\.cache-[[:graph:]]+' $dll)

# cleanup cache every install - can become 100k+ files using GBs
/bin/rm -f $cache/*$suf
/usr/bin/find $cache -iname "*$suf" -delete

# reset and cache system dirs
/usr/libexec/fc-cache-1 -rs || :

# ensure TAG later for cleanup cron job
/usr/bin/touch -c $cache/CACHEDIR.TAG

Reply via email to