Commit Graph

95 Commits

Author SHA1 Message Date
Akira TAGOH d62d984e2b Revert constructing fullname property from family and style properties
This seems making a regression in Java. we will revisit this issue later.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/277
2021-06-28 17:37:23 +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 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
Tim-Philipp Müller 03aa12c75e Guard dirent.h includes
Might not be available on Windows.
2020-07-27 13:43:23 +00: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
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 5f12f564f8 Do not remove UUID file when a scanned directory is empty
Because FcDirCacheDeleteUUID does not reset the modification time on
the directory, and because FcDirCacheRead unconditionally creates the
UUID file each time it is run, any empty directory in the cache will
get its timestamp changed each time the cache for that directory is
read.

Instead, just leave the UUID file around as it is harmless.

The alternative would be to only create the UUID file after the cache
has been created and the directory has been discovered to be
non-empty, but that would delay the creation of the UUID file.

Signed-off-by: Keith Packard <keithp@keithp.com>
2018-10-25 16:02:55 +09: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
Akira TAGOH 767e3aa7c5 Fix compiler warnings 2018-01-04 20:37:26 +09:00
Akira TAGOH dd21876e64 Update .uuid only when -r is given but not -f. 2017-12-18 12:11:21 +09:00
Akira TAGOH 8f88b1c47c abstract hash table functions 2017-11-20 17:37:22 +05:30
Akira TAGOH 7b48fd3dd4 Use uuid-based cache filename if uuid is assigned to dirs 2017-11-20 17:37:22 +05:30
Behdad Esfahbod 27a6a299e0 Add FcFreeTypeQueryAll()
Like FcFreeTypeQuery(), but adds patterns for all fonts found, including named
instances of variable fonts.  If id is -1, then all collection faces are queried.
Returns number of fonts added.

This merges the same face loop that was in fc-query. and fcdir.c.

Needs documentation update.
2017-09-12 17:17:05 -04:00
Behdad Esfahbod 8f4c4d278d Remove blanks facility from the library
XML parser does not accept it anymore either.
2017-09-12 17:02:27 -04:00
Masamichi Hosoda 79058f4e91 Bug 99360 - Fix cache file update on MinGW
On Windows, opened or locked files cannot be removed.
Since fontconfig locked an old cache file while updating the file,
fontconfig failed to replace the file with updated file on Windows.

This patch makes fontconfig does not lock the old cache file
while updating it on Windows.
2017-06-01 11:46:07 +09:00
Akira TAGOH d179cbc253 Revert "Workaround another race condition issue"
This reverts commit f44bfad235.
2016-04-06 14:39:15 +09:00
Behdad Esfahbod 27d61f1ddc [GX] Enumerate all named-instances in TrueType GX fonts 2016-03-08 13:39:05 -08:00
Behdad Esfahbod 28f62d1bb8 Call FcFreeTypeQueryFace() from fcdir.c, instead of FcFreeTypeQuery()
Need for upcoming work.  No functional change expected.
2016-03-08 13:39:05 -08:00
Patrick Haller d570a841a2 Optimizations in FcStrSet
Applied optimizations:
- skip duplicate check in FcStrSetAppend for values originating from readdir()
- grow FcStrSet in 64-element bulks for local FcStrSets (FcConfig layout unaltered)

Starting gedit is measured to

                        Unoptimized     Optimized
user[s]                         0,806         0,579
sys[s]                          0,062         0,062
Total Instr Fetch Cost: 1.658.683.750   895.069.820
Cachegrind D Refs:        513.917.619   312.000.436
Cachegrind Dl Misses:       8.605.632     4.954.639
2016-01-12 10:42:40 +09:00
Akira TAGOH ad9f588050 Fix the broken cache more.
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
2015-08-14 17:19:29 +09:00
Akira TAGOH c965c9f677 Bug 89617 - FcConfigAppFontAddFile() returns false on any font file
Prior to the change of 32ac7c75e8
FcConfigAppFontAddFile() always returned FcTrue no matter what
fonts was added. after that, it always returned FcFalse because
adding a font doesn't add any subdirs with FcFileScanConfig().
so changing that to simply ignore it.

Also fixing it to return FcFalse if non-fonts was added, i.e.
FcFreeTypeQuery() fails.

https://bugs.freedesktop.org/show_bug.cgi?id=89617
2015-03-23 13:31:57 +09:00
Akira TAGOH 7301f2f028 Remove the dead code 2015-03-23 13:18:49 +09:00
Akira TAGOH 6c3c2603b9 Fix a segfault
introduced by the previous commit d17f556153
2014-06-18 19:13:06 +09:00
Akira TAGOH d17f556153 Read the config files and fonts on the sysroot when --sysroot is given to fc-cache
Fix for e96d776088

https://bugs.freedesktop.org/show_bug.cgi?id=59456
2014-06-17 20:11:02 +09:00
Akira TAGOH f44bfad235 Workaround another race condition issue
See https://bugzilla.redhat.com/show_bug.cgi?id=921706
2014-06-05 19:06:02 +09:00
Akira TAGOH 7a6622f25c Improve the performance issue on rescanning directories 2013-12-20 11:57:16 +09:00
Akira TAGOH 041deb0cc5 warn deprecated only when migration failed 2013-08-07 12:05:32 +09:00
Behdad Esfahbod 83d8019011 Fix unused-parameter warnings 2012-12-29 22:32:56 -05:00
Akira TAGOH 959442bca1 Fix a typo 2012-12-06 19:49:05 +09:00
Akira TAGOH 9231545c6b Do not show the deprecation warning if it is a symlink 2012-12-05 18:13:25 +09:00
Mikhail Gusarov 0ac6c98294 Fix cache aging for fonts on FAT filesystem under Linux
Windows does not update mtime of directory on FAT filesystem when
file is added to it or removed from it. Fontconfig uses mtime of
directory to check cache file aging and hence fails to detect
newly added or recently removed files.

This changeset detects FAT filesystem (currently implemented for
Linux) and adds generating checksum of directory entries instead
of using mtime which guarantees proper cache rebuild.

For non-FAT filesystems this patch adds single syscall per directory
which is negligeable overhead.

This fixes bug https://bugs.freedesktop.org/show_bug.cgi?id=25535

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
2012-05-28 16:46:04 +09:00
Akira TAGOH ea1c6ea337 Fix a memory leak in FcDirScanConfig() 2012-03-27 21:06:36 +09:00
Mike Frysinger e3a66c2937 delete unused variables
Newer gcc is better at detecting set-but-unused variables.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-02-21 14:15:58 -05:00
Behdad Esfahbod 0fcf866d44 Bug 36577 - Updating cache with no-bitmaps disables bitmap fonts...
Do not remove blacklisted fonts during cache generation.  We already
apply the blacklist when reading the caches.  The idea always has been
that the config should not affect caches built, although that design
was tarnished with the introduction of target="scan" configurations.
2011-06-20 11:07:56 -04:00
Behdad Esfahbod c21fb9ac27 Always define FcStat as a function
Such that first arg is const char *.  We also need to make more changes
in that function as part of some other bug.
2011-03-14 18:49:21 -03:00
Behdad Esfahbod 5aaf466d38 Cleanup copyright notices to replace "Keith Packard" with "the author(s)" 2010-11-10 16:45:42 -05:00
Behdad Esfahbod 594dcef0f3 Remove all training whitespaces 2010-04-12 12:19:05 -04:00
Behdad Esfahbod 5e544b32d8 Use default config in FcFileScan() and FcDirScan()
Before a NULL config was passed down adn essentially FcFileScan was
equivalent to FcFreeTypeQuery.  Now fc-scan tool correctly applies
the configuration to the scanned patterns.
2009-09-06 22:10:22 -04:00
Behdad Esfahbod 3074a73b41 Replace 'KEITH PACKARD' with 'THE AUTHOR(S)' in license text in all files 2009-03-13 17:59:28 -04:00
Behdad Esfahbod 4074fd254e Revive FcConfigScan() (bug #17121)
FcConfigScan() with parameters cache=NULL and force=FcTrue can be used
to scan font dirs without any caching side effect.
2009-02-13 16:54:06 -08:00
Behdad Esfahbod f69db8d49c Consistently use FcStat() over stat() in all places 2009-02-13 16:54:01 -08:00
Behdad Esfahbod 317b849215 Replace RCS Id tags with the file name 2009-02-13 16:53:55 -08:00
Keith Packard db6f19f13b Store font directory mtime in cache file.
Instead of relying on mtime ordering between a directory and its associated
cache file, write the directory mtime into the cache file itself. This makes
cache file checks more reliable across file systems.

This change is made in a way that old programs can use new cache files, but
new programs will need new cache files.
2007-10-18 04:13:51 -07:00
Keith Packard 0f963b0d3e Segfault scanning non-font files. Disallow scan edit of user vars. (#8767)
Missing NULL font check before attempting to edit scanned pattern.
Also, <match target="scan"> rules are now checked to ensure all
edited variables are in the predefined set; otherwise, the resulting
cache files will not be stable.
2006-12-02 13:57:45 -08:00
Keith Packard 97c3d5b692 Reimplement FcConfigAppFontAddDir; function was lost in 2.4.0.
With the cache restructuring of 2.4.0, the ability to add
application-specific font files and directories was accidentally lost.
Reimplement this using by sharing the logic used to load configured font
directories.
2006-09-15 00:23:40 -07:00
Keith Packard 23816bf9ac Eliminate .so PLT entries for local symbols. (thanks to Arjan van de Ven)
Using a simple shell script that processes the public headers, two header
files are constructed that map public symbols to hidden internal aliases
avoiding the assocated PLT entry for referring to a public symbol.

A few mistakes in the FcPrivate/FcPublic annotations were also discovered
through this process
2006-09-05 02:24:01 -07:00
Keith Packard c2c6976d1a Add FcMatchScan to resolve Delicious font matching issues (bug #6769)
The Delicious family includes one named Delicious Heavy, a bold variant
which is unfortunately marked as having normal weight. Because the family
name is 'Delicious', fontconfig accidentally selects this font instead of
the normal weight variant. The fix here rewrites the scanned data by running
the scanned pattern through a new substitution sequence tagged with
<match target=scan>; a sample for the Delicious family is included to
demonstrate how it works (and fix Delicious at the same time).

Also added was a new match predicate -- the 'decorative' predicate which is
automatically detected in fonts by searching style names for key decorative
phrases like SmallCaps, Shadow, Embosed and Antiqua. Suggestions for
additional decorative key words are welcome. This should have little effect
on font matching except when two fonts share the same characteristics except
for this value.
2006-09-02 17:52:12 -07:00
Keith Packard 9b511b2905 Unify directory canonicalization into FcStrAddFilename.
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.
2006-09-02 14:52:37 -07:00
Keith Packard bc5e487f2a Pass directory information around in FcCache structure. Freeze charsets.
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.
2006-09-01 01:15:14 -07:00
Keith Packard 2d3387fd72 Skip broken caches. Cache files are auto-written, don't rewrite in fc-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.
2006-08-30 21:59:53 -07:00