[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cygwin-apps
Subject:    RFC: postinstall fontconfig cache changes
From:       Brian Inglis via Cygwin-apps <cygwin-apps () cygwin ! com>
Date:       2024-05-05 22:56:54
Message-ID: 910f0290-a20a-483a-acce-849b6948fd29 () SystematicSW ! ab ! ca
[Download RAW message or body]

Hi folks,

Since Yaakov added the fontconfig cache postinstall script, it has been 
selecting only fonts created by 'Microsoft Corp' and (recently?) matching 
'*.ttf' (lower case only) for whatever reasons?

I have been running my own attached local fontconfig cache postinstall script, 
with some tweaks, such as putting my symlinks into font directory 'windows' 
instead of fontconfig package's 'microsoft', using `cygpath -UW` so the symlinks 
to Windows/Fonts created survive changes I made to cygdrive over the years, 
adding .ttf fonts not created by 'Microsoft Corp' including those only 
'Microsoft supplied', original Windows .TTF (uppercase) fonts installed with the 
system, .ttc font collections which are supported by recent fontconfig, and .otf 
OpenType fonts provided with newer font packages, as Pango and Harfbuzz do not 
appear to support some recent TrueType hinting changes.

I also have to clean up the cache directory, as it sometimes got to *many* 1000s 
of cache files, taking up GB, a known but unsolved? (may now be fixed) issue 
with "broken" [see NEWS] font cache handling, whereas after resetting it has 
only dozens of cache files taking a dozen MB, created in ~10s for ~3600 fonts, 
from Windows, packages, and local downloads and installs.

I would like to request consideration for adding all Windows fonts of supported 
types of any case to the cache every startup.

-- 
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
["zp_l_fontconfig_cache.dash" (text/plain)]

#!/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

# find Windows .TTF, .otf, .ttc and non-MS Corp .ttf fonts and link between fonts \
dirs # Notes:
# system 
# 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;
# fontconfig handles ttc TrueType collections and otf OpenType fonts
/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 '*.otf' -print \)					| \
while read f
do
    [ -e "$winfontsdir/${f##*/}" ] || /bin/ln -st $winfontsdir/ "$f"
done

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

# 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



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic