Commit Graph

1153 Commits

Author SHA1 Message Date
Akira TAGOH 14c23a5715 Fix double-free 2018-05-25 15:20:10 +09:00
Alexander Larsson 3ea70f9368 Cache: Remove alias_table
There is really no need for this anymore

https://bugs.freedesktop.org/show_bug.cgi?id=106618
2018-05-25 14:43:06 +09:00
Alexander Larsson c42402d0b8 Cache: Rewrite relocated paths in earlier
This changes the rewriting of the FC_FILE values for relocated caches to an earlier stage
while reading the cache. This is better, because it means all APIs will report the
rewritten paths, not just the once that use the list apis.

We do this by detecting the relocated case and duplicating the FcPattern and FcPatternElm
in an cache allocation (which will die with the cache) and then reusing the FcValueLists
from the cache.

This means that in the rewritten case we will use some more memory, but not the full
size of the cache. In a test here I had 800k of relocated caches, but ~200k of wasted
on duplicating the objects.

This should fix https://bugs.freedesktop.org/show_bug.cgi?id=106618
2018-05-25 14:42:52 +09:00
Alexander Larsson a63b9c622e Add FcCacheAllocate() helper
This lets you allocate a chunk of memory that will be freed when the cache
is freed.

https://bugs.freedesktop.org/show_bug.cgi?id=106618
2018-05-25 14:42:05 +09:00
Akira TAGOH 94080c3d48 Fix -Wstringop-truncation warning 2018-05-25 14:02:58 +09:00
Akira TAGOH 684c3ce685 Fix leaks 2018-05-25 13:51:10 +09:00
Chris Lamb f098adac54 Ensure cache checksums are deterministic
Whilst working on the Reproducible Builds[0] effort, we noticed that
fontconfig generates unreproducible cache files.

This is due to fc-cache uses the modification timestamps of each
directory in the "checksum" and "checksum_nano" members of the _FcCache
struct. This is so that it can identify which cache files are valid
and/or require regeneration.

This patch changes the behaviour of the checksum calculations to prefer
the value of the SOURCE_DATE_EPOCH[1] environment variable over the
directory's own mtime. This variable can then be exported by build
systems to ensure reproducible output.

If SOURCE_DATE_EPOCH is not set or is newer than the mtime of the
directory, the existing behaviour is unchanged.

This work was sponsored by Tails[2].

 [0] https://reproducible-builds.org/
 [1] https://reproducible-builds.org/specs/source-date-epoch/
 [2] https://tails.boum.org/
2018-05-16 16:06:46 +09:00
Akira TAGOH 0b85e77ede Bug 106459 - fc-cache doesn't use -y option for .uuid files
https://bugs.freedesktop.org/show_bug.cgi?id=106459
2018-05-13 16:21:58 +09:00
Akira TAGOH cfb21c7d85 Bug 106497 - better error description when problem reading font configuration
https://bugs.freedesktop.org/show_bug.cgi?id=106497
2018-05-13 14:48:10 +09:00
Akira TAGOH 307639cff1 Bug 43367 - RFE: iterator to peek objects in FcPattern
Add various APIs to obtain things in FcPattern through the iterator

https://bugs.freedesktop.org/show_bug.cgi?id=43367
2018-05-11 20:48:30 +09:00
Tom Anderson 730deada8c Add FONTCONFIG_SYSROOT environment variable 2018-05-05 17:57:21 +09:00
Tom Anderson 7ad010e80b Use realfilename for FcOpen in _FcConfigParse
realfilename is the file name after sysroot adjustments.  It should be used
instead of filename in the call to FcOpen() which forwards the name directly to
open().

Though I don't explicitly request a sysroot, I was getting error messages saying
"failed reading config file".  This CL fixes the error spam.
2018-04-17 13:49:41 +09:00
Tom Anderson c60ed9ef66 Fix undefined-shift UBSAN errors
The expression "1 << 31" will cause UBSAN to complain with this error message:
runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

The same operation on unsigned types is fine, however.  This CL replaces the
strings "1 <<" with "1U <<".
2018-04-16 15:23:20 +02:00
Behdad Esfahbod a8a6efa805 Share name-mapping across instances
Continuation of previous commit.

Makes scanning Voto Serif GX fast again.
2018-03-31 19:19:36 +02:00
Behdad Esfahbod fa13f8835c Fix name scanning
In 161c738 I switched from linear name scanning to binary searching.
That, however, ignored the fact that there might be more than one
name table entry for each pair we want to query.

To fix that and retain bsearch, I now get all name entries first,
sort them, and use for bsearching.

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

This makes scaning Voto Serif GX twice slower though, since we are
creating and sorting the list for each instance. In the next commit,
I'll share this list across different instances to fix this.
2018-03-31 18:36:20 +02:00
Akira TAGOH 31269e3589 Do not ship fcobjshash.h 2018-03-28 18:54:37 +09:00
Akira TAGOH 98eaef69af Leave the locale setting to applications
https://bugs.freedesktop.org/show_bug.cgi?id=105492
2018-03-15 12:36:46 +09:00
Akira TAGOH 4699406a68 Add the value of the constant name to the implicit object in the pattern
For objects which has been changed the object type to FcTypeRange.

https://bugs.freedesktop.org/show_bug.cgi?id=105415
2018-03-14 18:32:30 +09:00
Akira TAGOH 923b5be626 Do not override locale if already set by app
https://bugs.freedesktop.org/show_bug.cgi?id=105492
2018-03-14 12:35:05 +09:00
Akira TAGOH 198358dd8f Allow the constant names in the range
https://bugs.freedesktop.org/show_bug.cgi?id=105415
2018-03-12 11:49:58 +09:00
Akira TAGOH 07bd14c5c7 Fix the build issue again on MinGW with enabling nls 2018-03-09 11:55:43 +09:00
Akira TAGOH 8c96285d21 Initialize an array explicitly
Patch from Kurt Kartaltepe
2018-03-02 13:30:00 +09:00
Akira TAGOH e300d863f5 Fix a build issue on MinGW with enabling nls 2018-03-02 13:19:38 +09:00
Akira TAGOH 0394cb7829 Ensure the user config dir is available in the list of config dirs on the fallback config 2018-02-05 13:31:00 +09:00
Akira TAGOH 34b5c949d5 Do not mix up font dirs into the list of config dirs 2018-02-05 12:47:01 +09:00
Olivier Crête 5710377301 Fix cross-compilation by passing CPPFLAGS to CPP 2018-02-01 20:11:19 +09:00
Akira TAGOH ef748b39e0 Take effects on dir, cachedir, acceptfont, and rejectfont only when loading
Those elements takes effects immediately during parsing config files so makes them conditional to ignore on scanning.
2018-01-23 22:27:17 +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
Behdad Esfahbod fd2ad1147a Fix undefined-behavior signed shifts 2018-01-09 11:03:31 +01:00
Behdad Esfahbod 94683a1255 Use FT_Done_MM_Var if available 2018-01-08 09:55:41 +00:00
Akira TAGOH 97488fd725 export GETTEXTDATADIR to refer the local .its/.loc file instead of using --its option 2018-01-06 18:55:00 +09:00
Behdad Esfahbod 030e2e4e94 Fix leak 2018-01-05 14:33:41 +00:00
Akira TAGOH a2e0ebf392 Add files to enable ITS support in gettext 2018-01-05 18:23:08 +09:00
Tom Anderson b8a225b3c3 Allow overriding symbol visibility.
Fontconfig symbols were hardcoded to be either hidden or exported.  This patch
adds configurable symbol visibility.  This is useful for projects that want to
do in-tree fontconfig builds and not export any symbols, otherwise they would
conflict with the system library's symbols

Chromium is a project that does in-tree fontconfig builds, and the workaround
currently used is "#define visibility(x) // nothing" [1] and building with
"-fvisibility=hidden".
[1] https://cs.chromium.org/chromium/src/third_party/fontconfig/BUILD.gn?rcl=ce146f1f300988c960e1eecf8a61b238d6fd7f7f&l=62
2018-01-04 15:24:16 +00:00
Behdad Esfahbod 37fb4a989e Support FC_WIDTH as double as well 2018-01-04 15:22:06 +00:00
Behdad Esfahbod 1fa9cb78c1 Remove hack for OS/2 weights 1..9 2018-01-04 15:22:06 +00:00
Akira TAGOH 3642d71724 Add FcReadLink to wrap up readlink impl. 2018-01-04 20:39:14 +09:00
Akira TAGOH 767e3aa7c5 Fix compiler warnings 2018-01-04 20:37:26 +09:00
Behdad Esfahbod 706535e107 Add FcWeightTo/FromOpenTypeDouble()
No idea why I didn't add these as double to begin with.
2018-01-03 15:59:56 +00:00
Akira TAGOH 97898b1158 Fix the mis-ordering of ruleset evaluation in a file with include element 2018-01-03 22:15:11 +09:00
Behdad Esfahbod f8e22fd646 Put back accidentally removed code 2017-12-20 12:21:20 -05:00
Behdad Esfahbod 6d1d44d5ec Let pattern FC_FONT_VARIATIONS override standard axis variations
Ie. flip the merge order.
2017-12-19 15:51:16 -05:00
Behdad Esfahbod 650b051a25 Set font-variations settings for standard axes in variable fonts
This is the last piece of the puzzle for variable-font support in
fontconfig.  This takes care of automatically setting the variation
settings when user requests a weight / width / size that has variation
in the matched font.
2017-12-19 15:04:25 -05:00
Behdad Esfahbod 57ff677b1b Remove a debug abort()
Ouch!
2017-12-18 22:18:03 -05:00
Akira TAGOH aa85a2b3b6 Try to get current instance of FcConfig as far as possible 2017-12-19 12:16:48 +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
Behdad Esfahbod 7ca28c2fed Don't crash
Not proper fix necessarily. But fixes this crash:
https://bugs.freedesktop.org/show_bug.cgi?id=101889#c81
2017-12-18 21:22:21 -05:00
Akira TAGOH e83f8777d5 Disable uuid related code on Win32 2017-12-18 21:45:13 +09:00
Akira TAGOH 182186e53a Do not update mtime with creating .uuid 2017-12-18 21:26:29 +09:00
Akira TAGOH 8ab4d67995 Replace uuid in the table properly when -r 2017-12-18 20:05:14 +09:00