The UUID files would be placed in each font directory to provide the
unique cache name, independent of path, for that directory. The UUID
files are undesireable for a couple of reasons:
1) They must be placed in the font directories to be useful. This
requires modifying the font directories themselves, introducing
potential visible timestamp changes when running multiple
applications, and makes the cache processing inconsistent between
applications with permission to write to the font directories and
applications without such permission.
2) The UUID contents were generated randomly, which makes the font
cache not reproducible across multiple runs.
One proposed fix for 2) is to make the UUID dependent on the font
directory path, but once we do that, we can simply use the font
directory path itself as the key as the original MD5-based font cache
naming mechanism did.
The goal of the UUID file mechanism was to fix startup time of
flatpaks; as the font path names inside the flatpak did not match the
font path names in the base system, the font cache would need to be
reconstructed the first time the flatpak was launched.
The new mechanism for doing this is to allow each '<dir>' element in
the configuration include a 'map' attribute. When looking for a cache
file for a particular directory, if the directory name starts with the
contents of the <dir> element, that portion of the name will be
replaced with the value of the 'map' attribute.
Outside of the flatpak, nothing need change -- fontconfig will build
cache files using real directory names.
Inside the flatpak, the custom fonts.conf file will now include
mappings such as this:
<dir map="/usr/share/fonts">/run/host/fonts</dir>
When scanning the directory /run/host/fonts/ttf, fontconfig will
use the name /usr/share/fonts/ttf as the source for building the cache
file name.
The existing FC_FILE replacement code used for the UUID-based
implementation continues to correctly adapt font path names seen by
applications.
v2:
Leave FcDirCacheCreateUUID stub around to avoid removing
public API function.
Document 'map' attribute of <dir> element in
fontconfig-user.sgml
Suggested-by: Akira TAGOH <akira@tagoh.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
Trying to address what these configuration files really do.
This change allows to see the short description that mention
the purpose of the content in the config file and obtain
them through API.
This change also encourage one who want to make some UI for
the user-specific configuration management. it is the main
purpose of this change for me though.
Aside from that, I've also made programs translatable. so
we see more dependencies on the build time for gettext,
and itstool to generate PO from xml.
Take a look at the nano second in the mtime to figure out
if the cache needs to be updated if available.
and do the mutex lock between scanning and writing a cache
to avoid the conflict.
Also we don't need to scan directories again after writing
caches. so getting rid of the related code as well.
https://bugs.freedesktop.org/show_bug.cgi?id=69845
and for reference:
https://bugzilla.redhat.com/show_bug.cgi?id=1236034
Add an ability to set the system root to generate the caches.
In order to do this, new APIs, FcConfigGetSysRoot() and
FcConfigSetSysRoot() is available.
Added -h instead of -?. And upon -h and --help, write usave to stdout
instead of stdin, and return 0 instead of 1.
-? still works like before as that's what getopt returns upon unknown
arguments.
Old cache file versions, or corrupted cache files should be removed when
cleaning cache directories with fc-cache. This only affects filenames which
match the fontconfig cache file format, so other files will be left alone.
Some mingw versions have broken X_OK checking; instead of trying to work
around this in a system-depedent manner, simply don't bother checking for
X_OK along with W_OK as such cases are expected to be mistakes, and not
sensible access control.
fc-cache would say 'skipping: %d fonts, %d dirs' or 'caching: %d fonts, %d
dirs', which could easily mislead the user. Add 'existing cache is valid' or
'new cache contents' to these messages to explain what it is doing.
This call was followed by a call to stat(2) which provided the necessary
information. This call to access(2) was necessary when cache files were
stored in the font directory as that would check for write permission
correctly.
Use filenames to clean cache files for current architecture only. This is
sufficient as cache files live in their own directory where filenames are
under fontconfig control.
Looks like the last directory in the project which didn't use $(WARN_CFLAGS)
for some reason. Adding that found the usual collection of char * vs FcChar8
* issues (why, oh why is FcChar8 not just char...)
Borrowing header stuff written for cairo, fontconfig now exposes in the
shared library only the symbols which are included in the public header
files. All private symbols are hidden using suitable compiler directives.
A few new public functions were required for the fontconfig utility programs
(fc-cat and fc-cache) so those were added, bumping the .so minor version number
in the process.
Instead of making filename canonicalization occur in multiple places, it
occurs only in FcStrAddFilename now, as all filenames pass through that
function at one point.
Instead of passing directory information around in separate variables,
collect it all in an FcCache structure. Numerous internal and tool
interfaces changed as a result of this.
Charsets are now pre-frozen before being serialized. This causes them to
share across multiple fonts in the same cache.
Validate cache contents and skip broken caches, looking down cache path for
valid ones.
Every time a directory is scanned, it will be written to a cache file if
possible, so fc-cache doesn't need to re-write the cache file. This makes
detecting when the cache was generated a bit tricky, so we guess that if the
cache wasn't valid before running and is valid afterwards, the cache file
was written.
Also, allow empty charsets to be serialized with null leaves/numbers.
Eliminate a leak in FcEdit by switching to FcObject sooner.
Call FcFini from fc-match to make valgrind happy.
With the removal of the in-directory cache files, and the addition of
per-user cache directories, there is no longer any reason to preserve the
giant global cache file. Eliminating of this unifies the cache structure
and simplifies the overall caching strategies greatly.
Normalized directory names offer protection against looped directory trees
but cost enormous numbers of system calls (stat per file in the hierarchy).
Also, cache file directory name contents are validated each time the
directory is modified, don't re-validate every time the cache file is loaded
with an access and stat call.