Commit Graph

2430 Commits

Author SHA1 Message Date
Ben Wagner 8d3425b8b8 Back FcSerialize with open addressing hash table.
Instead of fixed number of buckets with chaining use an open addressing
hash table with linear probing, max load factor 0.75, and a power of two
number of buckets.
2021-11-16 15:48:56 -05:00
Ryan Gonzalez be453bd159 Ensure config.h is always included before stdlib headers
In particular, if an stdlib header goes first, it includes features.h
which only checks _FILE_OFFSET_BITS *once*, meaning that these files end
up compiled *without* _FILE_OFFSET_BITS taking effect, which affects
fcxml's operations in listing directories.

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2021-11-10 19:41:50 -06:00
Akira TAGOH 5841bd012d Fix some testcase fails for 14c265a1
Add an extra code to ignore an error of FT_Get_MM_Var()
only when FT_MM_Var variable isn't used in any case.
2021-11-09 20:42:52 +09:00
Behdad Esfahbod 14c265a10a If a varfont has 'opsz' axis, set FC_SIZE on default instant pattern
Otherwise default-instance pattern would match as an "all sizes",
which would be wrong. See:

https://gitlab.gnome.org/GNOME/pango/-/issues/621#note_1305844
2021-11-09 20:04:52 +09:00
Akira TAGOH ad70d78597 conf.d/60-latin.conf: Make Noto default. 2021-11-08 20:15:29 +09:00
Ben Wagner a204489885 Fix warning about os2->achVendID cannot be NULL
FreeType's TT_OS2::achVendID is a FT_Char[4] array and not a pointer,
so it does not need to be checked for NULL.
2021-10-28 16:17:48 -04:00
Akira TAGOH 877d869904 Add the option to not build fontconfig cache during installation
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/296
2021-10-14 17:52:03 +09:00
Akira TAGOH 1d76699927 Resolves symlinks against <dir prefix="relative">
When a config file is symlinked and obtaining an relative path from it for <dir>,
it behaved like:

$ realpath /path/to/foo.conf
/path/to/realpath/foo.conf
$ FONTCONFIG_FILE=/path/to/foo.conf fc-cache -v
Font directories:
        /path/to/fonts
/path/to/fonts: skipping, existing cache is valid: 1 fonts, 0 dirs
/path/to/cachedir: cleaning cache directory
fc-cache: succeeded

And after this change:

$ FONTCONFIG_FILE=/path/to/foo.conf fc-cache -v
Font directories:
        /path/to/relpath/fonts
/path/to/realpath/fonts: skipping, existing cache is valid: 1 fonts, 0 dirs
/path/to/cachedir: cleaning cache directory
fc-cache: succeeded

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/290
2021-10-11 18:43:12 +09:00
Akira TAGOH 2d17232a45 Fix score estimation for postscriptname
Before this fix:
$ fc-match :postscriptname=LiberationSans
LiberationSansNarrow.ttf: "Liberation Sans Narrow" "Regular"

After this fix:
$ fc-match :postscriptname=LiberationSans
LiberationSans-Regular.ttf: "Liberation Sans" "Regular"

See https://bugzilla.redhat.com/show_bug.cgi?id=1946871
2021-10-08 18:30:09 +09:00
Ryan Schmidt 889097353e Fix FC_DEFAULT_FONTS on macOS and with BSD sed
Fix processing of FC_DEFAULT_FONTS when it contains multiple comma-
separated values (i.e. on macOS/Darwin) and fix inserting it into
fonts.conf when using BSD sed.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/287
2021-10-05 08:51:52 +00:00
Ben Wagner 6e414d61c7 Extend test thread args lifetime
The argument passed to each thread in test-pthread.c indicates a thread
number to report when finished. This value is read out by the thread
into a local variable early in the thread's execution. Currently, the
address passed as this argument is the address of a loop local. However,
it is possible that the created thread will not be scheduled to run or
will not read the argument before the thread creation loop finishes and
the local is destroyed. This can lead to odd behavior, usually observed
as multiple threads reporting the same thread_num.

Fix this issue by storing the thread arguments in a parallel array to
the array of threads. This ensures that the thread arguments are in
scope as long as the threads themselves.

Discovered with tests/test-pthread with AddressSanitizer enabled.
2021-09-06 04:06:16 +00:00
Ben Wagner efc71a3c13 Free local FcCache lock on contention
If two threads attempt to create the FcCache lock in lock_cache at the
same time, both threads may create and initialize a local FcMutex. One
thread will atomically make cache_lock point to its FcMutex. The other
thread currently calls FcMutexFinish on the local lock, but does not
free it. Change this behavior to free the unused lock.

Found with test/test-pthread on an LeakSanitizer enabled build.
2021-09-06 03:20:31 +00:00
Ben Wagner 6e68763085 Add memory order constraints to C11 atomics
Reduce the strength of the C11 atomics from memory_order_seq_cst to the
actually required memory order constraints for each operation. In
addition to reflecting the already documented memory order constraints,
this should allow for better code generation.
2021-08-31 12:38:50 -04:00
Akira TAGOH 57032f489b Fix a memory leak when trying to open a non-existing file
https://bugzilla.redhat.com/show_bug.cgi?id=1914716
2021-08-25 15:52:53 +09:00
Akira TAGOH c7891755cb Reflect matching results to binding in FcPattern
This change allows applications to see what property was matched perfectly
and help to filter out for their needs.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/294
2021-08-24 19:32:09 +09:00
Akira TAGOH 5d84745e72 Bump the cache version to 8
Bump the cache version to avoid unexpected behavior in
older version of fontconfig.

There was no real incompatible features introduced in a cache.
But the older version of fontconfig can't deal with variable fonts
and then it failed. To avoid this breakage, you may want to choose
one of options like:

1) Applying this change to fontconfig in host and remove all the
fontconfig caches and then regenerate them by fc-cache linked with
older one and new one. or simply run applications.
You'll see two versions of caches in the cache directories.

2) Remove variable fonts on system and remove all the fontconfig
caches too. then regenerate caches. You'll still see one version of
caches there but without the entries of variable fonts.

After that, the problem should be gone.

https://bugzilla.redhat.com/show_bug.cgi?id=1981500
2021-08-24 18:28:26 +09:00
Alex Richardson 92ed966b74 FcCharSetPutLeaf(): Fix missing move of new_leaves contents
If the `realloc(numbers)` call fails, shrinking the leaves allocation
back to the old size is not guaranteed to return the old pointer value.
While this might be the case with some malloc() implementations, realloc()
could also just mark the following area as free.
To make this less error-prone, we grow numbers first and then grow leaves
since the numbers content does not need to be relocated, but leaves does.

See https://bugs.freedesktop.org/show_bug.cgi?id=90867
2021-08-18 10:36:47 +01:00
Akira TAGOH e1c7c6d744 Enable 11-lcdfilter-default.conf by default
Some applications needs this enabled by default on non-GNOME desktops.

reference: https://bugzilla.redhat.com/show_bug.cgi?id=1965684
2021-07-20 11:01:43 +00:00
Alex Richardson 012ffaac75 Add support for C11 stdatomic atomics
This fixes deprecation warnings when building for macOS >= 10.12 systems.
Additionally, using stdatomic.h (or the more modern __atomic_ builtins)
is required when targeting CHERI-enabled architectures such as
CHERI-RISC-V or Arm's Morello since the compiler rejects __sync_* atomic
for pointer types (they only work with integers).
2021-07-20 09:32:52 +01:00
Alex Richardson ab4761ff87 fcint: add casts to allow building with stricter compilers
When targeting CHERI, casts between pointers and integers must use
(u)intptr_t. uintptr_t values contains pointer bounds (and additional
metadata), whereas other integer types do not. This change also adds a
cast to FcOffsetToPtr() to silence a compiler warning that triggers if
the compiler cannot statically infer which side of an arithmetic operation
is the pointer operand and which one is the offset/mask.
2021-07-20 03:31:47 +00:00
Ryan Schmidt 3a7ad1b49f Restore fcatomic compatibility with Mac OS X 10.4.
Reverts the part of 6def66164a that
removed the fc_atomic_ptr_cmpexch compatibility code for systems earlier
than Mac OS X 10.5.

Reverts the part of 447b9ccc7d that moved
the definition of fc_atomic_ptr_get into the Mac OS X > 10.4 block. That
code is still needed on 10.4 and is implemented using functions that are
available on 10.4.

Compare against MAC_OS_X_VERSION_MIN_REQUIRED using a number not a
constant because the constant is not available on earlier SDKs.
2021-07-19 07:17:34 +00:00
Ryan Schmidt 8b3de9bd7f Fix run-test.sh to work with BSD mktemp
Avoid the GNU-specific --tmpdir flag to mkdir and always prefer to use
the directory specified in TMPDIR rather than /tmp.

See https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/288
2021-07-14 04:34:15 +00:00
Ryan Schmidt 6b67ab1c79 Remove Bugzilla references 2021-07-14 03:35:48 +00:00
Ryan Schmidt 8f56421e5f Avoid PCRE syntax when using grep
Avoid PCRE syntax when using grep because some versions of grep don't
support that.
2021-07-08 16:09:19 -05:00
Akira TAGOH 4d43f84188 Do not set different score to non-string values
Non-string values in a cache is supposed to choose one from them.
Due to the change of da1c9f7a, there was a regression on scoring for
matching functions.  So reverting the behavior for evaluating non-string
values to the previous one.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/286
2021-07-08 14:47:36 +09:00
Mehdi Sabwat fd393c53d8 fcstat: add support for wasm-emscripten
fallback to f_type statfs struct field, since f_fstypename is not supported on the platform.
2021-07-06 18:17:32 +02:00
Akira TAGOH e291fda7d4 Bump version to 2.13.94 2021-06-28 22:45:02 +09:00
Akira TAGOH da1c9f7a6c Fix score evaluation for multiple values in properties
Sometimes fonts has multiple values in family and sub-family in order to unify
other variants into one. they basically make difference in sub-family though,
they also still have standalone family and sub-family. in that case, sub-family is
likely to be Regular.

fontconfig couldn't recognize the difference between :family=Foo:style=Regular
and :family=Foo Caption:style=Regular for example because fontconfig didn't
give different score on matching result for the position of multiple values in
a cache.
Thus, when querying a font like :family=Foo:style=Regular may results
:family=Foo Caption:style=Regular. (see the test case for more details)

To fix this situation, giving different score according to the position
of multiple values in a cache as well as the position of multiple values
in a query.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/283
2021-06-28 08:51:58 +00:00
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 fe2fa4d1f4 Better wording for comments in config
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/274
2021-06-25 21:30:08 +09:00
Albert Astals Cid fd3eebad74 Fix potential memory leak in _get_real_paths_from_prefix 2021-04-10 00:10:20 +02:00
Akira TAGOH 6f27f42e61 Add support for XDG_DATA_DIRS
Add dirs from XDG_DATA_DIRS when <dir prefix="xdg"> appears in fonts.conf

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/271
2021-03-30 15:08:17 +09:00
Akira TAGOH b03140c14e ci: Update CA cert related thing for Python on Windows 2021-03-26 15:45:00 +09:00
Akira TAGOH 60ce9b695e Fix build fail when missing docbook and/or disabling doc-build
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/272
2021-03-25 21:26:12 +09:00
Akira TAGOH d263d4075e Refactoring configure.ac to add <dir> element around font paths 2021-03-03 22:17:36 +09:00
Akira TAGOH 10c7390e35 Fix missing <dir> element for WINDOWSFONTDIR in meson
also refactoring logic around it to reduce the redundant

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/276
2021-03-03 22:16:56 +09:00
Heiko Becker 4e42925096 Handle absolute sysconfdir when installing symlinks
sysconfdir defaults to /etc when the prefix is set to /usr. But joining
MESON_INSTALL_DESTDIR_PREFIX and sysconfdir when the latter is an
absoulte path, results in sysconfdir only. Which might lead to an error
during install because /etc/fonts/conf.d/ might already exist from an
pre-existing fontconfig installation.
2021-03-03 04:54:33 +00:00
Akira TAGOH 615e2cb844 Overwrite symlinks for config files
In Makefile, we are trying to remove old symlinks first and then create a symlink.
do the same thing in meson too.

Also, the line of the exception handling for FileExistsError is meaningless
as the above line is taking care of it instead and we shouldn't ignore it if
os.remove and os.symlink doesn't work somehow.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/275
2021-03-02 19:41:44 +09:00
Tim-Philipp Müller dba3287bf5 meson: fix subproject build regression
commit ae9ac2a1 from !165 introduced a regression when
fontconfig is built as a subproject. In that case we
would fail to correctly construct the path to the root
build dir where the meson-info subdirectory resides,
instead looking for it in the fontconfig subproject
subdir. This would result in
FAILED: subprojects/fontconfig/src/fcobjshash.gperf
errors in the cutout.py script.

Instead use the @BUILD_ROOT@ substitution to get
to the build root which will work correctly in
either scenario.
2021-02-18 11:26:26 +00:00
Ben Wagner ba15d41bdc Fix stack use after scope in FcConfigCompareValue
Discovered by AddressSanitizer. When left_o and right_o are promoted the
promoted values are placed on the stack in FcValuePromotionBuffer.
The FcValuePromotionBuffers must then continue to be in scope while
left_o and right_o point into their content. In 9d4e5d0f the
FcValuePromotionBuffers were moved into the incorrect scope, leaving
left_o and right_o pointing into an object whose lifetime has ended.
This is similar to left and right which appear to have a smaller scope
but are actually required to be in the larger scope.

Correct this by moving the FcValuePromotionBuffers to the proper scope.
Leave the left and right FcValues where they are since they are in the
correct scope already.

This also adds to test-conf the ability to create charset, langset,
range, and matrix in patterns. This allows for a simple test which fails
under AddressSanitizer before this change and passes after.
2021-02-16 11:30:32 -05:00
Tim-Philipp Müller ae9ac2a1bf meson: fix cross-compilation issues with gperf header file preprocessing
Pass c_args to the compiler when preprocessing the gperf header file,
they might contain important bits without which compilation/preprocessing
might fail (e.g. with clang on Android). cc.cmd_array() does not include
the c_args and we can't easily look them up from the meson.build file, so
we have to retrieve from the introspection info.

This is basically the Meson equivalent to commit 57103773.
2021-02-15 12:53:32 +00:00
Xavier Claessens 7bfbaecf81 Windows: Fix symlink privilege error detection
The message is in e.args[1] and not e.args[0] at least with python 3.8.
Should be more future proof like this in case it change again.
2021-02-15 11:58:52 +00:00
Carmina16 401d521c1f ie.orth: Corrected; mistaken source replaced 2021-01-30 10:21:33 +00:00
Xavier Claessens b58f2798e2 Meson: Do not wrap fccache insallation script
When passing fccache executable directly Meson does special tricks such
as modifying $PATH on Windows.

See: https://github.com/mesonbuild/meson/pull/8259

Fixes: #260
2021-01-28 05:12:06 +00:00
Xavier Claessens 58c6633d6c Meson: Fallback to gperf subproject on all platforms
With Meson 0.56 when find_program() does not find it on the system it
automatically checks if a .wrap provides it and configure the
subproject.
2021-01-26 08:58:12 -05:00
Szunti 23e46d13c5 Fix stripping whitespace from end of family in FcPatternAddFullname 2021-01-20 16:13:18 +01:00
Tim-Philipp Müller 4b142e9241 meson: error out in script if gperf preprocessing failed 2021-01-15 11:34:43 +00:00
Jacko Dirks b7e4931582 fccfg.c: lock_config: Fix potential memory leak
We would malloc for every try, never cleaning up.
2021-01-13 14:25:59 +01:00
Tim-Philipp Müller 643c3f1e27 ci: add meson android aarch64 build
Passing -Wno-pointer-bool-conversion in cross file
to suppress compiler warning:

src/fcfreetype.c:1373:11: address of array 'os2->achVendID' will always evaluate to 'true'
2021-01-08 11:39:25 +00:00
Tim-Philipp Müller 8657c081e9 fcformat: fix compiler warnings with clang on Android
fcformat.c:762:44: warning: expression which evaluates to zero treated as a null pointer constant of type 'FcChar8 *' (aka 'unsigned char *') [-Wnon-literal-null-conversion]
                if (!FcNameUnparseValue (buf, &l->value, '\0'))
                                                         ^~~~
fcformat.c:769:38: warning: expression which evaluates to zero treated as a null pointer constant of type 'FcChar8 *' (aka 'unsigned char *') [-Wnon-literal-null-conversion]
            FcNameUnparseValueList (buf, l, '\0');
                                            ^~~~
2021-01-08 11:39:25 +00:00