Commit Graph

24 Commits

Author SHA1 Message Date
Akira TAGOH acc017e672 Drop unnecessary line to include uuid.h 2019-04-03 12:02:09 +00:00
Keith Packard c4324f54ee Replace UUID file mechanism with per-directory 'map' attribute [v2]
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>
2019-04-03 12:02:09 +00:00
Akira TAGOH f5dd8512bd Remove .uuid when no font files exists on a directory
https://bugs.freedesktop.org/show_bug.cgi?id=106632
2018-06-11 17:03:46 +09:00
Alexander Larsson 4ff7155f5c FcHashTableAddInternal: Compare against the right key
We were comparing the passed in key with the ready-to-insert key
rather than the key in the hashtable, so if you ever had a hash
conflicts we'll never insert the new item.

https://bugs.freedesktop.org/show_bug.cgi?id=101889
2018-01-14 15:33:00 +09:00
Alexander Larsson 0b59a65a71 fchash: Fix replace
When we replace a bucket in the hashtable we have to update the
next pointer too, or we lose all the other elements that hashed to
this key.
2017-12-19 12:07:50 +09:00
Akira TAGOH e83f8777d5 Disable uuid related code on Win32 2017-12-18 21:45:13 +09:00
Akira TAGOH 8ab4d67995 Replace uuid in the table properly when -r 2017-12-18 20:05:14 +09:00
Akira TAGOH 57eaf0ba7e Returns false if key is already available in the table 2017-12-18 16:41:04 +09:00
Akira TAGOH 1b2279d6b5 thread-safe functions in fchash.c 2017-11-24 10:53:39 +05:30
Akira TAGOH abe91a1694 Use smaller prime for hash size 2017-11-20 17:37:23 +05:30
Akira TAGOH 665a5d3044 Fix a typo 2017-11-20 17:37:23 +05:30
Akira TAGOH 8f88b1c47c abstract hash table functions 2017-11-20 17:37:22 +05:30
Behdad Esfahbod 8f62ccaa96 Remove unused FcHash code now that FC_HASH is deprecated 2014-06-12 17:02:10 -04:00
Behdad Esfahbod 3f992254f2 Rewrite hashing to use FT_Stream directly
This is more robust but introduces a small change in behavior:
For .pcf.gz fonts, the new code calculates the hash of the uncompressed
font data whereas the original code was calculating the hash of the
compressed data.

No big deal IMO.
2014-05-16 15:02:58 -06:00
Behdad Esfahbod 8284df49ef Further simplify hash code 2014-05-16 14:23:56 -06:00
Behdad Esfahbod 748e77e89f Simplify hash code 2014-05-16 14:10:06 -06:00
Behdad Esfahbod e4d8847eee Remove unused code 2014-05-16 13:45:44 -06:00
Akira TAGOH 43f768b53f avoid reading config.h twice
config.h is read from fcint.h now so having a line of the sort of #include "config.h"
is duplicate.

Bug 69833 - Incorrect SIZEOF_VOID_P and ALIGNOF_DOUBLE definitions causes nasty warnings on MacOSX when building fat libraries
2013-09-26 17:51:15 +09:00
Akira TAGOH 8603e58695 Fix a shift count overflow on 32bit box 2013-06-27 12:30:56 +09:00
Akira TAGOH 03216ccf4c Bug 63329 - make check fails: .. contents:: :depth: 2
Add back FcHashGetSHA256DigestFromFile() and fall back to it
when font isn't SFNT-based font because FT_Load_Sfnt_Table
fails with FT_Err_Invalid_Face_Handle.
2013-04-10 18:41:22 +09:00
Akira TAGOH fc5a589aba Revert the previous change and rework to not export freetype API outside fcfreetype.c 2013-04-09 17:18:43 +09:00
Akira TAGOH c93a8b8b54 Obtain fonts data via FT_Face instead of opening a file directly 2013-04-09 12:46:30 +09:00
Akira TAGOH 9299155b52 Ensure closing fp on error 2013-04-09 11:34:35 +09:00
Akira TAGOH 95af7447db Bug 50733 - Add font-file hash?
Add "hash" object which contains SHA256 hash value (so far) computed from the font file.
2013-02-05 15:34:56 +09:00