summaryrefslogtreecommitdiff
path: root/src/fcstr.c
Commit message (Collapse)AuthorAgeFilesLines
* Ignore null pointer on Fc*Destroy functionsAkira TAGOH2022-12-051-18/+21
| | | | Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/339
* 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
* Resolves symlinks against <dir prefix="relative">Akira TAGOH2021-10-111-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add support for XDG_DATA_DIRSAkira TAGOH2021-03-301-6/+33
| | | | | | Add dirs from XDG_DATA_DIRS when <dir prefix="xdg"> appears in fonts.conf Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/271
* Use FC_UNLIKELYMatthias Clasen2020-08-251-6/+6
|
* 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.
* Add a hash function for familiesMatthias Clasen2020-08-251-0/+13
| | | | | | | 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.
* Fix some typos/spelling errorsAlan Coopersmith2020-07-211-1/+1
| | | | Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Allow overriding salt with new one coming laterAkira TAGOH2019-04-031-0/+58
|
* Add salt attribute to dir and remap-dir elementsAkira TAGOH2019-04-031-8/+24
| | | | | | | | | | | 'salt' attribute affects a cache filename to generate different name from directory name. This is useful when sharing caches with host on sandbox and/or give a filename differently: <dir salt="randomdata">/usr/share/fonts</dir> <remap-dir as-path="/usr/share/fonts" salt="salt for /usr/share/fonts on host">/run/host/fonts</remap-dir> Applications can read caches as-is for fonts on /run/host/fonts where is mounted from host. and write a cache for their own fonts on /usr/share/fonts with different name.
* Add reset-dirs elementAkira TAGOH2019-04-031-0/+16
| | | | | | This element removes all of fonts directories where added by dir elements. it is useful to override fonts dirs from system to their own dirs only.
* Replace UUID file mechanism with per-directory 'map' attribute [v2]Keith Packard2019-04-031-0/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The UUID files would be placed in each font directory to provide the unique cache name, independent of path, for that directory. The UUID files are undesireable for a couple of reasons: 1) They must be placed in the font directories to be useful. This requires modifying the font directories themselves, introducing potential visible timestamp changes when running multiple applications, and makes the cache processing inconsistent between applications with permission to write to the font directories and applications without such permission. 2) The UUID contents were generated randomly, which makes the font cache not reproducible across multiple runs. One proposed fix for 2) is to make the UUID dependent on the font directory path, but once we do that, we can simply use the font directory path itself as the key as the original MD5-based font cache naming mechanism did. The goal of the UUID file mechanism was to fix startup time of flatpaks; as the font path names inside the flatpak did not match the font path names in the base system, the font cache would need to be reconstructed the first time the flatpak was launched. The new mechanism for doing this is to allow each '<dir>' element in the configuration include a 'map' attribute. When looking for a cache file for a particular directory, if the directory name starts with the contents of the <dir> element, that portion of the name will be replaced with the value of the 'map' attribute. Outside of the flatpak, nothing need change -- fontconfig will build cache files using real directory names. Inside the flatpak, the custom fonts.conf file will now include mappings such as this: <dir map="/usr/share/fonts">/run/host/fonts</dir> When scanning the directory /run/host/fonts/ttf, fontconfig will use the name /usr/share/fonts/ttf as the source for building the cache file name. The existing FC_FILE replacement code used for the UUID-based implementation continues to correctly adapt font path names seen by applications. v2: Leave FcDirCacheCreateUUID stub around to avoid removing public API function. Document 'map' attribute of <dir> element in fontconfig-user.sgml Suggested-by: Akira TAGOH <akira@tagoh.org> Signed-off-by: Keith Packard <keithp@keithp.com>
* Fix missing closing bracket in FcStrIsAbsoluteFilename()Akira TAGOH2018-08-211-1/+1
| | | | Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/96
* Allocate sufficient memory to terminate with nullAkira TAGOH2018-07-251-1/+1
|
* Return canonicalized paths from FcConfigRealFilenameTom Anderson2018-07-161-0/+11
| | | | | | | | | | | | | | | | | | | FcConfigRealFilename() follows symlinks, but the link may be relative to the directory containing the link. For example, on my system, I have this file: /etc/fonts/conf.d/99-language-selector-zh.conf -> ../conf.avail/99-language-selector-zh.conf Since /etc/fonts/conf.d is probably not in PATH, open()ing the file would fail. This change makes FcConfigRealFilename() return the canonicalized filename instead. So for the example above, it would return: /etc/fonts/conf.avail/99-language-selector-zh.conf This was causing bad font rendering in Chromium [1] after the regression I introduced in 7ad010e80bdf8e41303e322882ece908f5e04c74. [1] https://bugs.chromium.org/p/chromium/issues/detail?id=857511
* Optimizations in FcStrSetPatrick Haller2016-01-121-14/+33
| | | | | | | | | | | | | | | Applied optimizations: - skip duplicate check in FcStrSetAppend for values originating from readdir() - grow FcStrSet in 64-element bulks for local FcStrSets (FcConfig layout unaltered) Starting gedit is measured to Unoptimized Optimized user[s] 0,806 0,579 sys[s] 0,062 0,062 Total Instr Fetch Cost: 1.658.683.750 895.069.820 Cachegrind D Refs: 513.917.619 312.000.436 Cachegrind Dl Misses: 8.605.632 4.954.639
* Revert changes made to FcConfigAppFontAddDir() recentlyBehdad Esfahbod2015-06-261-8/+0
| | | | | | | | | | | | | | | | In 32ac7c75e8db0135ef37cf86f92d8b9be000c8bb the behavior of FcConfigAppFontAddFile/Dir() were changed to return false if not fonts were found. While this is welldefined and useful for AddFile(), it's quite problematic for AddDir(). For example, if the directory is empty, is that a failure or success? Worse, the false value from AddDir() was being propagated all the way to FcInit() returning false now. This only happened upon memory allocation failure before, and some clients assert that FcInit() is successful. With this change, AddDir() is reverted back to what it was. AddFont() change (which was actually in fcdir.c) from the original commit is left in.
* Don't return FcFalse even when no fonts dirs is configuredAkira TAGOH2015-06-171-0/+8
|
* Remove unused regex codeBehdad Esfahbod2014-07-241-52/+0
| | | | Regex matching was disabled in f6244d2cf231e1dc756f3e941e61b9bf124879bb
* Avoid memory leak when NULL path passed to FcStrBuildFilenameAlan Coopersmith2013-11-051-2/+6
| | | | | | | | | | Reported by parfait 1.3: Memory leak of pointer sset allocated with FcStrSetCreate() at line 933 of src/fcstr.c in function 'FcStrBuildFilename'. sset allocated at line 927 with FcStrSetCreate(). sset leaks when sset != NULL at line 932. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
* Workaround the race condition issue on updating cacheAkira TAGOH2013-10-021-0/+6
|
* Use the glob matching for filenameAkira TAGOH2013-05-081-0/+44
| | | | | | | Regex is expensive to compare filenames. we already have the glob matching and it works enough in this case. Prior to this change, renaming FcConfigGlobMatch() to FcStrGlobMatch() and moving to fcstr.c
* Bug 38737 - Wishlist: support FC_POSTSCRIPT_NAMEAkira TAGOH2013-03-211-37/+48
| | | | | | Add the PostScript name into the cache and the matcher. Scoring the better font against the PostScript name by the forward-matching.
* Bug 59456 - Adding a --sysroot like option to fc-cacheAkira TAGOH2013-03-051-2/+60
| | | | | | Add an ability to set the system root to generate the caches. In order to do this, new APIs, FcConfigGetSysRoot() and FcConfigSetSysRoot() is available.
* Fix memory corruption!Behdad Esfahbod2013-01-081-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In FcStrListCreate() we were increasing reference count of set, however, if set had a const reference (which is the case for list of languages), and with multiple threads, the const ref (-1) was getting up to 1 and then a decrease was destroying the set. Ouch. Here's the valgrind error, which took me quite a few hours of running to catch: ==4464== Invalid read of size 4 ==4464== at 0x4E58FF3: FcStrListNext (fcstr.c:1256) ==4464== by 0x4E3F11D: FcConfigSubstituteWithPat (fccfg.c:1508) ==4464== by 0x4E3F8F4: FcConfigSubstitute (fccfg.c:1729) ==4464== by 0x4009FA: test_match (simple-pthread-test.c:53) ==4464== by 0x400A6E: run_test_in_thread (simple-pthread-test.c:68) ==4464== by 0x507EE99: start_thread (pthread_create.c:308) ==4464== Address 0x6bc0b44 is 4 bytes inside a block of size 24 free'd ==4464== at 0x4C2A82E: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==4464== by 0x4E58F84: FcStrSetDestroy (fcstr.c:1236) ==4464== by 0x4E3F0C6: FcConfigSubstituteWithPat (fccfg.c:1507) ==4464== by 0x4E3F8F4: FcConfigSubstitute (fccfg.c:1729) ==4464== by 0x4009FA: test_match (simple-pthread-test.c:53) ==4464== by 0x400A6E: run_test_in_thread (simple-pthread-test.c:68) ==4464== by 0x507EE99: start_thread (pthread_create.c:308) Thread test is running happily now. Will add the test in a moment.
* Fix build and warnings on win32Behdad Esfahbod2013-01-021-3/+0
|
* Remove FcSharedStr*Behdad Esfahbod2013-01-021-10/+1
|
* Make FcGetDefaultLang and FcGetDefaultLangs thread-safeBehdad Esfahbod2013-01-021-0/+4
|
* Make refcounts, patterns, charsets, strings, and FcLang thread-safeBehdad Esfahbod2013-01-021-11/+13
|
* Remove memory accounting and reportingBehdad Esfahbod2012-12-291-21/+0
| | | | That belongs in tools like cairo/util/malloc-stat.so
* Fix more warningsBehdad Esfahbod2012-12-291-2/+0
|
* Fix a typo that accessing to the out of arrayAkira TAGOH2012-12-111-1/+1
|
* Fix the wrong estimation for the memory usage information in fontconfigAkira TAGOH2012-12-071-3/+2
|
* Fix wrongly squashing for the network path on Win32.Akira TAGOH2012-10-091-0/+4
| | | | Patch from Diego Santa Cruz
* Fix a build fail on MINGWAkira TAGOH2012-06-131-3/+3
|
* Bug 32853 - Export API to get the default languageAkira TAGOH2012-06-081-0/+44
| | | | | Add a new API FcGetDefaultLangs() to export the string sets of the default languages.
* Fix the wrong estimation for the memory usage information in fontconfigAkira TAGOH2012-06-011-2/+1
|
* Bug 20411 - fontconfig doesn't match FreeDesktop directories specsAkira TAGOH2012-05-181-2/+3
| | | | | | | | Allows reading configuration files, fonts and cache files from the directories where the XDG Base Directory Specification defines. the old directories are still in the configuration files for the backward compatibility.
* Fix a build issue again when no regex functions availableAkira TAGOH2012-04-201-1/+1
| | | | Reported by Jon TURNEY
* Bug 48573 - platform without regex do not have also REG_XXX definesAkira TAGOH2012-04-121-2/+4
| | | | Fix a build issue on the platforms where regex isn't available
* Bug 28491 - Allow matching on FC_FILEAkira TAGOH2012-04-111-0/+50
| | | | Allow :file=/path/to/font/file on matching
* FcStrPlus: optimize a littleMike Frysinger2012-02-211-3/+5
| | | | | | | We've already calculated the lengths of these strings, so re-use those values to avoid having to rescan the strings multiple times. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* Cleanup copyright notices to replace "Keith Packard" with "the author(s)"Behdad Esfahbod2010-11-101-2/+2
|
* Remove all training whitespacesBehdad Esfahbod2010-04-121-37/+37
|
* [fcstr] Remove unused variableBehdad Esfahbod2009-06-241-2/+0
|
* Replace 'KEITH PACKARD' with 'THE AUTHOR(S)' in license text in all filesBehdad Esfahbod2009-03-131-2/+2
|
* [fcxml.c] Embed a static 64-byte attr buffer in FcPStackBehdad Esfahbod2009-03-121-2/+2
| | | | | Reduces number of mallocs called from FcConfigSaveAttr in my small test from 160 down to 6.
* [fcstr,fcxml] Don't copy FcStrBuf contents when we would free it soonBehdad Esfahbod2009-03-121-0/+13
| | | | | We can simply NUL-terminate the buffer and use it. Reduces number of mallocs called from FcStrBufDone in my small test from 631 down to 66.
* [fcstr.c] Embed a static 64-byte buffer in FcStrBufBehdad Esfahbod2009-03-121-2/+9
| | | | | Reduces number of mallocs called from FcStrBufChar in my small test from 900 down to 6.