Description of problem: xfs sometimes unessarily rebuilds fonts.dir only because of the presences of a newer fonts.cache-1 file, not for any actual new fonts. Version-Release number of selected component (if applicable): XFree-4.3.0-15 Patch to xfs.init to ignore the presence of fonts.cache-1 file: 34c34 < elif [ "$(find . -type f -cnewer fonts.dir 2>/dev/null)" != "" ];then --- > elif [ "$(find . -type f -not -name fonts.cache-1 -cnewer fonts.dir 2>/dev/null)" != "" ];then
Doh, this report fell between the cracks, however recent discussion brought it back to my attention. I've just commited a fix to xfs.init in the src.rpm which is based on your above fix, but slightly more robust: elif [ "$(find . -type f -cnewer fonts.dir -not -name "fonts.cache*" >/dev/null)" != "" ];then The fonts.cache filenames may change in future, so this will catch any changes. Owen: Is this sufficient, or is there some other enhancement you think would be nice to include to speed up startup? The current fix is in 4.3.0-37.1 and will be in the next rawhide build.
As discussed in IRC yesterday, while the above is needed, it is not sufficient. You also need to run fc-cache at least every time you update a fonts.dir file, or any change to a font directory will leave fontconfig permanently out of date. The simplest way to do this is to *always* run fc-cache; it's quite fast when there are no out-of-date font directories. Thaat is, at the end of buildfontlist, add: 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. + [ -x /usr/bin/fc-cache ] && /usr/bin/fc-cache popd &> /dev/null I tested this yesterday with a patch similar to what you had above (fonts.cache*) and it worked well. In your comment above, is the >/dev/null replaing 2>/dev/null just a typo? It clearly won't won't work that way :-)
>The simplest way to do this is to *always* run fc-cache; it's quite >fast when there are no out-of-date font directories. Thaat is, >at the end of buildfontlist, add: Ok, I'll add that, however I think the fontconfig package should have it's own initscript also which does similar detection for cases where the user disables our xfs initscript, either because they prefer to use the X server to handle core fonts, or because they're using a networked font server. That's something that we can do for the next development cycle if you agree that it is a sane thing to do (which I hope <grin>). The fc-cache being in xfs initscript seems like a good idea regardless though, even if we do have a fontconfig initscript.
I've added your fc-cache suggestion to the xfs.init script. >In your comment above, is the >/dev/null replaing 2>/dev/null just a typo? >It clearly won't won't work that way :-) That was an inadvertent typo that got into the bugzilla comment when I added it somehow. The initscript has 2>/dev/null still. ;o)
Here are all of the changes I made, which are awaiting peer review before I officially commit all changes to the next build: @@ -32,25 +32,29 @@ NEEDED=no if ! [ -e fonts.dir ]; then NEEDED=yes - elif [ "$(find . -type f -cnewer fonts.dir 2>/dev/null)" != "" ];then + elif [ "$(find . -type f -cnewer fonts.dir -not -name "fonts.cache*" 2>/dev/null)" != "" ];then NEEDED=yes fi if [ "$NEEDED" = "yes" ]; then rm -f fonts.dir &>/dev/null - if ls | grep -i "\.tt[cf]$" &>/dev/null; then - # TrueType fonts found... + if ls | grep -i "\.[ot]t[cf]$" &>/dev/null; then + # TrueType or Opentype fonts found... 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 -iv '\(fonts\.\(scale\|alias\|cache.*\)$\|.+\(\.[ot]t[cf]\|dir\)$\)')" != "" ]; then + # This directory contains fonts that are not TrueType or Opentype... 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. + [ -x /usr/bin/fc-cache ] && /usr/bin/fc-cache popd &> /dev/null }
Hmm, the final check will trigger mkfontdir to be called if the directory contains a subdirectory. Perhaps it should use "find . -type f -regex '....'" instead of using ls | grep? However the find command would have to limit it's search to just the one directory and not subdirs otherwise new files found in subdirs would trigger fonts.dir recreation in the current dir also. Kind of pedantic, however I'm trying to cover all corner cases, or else it's pointless if it ends up causing fonts.dir creation anyways due to some oddity or another. Thoughts?
4.3.0-39 in rawhide implements a fix for this and other issues, and should start rather quickly now.