Commit Graph

2420 Commits

Author SHA1 Message Date
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
Akira TAGOH abbd87ac2c Add some tweaks into runtest.sh to see progress 2020-08-25 12:50:27 +09: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 a5fd5dc471 meson: print configuration summary()
Fixes #249
2020-07-31 15:17:09 +01: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
Akira TAGOH 97d709e888 Fix a typo in doc/confdir.sgml.in
Since changes introduced by e181ab4d
2020-07-02 13:55:04 +09: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
Tim-Philipp Müller 344925fc53 doc: fix FcPatternFilter documentation
The second argument should be ARG2 not ARG1.
2020-07-01 10:49:20 +01:00
Jan Tojnar 37c7c74874 Drop elements with its namespace from fonts.conf.in
This appears to have been forgotten in https://gitlab.freedesktop.org/fontconfig/fontconfig/merge_requests/97
2020-06-24 00:00:12 +00:00
Akira TAGOH fcb0420281 Drop Bitstream Vera fonts from 60-latin.conf
Bitstream Vera fonts seems broken so dropped them there.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/26
2020-06-02 17:33:15 +09: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 528b17b283 Drop elements with its namespace from conf
The translation related elements are now provided by separate files
fontconfig.its and fontconfig.loc. we don't need to have it in conf
anymore.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/234
2020-05-25 10:44:05 +09:00
Akira TAGOH 6d4f937898 Drop unmaintained files 2020-05-19 13:53:22 +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 f3e049967e Fix errors on shellcheck
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/235
2020-04-10 17:27:15 +09:00
Nicolas Mailhot 9c46ef4aac Use an URN for DTD ID
XML tools interpret “fonts.dtd” as a relative path.

Unfortunately, that can not work now that the configuration is spread over
multiple system-dependant directories, without a common relative path to this
file. And, an absolute path can not be defined in a system-independant way.
System independance is a requirement to share config files between systems.

Therefore, replace the broken relative path by a formal URN, that will work the
same way on all systems, without network access.

This makes the DTD registerable with commands like:
$ xmlcatalog --noout --add system \
                           "urn:fontconfig:fonts.dtd" \
                           "file:///usr/share/xml/fontconfig/fonts.dtd" \
                           /etc/xml/catalog

That enables easy config file checking:
$ xmllint --loaddtd ${config_file} >/dev/null
2020-03-28 15:01:35 +01: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 8bddcb1137 Fix a test fail when no bwrap was available
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/201
2019-12-05 19:55:06 +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
Jan Tojnar a4aa66a858 Correct reset-dirs in DTD
Empty elements need to be declared as such in well-formed DTDs.
2019-11-20 02:13:58 +00:00
Akira TAGOH 23ab038281 Fix gcc warnings with -Wpointer-sign
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/184
2019-11-06 20:28:58 +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
Jan Tojnar 65087ac7ce
conf: Add JoyPixels emoji font
It is a successor of EmojiOne.

https://www.joypixels.com/
2019-08-29 12:51:43 +02: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