summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Fix leak of `reason` in _FcConfigParse when not complainingBen Wagner2023-03-301-0/+3
| | | | | | | | | | | | | | | In "Do not return FcFalse from FcConfigParseAndLoad*() if complain is set to false" [0], _FcConfigParse was updated to return FcTrue early if it was instructed not to complain on errors. In "Take effect sysroot functionality to the default config file" [1] the error messages were factored into a `reason` which was allocated. Be sure to free this `reason` in the case of returning FcTrue early. Discovered with a leak checker while attempting to configure in interesting ways. [0] https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/fcada522913e5e07efa6367eff87ace9f06d24c8 [1] https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/cd51cb241aad7b362b793200ca7d42595c14f52b
* Clean up unused codeAkira TAGOH2023-03-062-8/+0
|
* Reload MM/VF metadata for each font face in font collectionmsizanoen12023-02-221-0/+14
| | | | | | This ensures that the MM/VF metadata is the correct metadata for each font face instead of whatever happens to be in the first one in the collection.
* In fcfreetype.c, `GetScriptTags`: fix `use_of_uninitialized_value` and ↵Vitaly Lysenkov2023-02-211-2/+2
| | | | return the correct number of parsed tags in case the font file contains less tags than indicated.
* Fix false-positive CFI failureTom Anderson2023-02-131-2/+2
| | | | | | | | | | | | | When building Chromium with upstream Fontconfig with CFI, the following build error is raised: ../../third_party/fontconfig/src/src/fchash.c:105:21: runtime error: control flow integrity check for type 'unsigned int (const void *)' failed during indirect function call This occurs because CFI doesn't like the conversion from `unsigned int (const void *)` to `unsigned int (const char *)`. To fix this, simply redefine `FcHashFunc` to use `char *` instead.
* Fix filepaths added when scanning with sysrootTom Anderson2023-02-091-11/+11
| | | | | | | | This fixes a regression introduced by 76f88e780. When using FONTCONFIG_SYSROOT=/home/tom/test_fonts, strace reveals that fontconfig attempted to open /test_fonts/Ahem.ttf instead of /home/tom/test_fonts/Ahem.ttf. The fix is to use `s_dir` instead of `dir` in `file_prefix`.
* Add some missing constant names for weight.Akira TAGOH2023-01-251-2/+24
| | | | Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/348
* Report more detailed logs instead of assertion.Akira TAGOH2023-01-251-10/+7
| | | | | | | | Getting backtraces against this assertion isn't useful at all. Fontconfig isn't capable to report who really have a reference of caches though, this report may be better than assertion. So we can try analysis tools then. And report it only when running with FC_DEBUG=16.
* Expand ~ in globOndrej Balaz2023-01-252-2/+10
| | | | | | Allow ~ home directory expansion in acceptfont and rejectfont globs. Fixes: #347
* src/meson.build: Store correct paths to fontconfig.pc.Akira TAGOH2022-12-281-2/+2
| | | | Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/345
* Ignore LC_CTYPE if set to "UTF-8"Jean Abou Samra2022-12-141-1/+11
| | | | | | | | | | | | | | | LC_CTYPE is set to "UTF-8" on some macOS systems, which is POSIX-compliant in a strict sense, but breaks the usual assumption that a locale name has the form "ll_LL.encoding". https://unix.stackexchange.com/questions/503110/valid-values-for-lc-ctype Previously, this would cause the warning Fontconfig warning: ignoring UTF-8: not a valid region tag Now, we just skip this variable if set to "UTF-8", since that value doesn't give any language information, and move on to try LANG.
* Ignore null pointer on Fc*Destroy functionsAkira TAGOH2022-12-058-78/+95
| | | | Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/339
* 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.