Commit Graph

1347 Commits

Author SHA1 Message Date
Szunti df29933e1a Check qual and compare for family tests
Fixes #267. Hash table lookups assumed qual="any" compare="eq".
Add a test too.
2020-12-17 04:51:20 +00:00
Ben Wagner d55eaa6b31 Fix leaks in fcxml.c, fc-match.c, and tests.
Fix leaks reported by AddressSanitizer when running 'make check'.
2020-12-14 10:54:11 +00:00
Ben Wagner 97d5418554 Remove abort from FcCompareSize.
There doesn't appear to be a good reason to abort when 'v1' has type
FcTypeRange. If there does turn out to be a good reason for this then it
should be better documented and the code for handling this case removed.
At worst it seems -1 should be returned as it is for other unknown
types. It is possible this is left over debug code from the initial
implementation.
2020-12-07 04:21:38 +00:00
Ben Wagner 3d6926380d Skip leading whitespace in style name.
Found by Clang-Tidy. The intent seems to have been to skip all leading
whitespace in the 'style' string, but instead this loop was an odd
looking no-op. Remove the 'break' from the loop so that it will
continue until end of string or a non-space character is found.
2020-12-04 15:05:38 -05:00
Akira TAGOH 93c93689f5 Add back fullname property at scan matching phase
There seems to be a lot of config files using fullname property in the world.
To keep the backward compatibility, fullname property is back to a cache at
the scan matching phase but will be rebuilt once it is done according to family
and style property in the pattern no matter what changes one made in fullname
property during that.

Ref. https://bugzilla.redhat.com/show_bug.cgi?id=1902881
2020-12-04 18:18:03 +09:00
Niklas Guertler bc84228a2e Allow multiple default system font directories in the fallback config, and set them to the default dirs on Darwin. 2020-11-28 01:16:36 +00:00
Chun-wei Fan 89f7bcac08 meson: Don't use .def files for Visual Studio builds
Instead, when building with Visual Studio-style compilers, define 'FcPublic' as
appropriate so that symbols will be exported without the need to maintain a
.def file.
2020-11-19 11:22:29 +08:00
Akira TAGOH 8815641571 Use memcpy instead of strcpy
To work around a warning with GCC10 on Win32

warning: '__builtin___strncpy_chk' specified bound depends on the length of the source argument [-Wstringop-overflow=]
2020-11-02 14:25:01 +09:00
Ben Wagner 447b9ccc7d Fix fc_atomic_ptr_get and use.
Before this change building with ThreadSanitizer and running
test/test-pthread generated a large number of threading issues. These
mostly stemmed from fc_atomic_ptr_get not doing an atomic load and using
"acquire load" instead of "load acquire". After making these changes it
was still necessary to use fc_atomic_ptr_get where it was needed.

This also documents the current memory barrier requirements for the
atomic primitives.
2020-11-02 05:05:24 +00:00
Xavier Claessens abc723366d meson: Fix build failure when compiler is not in PATH
When cross compiling gcc/clang could not exist in PATH and Meson could
be using aarch64-linux-android-clang set in a cross file for example.
2020-10-03 22:07:54 -04:00
Akira TAGOH dc1443ac83 Split up a code again coming from different copyright notice
to show up easier in COPYING.
it was originally merged from separate file by 2e2121f9 though.
2020-09-29 15:37:14 +09:00
Akira TAGOH dbef9d10de Make sure a combination of family and familylang is available 2020-09-21 14:55:21 +09:00
Akira TAGOH 5a291467a7 Add Regular style when no meta data available to guess a style
This makes sure that fullname can be constructed at least even if a style is missing
and "Regular" is omitted for fullname so this change won't affect in that case.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/259
2020-09-21 14:55:18 +09:00
Akira TAGOH dbd67ccc63 Update meson.build 2020-09-16 15:06:43 +09:00
Akira TAGOH c78e7fd6de Add fullname later once FcConfigSubstitute() is done
So user's changes in family and style will be reflected into fullname.
2020-09-16 13:40:48 +09:00
Akira TAGOH 0f9040406c Construct fullname from family and style
OpenType spec says that the Regular descriptor would generally be
omitted from fullname. but some fonts doesn't follow on it.

So decided to construct a fullname from family and style instead of
relying on the meta data in a font.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/208
2020-09-16 13:40:48 +09:00
Akira TAGOH 76f88e780a fc-scan: add --sysroot option
and fix scanning to get things work with sysroot

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/225
2020-09-15 18:17:36 +09:00
Akira TAGOH 9d419e22d6 Add CONFIGDIR to the fallback config where can be specified by --with-configdir 2020-09-15 18:14:30 +09:00
Akira TAGOH 3ae08a8601 Make more clearer the license terms
COPYING is missing non-expat license terms for some files and some files is also missing license terms. This is changes to makes it clearer and update.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/219
2020-09-03 06:25:30 +00:00
Matthias Clasen e735abcfe1 Fix a problem in FcConfigSubstitute
We were using the family names from the pattern without
copying, and this was leading to a valgrind warning:
==53167== Invalid read of size 1
==53167==    at 0x58B0238: FcStrCaseWalkerNextNonBlank (fcstr.c:198)
==53167==    by 0x58B0238: FcStrCaseWalkerNextNonBlank (fcstr.c:186)
==53167==    by 0x58B02C7: FcStrCmpIgnoreBlanksAndCase (fcstr.c:281)
==53167==    by 0x58A4D44: FcHashTableFind (fchash.c:109)
==53167==    by 0x5895E76: FamilyTableAdd (fccfg.c:1634)
==53167==    by 0x589646A: FcConfigAdd.isra.0 (fccfg.c:1823)
==53167==    by 0x58988CF: IA__FcConfigSubstituteWithPat.part.0 (fccfg.c:2228)
==53167==    by 0x55F4F1A: pango_cairo_fc_font_map_fontset_key_substitute (pangocairo-fcfontmap.c:106)
==53167==    by 0x5B88AF6: pango_fc_default_substitute (pangofc-fontmap.c:1795)
==53167==    by 0x5B88D15: pango_fc_font_map_get_patterns (pangofc-fontmap.c:1850)
==53167==    by 0x5B88FC7: pango_fc_font_map_load_fontset (pangofc-fontmap.c:1952)
==53167==    by 0x5623627: pango_font_map_load_fontset (pango-fontmap.c:161)
==53167==    by 0x5621743: pango_context_get_metrics (pango-context.c:1782)
==53167==  Address 0x150d3450 is 0 bytes inside a block of size 10 free'd
==53167==    at 0x483B9F5: free (vg_replace_malloc.c:538)
==53167==    by 0x58ABE70: FcValueListDestroy (fcpat.c:147)
==53167==    by 0x5898A08: IA__FcConfigSubstituteWithPat.part.0 (fccfg.c:2203)
==53167==    by 0x55F4F1A: pango_cairo_fc_font_map_fontset_key_substitute (pangocairo-fcfontmap.c:106)
==53167==    by 0x5B88AF6: pango_fc_default_substitute (pangofc-fontmap.c:1795)
==53167==    by 0x5B88D15: pango_fc_font_map_get_patterns (pangofc-fontmap.c:1850)
==53167==    by 0x5B88FC7: pango_fc_font_map_load_fontset (pangofc-fontmap.c:1952)
==53167==    by 0x5623627: pango_font_map_load_fontset (pango-fontmap.c:161)
==53167==    by 0x5621743: pango_context_get_metrics (pango-context.c:1782)

Use copies of the strings as keys in the hash table to avoid this.
2020-08-30 12:05:24 -04:00
Matthias Clasen ff7d314ab5 Fix up FC_LIKELY macros
__builtin_expect returns the same type as the expression,
so enforce that we pass in a boolean expression.

Pointed out by Emmanuele Bassi.
2020-08-25 18:12:07 -04:00
Matthias Clasen e117d6768c Fixup: Handle patterns without family
Pointed out by Akira Tagoh.
2020-08-25 12:15:45 -04:00
Matthias Clasen 51d40491fc Use FC_UNLIKELY 2020-08-25 12:15:45 -04:00
Matthias Clasen 76699a4813 Add FC_LIKELY and FC_UNLIKELY macros
These wrap __builtin_expect where it exists.
2020-08-25 12:15:45 -04:00
Matthias Clasen 835f9bbdbe Fixup: Promote ints to ranges when appropriate
Pointed out by Akira Tagoh.
2020-08-25 12:15:45 -04:00
Matthias Clasen 148ebf98ed Use __builtin_expect in a few places
utf8 is extremely rare in the strings we see in
font configuration, so this seems to be a good
case for __builtin_expect.
2020-08-25 12:15:45 -04:00
Matthias Clasen 13015a0a6e Use a hash table for families in FcConfigSubstitute
Use the same approach we used for FcFontMatch, and
keep a hash table of family names. We only speed
up the no-match case, for now.
2020-08-25 12:15:18 -04:00
Matthias Clasen 7deb07e38e Speed up FcCompareLang and FcCompareBool
Avoid FcCanonicalize here too.
2020-08-25 12:15:18 -04:00
Matthias Clasen 09729c9032 Speed up FcConfigCompareValue
Avoid FcValueCanonicalize when we can, to avoid
unnecessary copying of FcValue structs.
2020-08-25 12:15:18 -04:00
Matthias Clasen 9d4e5d0f25 Speed up FcConfigCompareValue
Make FcConfigPromote use a switch instead of
an if-else cascade, and avoid calling it when
we can.

Note that we need to add a case for integers
in FcConfigCompareValue, since we are no longer
promoting integers to doubles unconditionally.
2020-08-25 12:15:18 -04:00
Matthias Clasen 922168afe8 Speed up fonthashint matching
When we don't need to differentiate between weak and strong,
we can exit the loop in FcCompareValueList once we found a
best match.

This change helps reducing the amount of list walking we do
for fonthashint, where careless config files end up creating
lists with ~100 booleans :( We don't want to walk all those
to the end, over and over again.

We are already special-casing family, and the only other case
where weak != strong, PostScript names, doesn't have long lists
of values, so the limitation to weak == strong doesn't matter
much in practice.
2020-08-25 12:15:18 -04:00
Matthias Clasen 1b0cb23adc Add a shortcut for FcQualAny matching
When checking whether a test matches a pattern,
we cut the loop short for FcQualAll when we see
the first non-matching value, but for FcQualAny
we were always walking the full list. This patch
cuts the loop short for FcQualAny when we see the
first matching value.
2020-08-25 12:15:18 -04:00
Matthias Clasen 8022ab4aff Use a hash table for family matching
With the way typical font configurations look, matching the lists
of families is the bottleneck for both FcFontMatch and FcFontSort.
After installing the Noto fonts on my system, an innocent match
pattern like "Cantarell 14" turns into a monster with a list of
300 family names after calling FcConfigSubstitute().

With this setup, every FcFontSort call takes 80-100 ms, which is
entirely incompatible with using FcFontSort for anything interactive.
And many font choosers render every font in itself, causing on average
one FcFontSort call per font.

On my system, it takes more than 20 seconds to open the GTK font
chooser dialog, with frequent stalls when scrolling.

This patch special-cases font families and replaces the list
walking for comparison with a hash table lookup. With this
patch, the FcFontSort time goes to ~10ms per call. Which is
still not good enough for calling it dozens of times when
scrolling, but a significant improvement.
2020-08-25 12:15:18 -04:00
Matthias Clasen 055843631b Add a hash function for families
Add a hash function that behaves like family
comparison: ignoring case and blanks. This
will be used to replace the list walking for
finding family matches with a hash table.
2020-08-25 12:10:53 -04:00
Matthias Clasen 46d818df26 Special-case some of the string walking code
Make variants of FcStrCaseWalkerNext for the two
common cases, delim == NULL and delim == " ", to
speed things up.

These are inner loops, and having the conditions
as simple as possible helps.
2020-08-25 12:10:53 -04:00
Matthias Clasen de73d6c51a Avoid a crash in FcPatternHash with ranges
When a cached pattern contains a range,
FcPatternHash will crash.

Fixes #254.
2020-08-23 11:28:30 -04:00
Jan Tojnar 9133e799b5 Turn unknown attributes into warning
As far as I can tell, fontconfig can recover from encountering an unknown attribute.
And unknown elements already print a warning instead of an error, so let's make this a warning too.
2020-08-18 04:13:21 +00:00
Akira TAGOH a53f79b4a2 Fix build issues regarding formatter for Win32
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/248
2020-08-06 13:02:00 +09:00
Tim-Philipp Müller 57a224f51d Add Meson build system
See https://mesonbuild.com
2020-07-31 07:26:11 +00:00
Tim-Philipp Müller 03aa12c75e Guard dirent.h includes
Might not be available on Windows.
2020-07-27 13:43:23 +00:00
Alan Coopersmith 9bc88933b2 Fix some typos/spelling errors
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-07-21 18:42:40 -07:00
Akira TAGOH 437f03299b Fix empty XDG_CACHE_HOME Behavior
Use the default $HOME/.cache one for empty XDG_CACHE_HOME.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/243
2020-07-14 19:48:11 +09:00
Ben Wagner 4a1cf888cf Replace FT_UNUSED with FC_UNUSED.
FreeType is trying to hide FT_UNUSED, so use FC_UNUSED instead.
2020-07-07 10:25:02 -04:00
Tim-Philipp Müller a30e4db967 fccompat: fix build on Windows without unistd.h
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=vs-2019
2020-07-07 03:48:34 +00:00
Tim-Philipp Müller 93e65a8541 Fix build on Windows some more 2020-07-01 20:04:13 +01:00
Tim-Philipp Müller a98b620683 Use FC_PATH_MAX to fix build on Windows 2020-07-01 20:00:57 +01:00
Mathieu Duponchelle 7b293e3292 Some build fixes to support compilation with MSVC on Windows 2020-07-01 20:00:42 +01:00
Akira TAGOH 68d021b634 Add FC_ORDER property into cache
"fontversion" used to be modified to sort out fonts as a technique.
But that lost the original purpose to do the version control between
releases.

This change adds the dedicated property into the cache.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/226
2020-05-25 18:22:55 +09:00
Akira TAGOH fdbd9d13b7 Fix cache conflicts on OSTree based system
mtime isn't reliable to detect updates of fonts on OSTree based system
since they reset mtime to 0 for system files.
Due to this, there are the situation likely to happen where mtime is
newer but content is older.

Fortunately, OSTree based system requires reboot to deploy changes. so
we can assume we won't see any changes on system fonts. so system caches
are always up-to-date. we can ignore meta data for system fonts in
user caches.
2020-05-12 21:06:10 +09:00
Jonathan Kew 6edaaa4d18 Set name_mapping to NULL after freeing
To avoid risk of double-free.
    
Fixes #237.
2020-04-28 16:50:49 +00:00
Akira TAGOH 6f6b397802 Fix assertion in FcCacheFini() again
The previous fix in fbc05949ef was wrong. reverting.

When reading older caches, FcDirCacheMapHelper() returns FcFalse and
it became the return value from FcDirCacheProcess() too, which is wrong.
Actually one of calls for FcDirCacheMapHelper() should be successfully
finished and closure should have a valid pointer for cache.

Due to this, the proper finalization process wasn't running against
cache in closure.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/227
2020-03-23 14:08:55 +09:00
Nirbheek Chauhan 6def66164a fcatomic: Fix EXC_BAD_ACCESS on iOS ARM64
iPhone 2.1 was released a long time ago, and the macro for checking
the target iOS SDK version has changed. We can simplify everything and
do a very basic check.
2020-03-19 18:44:36 +09:00
Akira TAGOH d3bfbea7dc Set exact boolean value to color property
This is a regression since 48e9e5f4
2020-02-27 14:25:10 +09:00
Akira TAGOH fbc05949ef Fix assertion in FcFini()
Due to the unproper initialization of `latest_mtime', the duplicate caches
was still in fcCacheChains with no references. which means no one frees
them. thus, the memory leak was happened.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/227
2020-02-26 15:42:21 +09:00
Akira TAGOH 61573ad5f7 Fix memory leaks 2020-02-19 17:05:20 +09:00
Akira TAGOH 71d6866d38 Fix the process substitution doesn't work with FONTCONFIG_FILE
Don't address the real filename when a named pipe is given in FONTCONFIG_FILE.
2020-02-19 14:02:31 +09:00
Akira TAGOH 452be8125f Add proper fullname for named-instances
Try to build a fullname from a family and a style name for a named-instance.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/185
2019-12-09 20:13:38 +09:00
Akira TAGOH 8249f871b3 Don't add a value for FC_FULLNAME in meta face
FC_FULLNAME is affected by variables and could be different
against it. FC_FULLNAME should be dropped from meta face.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/185
2019-11-28 18:08:07 +09:00
Akira TAGOH aa8c8cfa9f Fix potential race condition in FcConfigSetCurrent and FcConfigReference 2019-11-06 14:21:34 +09:00
Akira TAGOH b5bcf61fe7 Use FcConfigReference/Destroy appropriately instead of FcConfigGetCurrent
This may improves to be MT-safe.

Reported at https://bugs.chromium.org/p/chromium/issues/detail?id=1004254
2019-11-01 14:44:47 +09:00
Akira TAGOH a45fc8a332 Fix a memory leak caused by the previous commit 2019-10-31 16:15:25 +09:00
Akira TAGOH c9862b6ea7 Read latest cache in paths
Right now fontconfig uses a cache found first in a path and
cachedirs are the order of the system-wide path and then the user path.
this is due to avoid writing caches into the user path when running as root.

However, changing caches by certain config only, e.g. using <match target="scan">
may not take effect by this behavior, because it may be stored into the user path.

Thus, needing to find the latest cache out from paths.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/182
2019-10-28 17:15:07 +09:00
Akira TAGOH cd51cb241a Take effect sysroot functionality to the default config file
When loading the default config file with FONTCONFIG_SYSROOT,
it fails if no /etc/fonts/fonts.conf is available, even if it is
there where is based on sysroot.

To address this, FcConfig is required to determine the sysroot.
therefore, this change makes FcConfigFilename() deprecated,
use FcConfigGetFilename() instead.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/181
2019-10-21 20:46:09 +09:00
Akira TAGOH 75eadca266 Warn as well if no directory name for cachedir provided
cachedir is used to determine where cache files are stored.
the empty directory will ends up to put them under the top of
directory of XDG_CACHE_HOME. that messes it up and must be avoided.

As a note, if you want to read/write something from the top of
XDG_DATA_HOME (dir) and/or XDG_CACHE_HOME (cachedir),
put "." instead of the empty.

https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/180
2019-10-08 20:12:12 +09:00
Akira TAGOH fcada52291 Do not return FcFalse from FcConfigParseAndLoad*() if complain is set to false
https://bugzilla.redhat.com/show_bug.cgi?id=1744377
2019-08-28 17:48:29 +09:00
Akira TAGOH cb1036a7c7 Affect FC_FONT_HAS_HINT property to score on matcher 2019-08-09 12:22:59 +00:00
Akira TAGOH 505c7c46a5 Improve the performance a bit
This change reduces the call cost of strcmp 1.5 % less.
2019-08-07 12:39:14 +00:00
Akira TAGOH 8c44becd45 Fix failing the check of prep table in some fonts 2019-07-30 11:06:19 +00:00
Akira TAGOH 80047ed8e8 Add FC_FONT_HAS_HINT property to see if font has hinting or not.
This may helps to enable autohint only when font doesn't have any hinting
2019-07-29 10:19:26 +00:00
Akira TAGOH e2f9f28aed Fix a memory leak in FcFreeTypeQuery*()
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/170
2019-07-26 04:59:54 +00:00
Akira TAGOH 1a0391c099 Fix memory leaks 2019-07-23 10:54:36 +00:00
Akira TAGOH 957625bafa Fix the fail on fc-cache
Fallback code to UUID-based cache name was broken.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/169
2019-07-23 10:53:16 +00:00
Akira TAGOH 36f46ba720 FcConfigParseAndLoad*() should returns false on config errors
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/168

Reported by Lawrence D'Oliveiro
2019-07-22 05:35:21 +00:00
Akira TAGOH 2960391699 Add English name first into a cache
In some cases, non-English languages might appears first in current order.
and when having English name with non-English language ID like Google Noto CJK TC,
English name with English language ID will be dropped due to duplicate.

This fixes that issue.
2019-07-09 06:40:29 +00:00
Akira TAGOH a57f22bf6d Fix a typo 2019-07-09 05:54:32 +00:00
Akira TAGOH cb3e6ff4d7 Improve the performance a bit 2019-07-08 13:26:49 +00:00
Akira TAGOH 322131f433 Fix a crash when running with FC_DEBUG=256
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/167
2019-07-02 04:59:52 +00:00
Akira TAGOH 83840fd1fa Fix obtaining real path from pre-defined names for Win32
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/166
2019-06-26 15:28:41 +09:00
Egmont Koblinger f2d4291d12 Fix the linear interpolation during weight mapping
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/164
2019-06-19 11:55:06 +02:00
Akira TAGOH c0dc76268b Fix a typo on masking face id
Most of functionality should be moved to FcFreeTypeQueryAll()
for varfonts now though, if doing the same to FcFreeTypeQuery()
returns Null pattern because of inappropriate masking.

This might be not that big deal for varfonts support. but

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/162

Reported by Kevin Scott
2019-06-18 05:58:17 +00:00
Akira TAGOH 66b0af41b8 Fix endianness on generating MD5 cache name 2019-06-10 10:57:05 +00:00
Akira TAGOH 76e899700b No need to remap for uuid based 2019-04-04 11:57:13 +00:00
Akira TAGOH 7f61838435 Fallback uuid-based name to read a cache if no MD5-based cache available 2019-04-04 10:59:47 +00:00
Akira TAGOH 13d2a47d79 Fix unexpected cache name by double-slash in path 2019-04-04 06:47:34 +00:00
Akira TAGOH faec0b51db Don't show salt in debugging message if salt is null 2019-04-04 05:04:17 +00:00
Akira TAGOH 91114d18c3 Allow overriding salt with new one coming later 2019-04-03 12:02:09 +00:00
Akira TAGOH d1acc73f23 Oops, Terminate string 2019-04-03 12:02:09 +00:00
Akira TAGOH fc9f706ecb Add some debugging output 2019-04-03 12:02:09 +00:00
Akira TAGOH cb1df8cb28 Don't warn if path can't be converted with prefix 2019-04-03 12:02:09 +00:00
Akira TAGOH ad3f335ccf Fix make check fail on MinGW again 2019-04-03 12:02:09 +00:00
Akira TAGOH 8e2c85fe81 Use alternative function for realpath on Win32 2019-04-03 12:02:09 +00:00
Akira TAGOH b1bcc0cbb2 Fix build issues on MinGW 2019-04-03 12:02:09 +00:00
Akira TAGOH 2e8ce63514 Add salt attribute to dir and remap-dir elements
'salt' attribute affects a cache filename to generate different name from directory name.
This is useful when sharing caches with host on sandbox and/or give a filename differently:

    <dir salt="randomdata">/usr/share/fonts</dir>
    <remap-dir as-path="/usr/share/fonts" salt="salt for /usr/share/fonts on host">/run/host/fonts</remap-dir>

Applications can read caches as-is for fonts on /run/host/fonts where is mounted from host.
and write a cache for their own fonts on /usr/share/fonts with different name.
2019-04-03 12:02:09 +00:00
Akira TAGOH def1d00036 Add reset-dirs element
This element removes all of fonts directories where added by
dir elements. it is useful to override fonts dirs from system
to their own dirs only.
2019-04-03 12:02:09 +00:00
Akira TAGOH acc017e672 Drop unnecessary line to include uuid.h 2019-04-03 12:02:09 +00:00
Akira TAGOH 2e09c62ba1 Trim the last slash
This fixes MD5 wrongly generated.
2019-04-03 12:02:09 +00:00
Akira TAGOH a563a1802e Add new element remap-dir instead of extending dir element 2019-04-03 12:02:09 +00:00
Akira TAGOH 500e77a01d Drop a 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
Keith Packard 67e9c12c5a Fetch FONTCONFIG_SYSROOT in FcConfigCreate
This saves the value of FONTCONFIG_SYSROOT in the config instead of
having to call getenv every time we need this value.

This also uses 'realpath' to construct a canonical path to sysroot,
eliminating symlinks and relative path names.

Signed-off-by: Keith Packard <keithp@keithp.com>
2019-04-03 12:02:09 +00:00