summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Make sure a combination of family and familylang is availableAkira TAGOH2020-09-211-0/+5
|
* Add Regular style when no meta data available to guess a styleAkira TAGOH2020-09-211-5/+18
| | | | | | | This makes sure that fullname can be constructed at least even if a style is missing and "Regular" is omitted for fullname so this change won't affect in that case. Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/259
* Update meson.buildAkira TAGOH2020-09-161-0/+1
|
* Add fullname later once FcConfigSubstitute() is doneAkira TAGOH2020-09-165-57/+98
| | | | So user's changes in family and style will be reflected into fullname.
* Construct fullname from family and styleAkira TAGOH2020-09-161-28/+11
| | | | | | | | | | OpenType spec says that the Regular descriptor would generally be omitted from fullname. but some fonts doesn't follow on it. So decided to construct a fullname from family and style instead of relying on the meta data in a font. Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/208
* fc-scan: add --sysroot optionAkira TAGOH2020-09-153-13/+35
| | | | | | and fix scanning to get things work with sysroot Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/225
* Add CONFIGDIR to the fallback config where can be specified by --with-configdirAkira TAGOH2020-09-151-0/+1
|
* Make more clearer the license termsAkira TAGOH2020-09-033-256/+257
| | | | | | COPYING is missing non-expat license terms for some files and some files is also missing license terms. This is changes to makes it clearer and update. Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/219
* Fix a problem in FcConfigSubstituteMatthias Clasen2020-08-301-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were using the family names from the pattern without copying, and this was leading to a valgrind warning: ==53167== Invalid read of size 1 ==53167== at 0x58B0238: FcStrCaseWalkerNextNonBlank (fcstr.c:198) ==53167== by 0x58B0238: FcStrCaseWalkerNextNonBlank (fcstr.c:186) ==53167== by 0x58B02C7: FcStrCmpIgnoreBlanksAndCase (fcstr.c:281) ==53167== by 0x58A4D44: FcHashTableFind (fchash.c:109) ==53167== by 0x5895E76: FamilyTableAdd (fccfg.c:1634) ==53167== by 0x589646A: FcConfigAdd.isra.0 (fccfg.c:1823) ==53167== by 0x58988CF: IA__FcConfigSubstituteWithPat.part.0 (fccfg.c:2228) ==53167== by 0x55F4F1A: pango_cairo_fc_font_map_fontset_key_substitute (pangocairo-fcfontmap.c:106) ==53167== by 0x5B88AF6: pango_fc_default_substitute (pangofc-fontmap.c:1795) ==53167== by 0x5B88D15: pango_fc_font_map_get_patterns (pangofc-fontmap.c:1850) ==53167== by 0x5B88FC7: pango_fc_font_map_load_fontset (pangofc-fontmap.c:1952) ==53167== by 0x5623627: pango_font_map_load_fontset (pango-fontmap.c:161) ==53167== by 0x5621743: pango_context_get_metrics (pango-context.c:1782) ==53167== Address 0x150d3450 is 0 bytes inside a block of size 10 free'd ==53167== at 0x483B9F5: free (vg_replace_malloc.c:538) ==53167== by 0x58ABE70: FcValueListDestroy (fcpat.c:147) ==53167== by 0x5898A08: IA__FcConfigSubstituteWithPat.part.0 (fccfg.c:2203) ==53167== by 0x55F4F1A: pango_cairo_fc_font_map_fontset_key_substitute (pangocairo-fcfontmap.c:106) ==53167== by 0x5B88AF6: pango_fc_default_substitute (pangofc-fontmap.c:1795) ==53167== by 0x5B88D15: pango_fc_font_map_get_patterns (pangofc-fontmap.c:1850) ==53167== by 0x5B88FC7: pango_fc_font_map_load_fontset (pangofc-fontmap.c:1952) ==53167== by 0x5623627: pango_font_map_load_fontset (pango-fontmap.c:161) ==53167== by 0x5621743: pango_context_get_metrics (pango-context.c:1782) Use copies of the strings as keys in the hash table to avoid this.
* Fix up FC_LIKELY macrosMatthias Clasen2020-08-251-2/+2
| | | | | | | __builtin_expect returns the same type as the expression, so enforce that we pass in a boolean expression. Pointed out by Emmanuele Bassi.
* Fixup: Handle patterns without familyMatthias Clasen2020-08-251-17/+20
| | | | Pointed out by Akira Tagoh.
* Use FC_UNLIKELYMatthias Clasen2020-08-251-6/+6
|
* Add FC_LIKELY and FC_UNLIKELY macrosMatthias Clasen2020-08-251-0/+8
| | | | These wrap __builtin_expect where it exists.
* Fixup: Promote ints to ranges when appropriateMatthias Clasen2020-08-251-7/+7
| | | | Pointed out by Akira Tagoh.
* Use __builtin_expect in a few placesMatthias Clasen2020-08-251-6/+6
| | | | | | utf8 is extremely rare in the strings we see in font configuration, so this seems to be a good case for __builtin_expect.
* Use a hash table for families in FcConfigSubstituteMatthias Clasen2020-08-251-20/+172
| | | | | | Use the same approach we used for FcFontMatch, and keep a hash table of family names. We only speed up the no-match case, for now.
* Speed up FcCompareLang and FcCompareBoolMatthias Clasen2020-08-251-12/+10
| | | | Avoid FcCanonicalize here too.
* Speed up FcConfigCompareValueMatthias Clasen2020-08-251-52/+78
| | | | | Avoid FcValueCanonicalize when we can, to avoid unnecessary copying of FcValue structs.
* Speed up FcConfigCompareValueMatthias Clasen2020-08-251-214/+250
| | | | | | | | | | Make FcConfigPromote use a switch instead of an if-else cascade, and avoid calling it when we can. Note that we need to add a case for integers in FcConfigCompareValue, since we are no longer promoting integers to doubles unconditionally.
* Speed up fonthashint matchingMatthias Clasen2020-08-251-6/+13
| | | | | | | | | | | | | | | | When we don't need to differentiate between weak and strong, we can exit the loop in FcCompareValueList once we found a best match. This change helps reducing the amount of list walking we do for fonthashint, where careless config files end up creating lists with ~100 booleans :( We don't want to walk all those to the end, over and over again. We are already special-casing family, and the only other case where weak != strong, PostScript names, doesn't have long lists of values, so the limitation to weak == strong doesn't matter much in practice.
* Add a shortcut for FcQualAny matchingMatthias Clasen2020-08-251-0/+2
| | | | | | | | | When checking whether a test matches a pattern, we cut the loop short for FcQualAll when we see the first non-matching value, but for FcQualAny we were always walking the full list. This patch cuts the loop short for FcQualAny when we see the first matching value.
* Use a hash table for family matchingMatthias Clasen2020-08-251-5/+134
| | | | | | | | | | | | | | | | | | | | | | With the way typical font configurations look, matching the lists of families is the bottleneck for both FcFontMatch and FcFontSort. After installing the Noto fonts on my system, an innocent match pattern like "Cantarell 14" turns into a monster with a list of 300 family names after calling FcConfigSubstitute(). With this setup, every FcFontSort call takes 80-100 ms, which is entirely incompatible with using FcFontSort for anything interactive. And many font choosers render every font in itself, causing on average one FcFontSort call per font. On my system, it takes more than 20 seconds to open the GTK font chooser dialog, with frequent stalls when scrolling. This patch special-cases font families and replaces the list walking for comparison with a hash table lookup. With this patch, the FcFontSort time goes to ~10ms per call. Which is still not good enough for calling it dozens of times when scrolling, but a significant improvement.
* Add a hash function for familiesMatthias Clasen2020-08-252-0/+16
| | | | | | | Add a hash function that behaves like family comparison: ignoring case and blanks. This will be used to replace the list walking for finding family matches with a hash table.
* Special-case some of the string walking codeMatthias Clasen2020-08-251-24/+62
| | | | | | | | | Make variants of FcStrCaseWalkerNext for the two common cases, delim == NULL and delim == " ", to speed things up. These are inner loops, and having the conditions as simple as possible helps.
* Avoid a crash in FcPatternHash with rangesMatthias Clasen2020-08-231-1/+1
| | | | | | | When a cached pattern contains a range, FcPatternHash will crash. Fixes #254.
* Turn unknown attributes into warningJan Tojnar2020-08-181-1/+1
| | | | | As far as I can tell, fontconfig can recover from encountering an unknown attribute. And unknown elements already print a warning instead of an error, so let's make this a warning too.
* Fix build issues regarding formatter for Win32Akira TAGOH2020-08-064-3/+15
| | | | Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/248
* Add Meson build systemTim-Philipp Müller2020-07-317-0/+563
| | | | See https://mesonbuild.com
* Guard dirent.h includesTim-Philipp Müller2020-07-275-0/+12
| | | | Might not be available on Windows.
* Fix some typos/spelling errorsAlan Coopersmith2020-07-214-5/+5
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Fix empty XDG_CACHE_HOME BehaviorAkira TAGOH2020-07-142-1/+3
| | | | | | Use the default $HOME/.cache one for empty XDG_CACHE_HOME. Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/243
* Replace FT_UNUSED with FC_UNUSED.Ben Wagner2020-07-071-7/+4
| | | | FreeType is trying to hide FT_UNUSED, so use FC_UNUSED instead.
* fccompat: fix build on Windows without unistd.hTim-Philipp Müller2020-07-073-1/+25
| | | | https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=vs-2019
* Fix build on Windows some moreTim-Philipp Müller2020-07-012-0/+6
|
* Use FC_PATH_MAX to fix build on WindowsTim-Philipp Müller2020-07-011-2/+2
|
* Some build fixes to support compilation with MSVC on WindowsMathieu Duponchelle2020-07-012-1/+13
|
* Add FC_ORDER property into cacheAkira TAGOH2020-05-254-0/+7
| | | | | | | | | | "fontversion" used to be modified to sort out fonts as a technique. But that lost the original purpose to do the version control between releases. This change adds the dedicated property into the cache. Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/226
* Fix cache conflicts on OSTree based systemAkira TAGOH2020-05-121-3/+25
| | | | | | | | | | | | mtime isn't reliable to detect updates of fonts on OSTree based system since they reset mtime to 0 for system files. Due to this, there are the situation likely to happen where mtime is newer but content is older. Fortunately, OSTree based system requires reboot to deploy changes. so we can assume we won't see any changes on system fonts. so system caches are always up-to-date. we can ignore meta data for system fonts in user caches.