summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Add FC_DESKTOP_NAME propertyAkira TAGOH2022-11-264-12/+68
| | | | To allow users to have desktop-specific matching rule.
* Fix the build issue on meson when -g option is added to c_argsAkira TAGOH2022-10-271-1/+2
| | | | Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/335
* Real fix of 91114d18cAkira TAGOH2022-09-281-5/+1
| | | | | | | | The change in 91114d18c broke remapping font paths. Patch from Mattias Clasen Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/331
* Avoid misuse of ctype(3)Taylor R Campbell2022-04-111-2/+2
| | | | | | | | | | | | | | | | | | | The ctype(3) functions take arguments of type int that are either (a) EOF, or (b) unsigned char values, {0, 1, 2, ..., 255} if char is 8-bit. Passing values of type char, on platforms where it is signed, can go wrong -- negative values may be confused with EOF (typically -1) or may lead to undefined behaviour ranging in practice from returning garbage data (possibly out of an adjacent buffer in memory that may contain secrets) to crashing with SIGSEGV (if the page preceding the ctype table is unmapped). The ctype(3) functions can't themselves convert to unsigned char because then they would give the wrong answers for EOF, for use with functions like getchar and fgetc; the user has to cast char to unsigned char.
* Fix possible memory leaks in FcPatternObjectAddWithBindingAkira TAGOH2022-01-311-33/+10
| | | | | | Reported by Ruth Ivimey-Cook Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/302
* WIN32: Fix pGetSystemWindowsDirectory found initialized during ↵Francesco Pretto2022-01-311-18/+26
| | | | | | | | | | | | FcConfigParseAndLoadFromMemory Trying to early loading a custom fonts.xml created on the fly results in the pGetSystemWindowsDirectory function pointer being found intialized. Normally the initialization is performed in the default configuration loading. The commit factorizes the lazy initialization of both WIN32 getters (together with pSHGetFolderPathA) in a function and call it when actually needed.
* Add an user font directory for Win32 to the default font pathAkira TAGOH2022-01-171-0/+10
| | | | | | Patch from @takase1121 Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/144
* Initialize variableAkira TAGOH2021-12-091-1/+1
|
* Apply the change made by 23e46d1 againAkira TAGOH2021-12-091-1/+1
| | | | Regression by d62d984e2bfe5b9c7767e8ad657ec93652d52bbd
* Fix the issue fail to obtain the style nameAkira TAGOH2021-12-091-0/+1
| | | | | | | The number of a couple of 'family' and 'familylang' and 'style' and 'stylelang' is different. need to reset the counter to get the property regarding to regarding to the lang. Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/303
* Actually skip leading spaces in style nameBen Wagner2021-12-061-2/+1
| | | | | | Because the loop body is just 'break' the loop never loops and at most one leading space is skipped. Remove the body to allow the loop to continue. Found with ClangTidy.
* Back FcSerialize with open addressing hash table.Ben Wagner2021-11-162-37/+170
| | | | | | 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.
* Ensure config.h is always included before stdlib headersRyan Gonzalez2021-11-101-1/+1
| | | | | | | | | 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>
* Fix some testcase fails for 14c265a1Akira TAGOH2021-11-091-14/+23
| | | | | 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.
* If a varfont has 'opsz' axis, set FC_SIZE on default instant patternBehdad Esfahbod2021-11-091-4/+19
| | | | | | | 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
* Fix warning about os2->achVendID cannot be NULLBen Wagner2021-10-281-1/+1
| | | | | 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.
* Resolves symlinks against <dir prefix="relative">Akira TAGOH2021-10-114-27/+37
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix score estimation for postscriptnameAkira TAGOH2021-10-081-3/+5
| | | | | | | | | | | | 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
* Free local FcCache lock on contentionBen Wagner2021-09-061-0/+1
| | | | | | | | | | 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.
* Add memory order constraints to C11 atomicsBen Wagner2021-08-311-3/+3
| | | | | | | 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.
* Fix a memory leak when trying to open a non-existing fileAkira TAGOH2021-08-251-5/+7
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=1914716
* Reflect matching results to binding in FcPatternAkira TAGOH2021-08-241-21/+81
| | | | | | | 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
* FcCharSetPutLeaf(): Fix missing move of new_leaves contentsAlex Richardson2021-08-181-14/+17
| | | | | | | | | | | 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
* Add support for C11 stdatomic atomicsAlex Richardson2021-07-202-1/+22
| | | | | | | | 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).
* fcint: add casts to allow building with stricter compilersAlex Richardson2021-07-201-3/+3
| | | | | | | | | 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.
* Restore fcatomic compatibility with Mac OS X 10.4.Ryan Schmidt2021-07-191-4/+7
| | | | | | | | | | | | | | Reverts the part of 6def66164a36eed968aae872d76acfac3173d44a that removed the fc_atomic_ptr_cmpexch compatibility code for systems earlier than Mac OS X 10.5. Reverts the part of 447b9ccc7d03bf953d1f1c4708ca16c56c1511ec 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.
* Do not set different score to non-string valuesAkira TAGOH2021-07-081-1/+1
| | | | | | | | | 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
* fcstat: add support for wasm-emscriptenMehdi Sabwat2021-07-061-1/+1
| | | | fallback to f_type statfs struct field, since f_fstypename is not supported on the platform.
* Fix score evaluation for multiple values in propertiesAkira TAGOH2021-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | 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
* Revert constructing fullname property from family and style propertiesAkira TAGOH2021-06-286-100/+55
| | | | | | This seems making a regression in Java. we will revisit this issue later. Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/277
* Fix potential memory leak in _get_real_paths_from_prefixmasterAlbert Astals Cid2021-04-101-2/+7
|
* Add support for XDG_DATA_DIRSAkira TAGOH2021-03-304-36/+166
| | | | | | Add dirs from XDG_DATA_DIRS when <dir prefix="xdg"> appears in fonts.conf Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/271
* meson: fix subproject build regressionTim-Philipp Müller2021-02-181-4/+1
| | | | | | | | | | | | | | | 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.
* Fix stack use after scope in FcConfigCompareValueBen Wagner2021-02-161-1/+1
| | | | | | | | | | | | | | | | | | | 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.
* meson: fix cross-compilation issues with gperf header file preprocessingTim-Philipp Müller2021-02-152-3/+18
| | | | | | | | | | 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.
* Fix stripping whitespace from end of family in FcPatternAddFullnameSzunti2021-01-201-1/+1
|
* meson: error out in script if gperf preprocessing failedTim-Philipp Müller2021-01-151-1/+1
|
* fccfg.c: lock_config: Fix potential memory leakJacko Dirks2021-01-131-0/+1
| | | | We would malloc for every try, never cleaning up.
* fcformat: fix compiler warnings with clang on AndroidTim-Philipp Müller2021-01-081-2/+2
| | | | | | | | | 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'); ^~~~
* Check qual and compare for family testsSzunti2020-12-171-1/+15
| | | | | Fixes #267. Hash table lookups assumed qual="any" compare="eq". Add a test too.
* Fix leaks in fcxml.c, fc-match.c, and tests.Ben Wagner2020-12-141-1/+3
| | | | Fix leaks reported by AddressSanitizer when running 'make check'.
* Remove abort from FcCompareSize.Ben Wagner2020-12-071-1/+0
| | | | | | | | | 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.
* Skip leading whitespace in style name.Ben Wagner2020-12-041-2/+1
| | | | | | | 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.
* Add back fullname property at scan matching phaseAkira TAGOH2020-12-042-1/+22
| | | | | | | | | | 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
* Allow multiple default system font directories in the fallback config, and ↵Niklas Guertler2020-11-281-1/+1
| | | | set them to the default dirs on Darwin.
* meson: Don't use .def files for Visual Studio buildsChun-wei Fan2020-11-191-6/+7
| | | | | | 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.
* Use memcpy instead of strcpyAkira TAGOH2020-11-021-1/+1
| | | | | | 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=]
* Fix fc_atomic_ptr_get and use.Ben Wagner2020-11-023-18/+25
| | | | | | | | | | | 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.
* meson: Fix build failure when compiler is not in PATHXavier Claessens2020-10-031-3/+4
| | | | | 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.
* Split up a code again coming from different copyright noticeAkira TAGOH2020-09-293-50/+50
| | | | | to show up easier in COPYING. it was originally merged from separate file by 2e2121f9 though.