Commit Graph

121 Commits

Author SHA1 Message Date
Akira TAGOH ed6c9cf67b Ignore null pointer on Fc*Destroy functions
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/339
2022-12-05 21:40:26 +09:00
Akira TAGOH 875878efb7 Fix possible memory leaks in FcPatternObjectAddWithBinding
Reported by Ruth Ivimey-Cook

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/302
2022-01-31 19:03:29 +09:00
Matthias Clasen de73d6c51a Avoid a crash in FcPatternHash with ranges
When a cached pattern contains a range,
FcPatternHash will crash.

Fixes #254.
2020-08-23 11:28:30 -04:00
Akira TAGOH 505c7c46a5 Improve the performance a bit
This change reduces the call cost of strcmp 1.5 % less.
2019-08-07 12:39:14 +00:00
Alexander Larsson c42402d0b8 Cache: Rewrite relocated paths in earlier
This changes the rewriting of the FC_FILE values for relocated caches to an earlier stage
while reading the cache. This is better, because it means all APIs will report the
rewritten paths, not just the once that use the list apis.

We do this by detecting the relocated case and duplicating the FcPattern and FcPatternElm
in an cache allocation (which will die with the cache) and then reusing the FcValueLists
from the cache.

This means that in the rewritten case we will use some more memory, but not the full
size of the cache. In a test here I had 800k of relocated caches, but ~200k of wasted
on duplicating the objects.

This should fix https://bugs.freedesktop.org/show_bug.cgi?id=106618
2018-05-25 14:42:52 +09:00
Akira TAGOH 307639cff1 Bug 43367 - RFE: iterator to peek objects in FcPattern
Add various APIs to obtain things in FcPattern through the iterator

https://bugs.freedesktop.org/show_bug.cgi?id=43367
2018-05-11 20:48:30 +09:00
Behdad Esfahbod 650b051a25 Set font-variations settings for standard axes in variable fonts
This is the last piece of the puzzle for variable-font support in
fontconfig.  This takes care of automatically setting the variation
settings when user requests a weight / width / size that has variation
in the matched font.
2017-12-19 15:04:25 -05:00
Akira TAGOH 68ff99c414 cleanup 2017-11-20 17:37:22 +05:30
Akira TAGOH 85d9de58ed Add new API to find out a font from current search path 2017-11-20 17:37:22 +05:30
Behdad Esfahbod 01f781a9a4 [varfonts] Share lang across named-instances
Makes VotoSerifGX scanning another 40% faster...  Down to 36ms now.
2017-09-27 18:55:50 -04:00
Akira TAGOH ee2000494c Add FcPatternGetWithBinding() to obtain the binding type of the value in FcPattern.
https://bugs.freedesktop.org/show_bug.cgi?id=19375
2017-07-07 15:43:59 +09:00
Akira TAGOH 10a57edd07 Add one more debugging option to see transformation on font-matching
just setting FC_MATCH=3 shows a lot of information and hard to keep on track for informamtion
which is really necessary to see. to use this more effectively, added FC_DBG_MATCH_FILTER to
see for what one really want to see. it takes a comma-separated-list of object names.
If you want to see family name only, try like this:

FC_DBG_MATCH_FILTER=family FC_DEBUG=4096 fc-match

debugging output will be filtered out and see family only in the result.
2015-06-08 17:39:25 +09:00
Akira TAGOH 3cd573fc1f Bug 71287 - size specific design selection support in OS/2 table version 5
This feature requires the FreeType 2.5.1 or later at the build time.

Besides <range> element allows <double> elements with this changes.

This may breaks the cache but not bumping in this change sets at this moment.
please be aware if you want to try it and run fc-cache before/after to
avoid the weird thing against it.
2014-03-26 12:19:04 +09:00
Akira TAGOH 7a6622f25c Improve the performance issue on rescanning directories 2013-12-20 11:57:16 +09:00
Akira TAGOH 197d06c49b Add FcTypeUnknown to FcType to avoid comparison of constant -1
This change reverts 9acc14c34a
because it doesn't work as expected when building
with -fshort-enums which is default for older arms ABIs

Thanks for pointing this out, Thomas Klausner, Valery Ushakov, and Martin Husemann
2013-06-28 15:04:11 +09:00
Akira TAGOH c758206e8c Fix a SIGSEGV on FcPatternGet* with NULL pattern 2013-03-21 11:58:06 +09:00
Behdad Esfahbod 93fb1d4bab Remove FcSharedStr* 2013-01-02 02:18:02 -06:00
Behdad Esfahbod 64af9e1917 Make refcounts, patterns, charsets, strings, and FcLang thread-safe 2013-01-02 00:51:00 -06:00
Behdad Esfahbod db6d86a6c1 Remove shared-str pool
We used to have a shared-str pool.  Removed to make thread-safety
work easier.  My measurements show that the extra overhead is not
significant by any means.
2013-01-02 00:37:00 -06:00
Behdad Esfahbod c9581b47c4 Don't crash in FcPatternDestroy with NULL pattern 2013-01-01 20:20:12 -06:00
Behdad Esfahbod 3878a12541 Make FC_DBG_OBJTYPES debug messages into warnings
And remove FC_DBG_OBJTYPES since it has no use now.
2013-01-01 20:19:53 -06:00
Behdad Esfahbod d7e1965aa0 Remove memory accounting and reporting
That belongs in tools like cairo/util/malloc-stat.so
2012-12-29 23:12:07 -05:00
Behdad Esfahbod 24cdcf52ab Fix compiler warnings 2012-12-29 22:24:24 -05:00
Akira TAGOH c20ac78b01 Bug 57114 - regression on FcFontMatch with namelang
After 7587d1c99d applied, family,
style, and fullname is localized against current locale or lang
if any though, the string in other languages were dropped from
the pattern. this caused unexpected mismatch on the target="font"
rules.

This fix adds other strings at the end of the list.
2012-11-15 16:37:32 +09:00
Akira TAGOH 1b692d8ab9 Fix the wrong estimation for the memory usage information in fontconfig 2012-06-01 19:06:17 +09:00
Akira TAGOH 4a060729a1 fcpat: Increase the number of buckets in the shared string hash table
This is a reasonably conservative increase in the number of buckets in the hash
table to 251.  After FcInit(), there are 240 shared strings in use on my system
(from configuration files I assume).  The hash value is stored in each link in
the chains so comparison are actually not very expensive.  This change should
reduce the average length of chains by a factor of 8.  With the reference
counted strings, it should keep the average length of chains to about 2.  The
number of buckets is prime so as not to rely too much on the quality of the
hash function.

https://bugs.freedesktop.org/show_bug.cgi?id=17832#c5

Patch from Karl Tomlinson
2012-03-28 13:42:01 +09:00
Akira TAGOH d8dcff7b96 Bug 17832 - Memory leaks due to FcStrStaticName use for external patterns
Use the reference-counted strings instead of the static strings

Patch from Karl Tomlinson
2012-03-28 13:42:01 +09:00
Behdad Esfahbod 1c475d5c8c Bug 35587 - Add padding to make valgrind and glibc not hate each other 2011-03-28 16:33:12 -04:00
Behdad Esfahbod 5aaf466d38 Cleanup copyright notices to replace "Keith Packard" with "the author(s)" 2010-11-10 16:45:42 -05:00
Behdad Esfahbod 594dcef0f3 Remove all training whitespaces 2010-04-12 12:19:05 -04:00
Behdad Esfahbod 963820fcbf [int] Remove fc_value_* macros that did nothing other than renaming 2009-11-16 17:46:18 -05:00
Behdad Esfahbod 888f9427ae [int] Remove fc_storage_type() in favor of direct access to v->type 2009-11-16 17:46:18 -05:00
Behdad Esfahbod efe5eae26b Simplify FcValueSave() semantics 2009-06-24 13:52:11 -04:00
Behdad Esfahbod 3074a73b41 Replace 'KEITH PACKARD' with 'THE AUTHOR(S)' in license text in all files 2009-03-13 17:59:28 -04:00
Behdad Esfahbod 263f16ced2 Oops, fix FcPatternFilter 2009-02-13 16:54:06 -08:00
Behdad Esfahbod 799691c901 Don't leak FcValues string loaded through fcxml.c (#17661)
Patch from Caolan McNamara.
2009-02-13 16:54:00 -08:00
Behdad Esfahbod 74e16ceeea Fix docs re 'orig' argument of FcPatternBuild and family
Now call it 'p' or 'pattern', since it's modified in place.
There is no copying.
2009-02-13 16:53:57 -08:00
Behdad Esfahbod 41fc0fe68d Add FcPatternFilter() (#13016) 2009-02-13 16:53:56 -08:00
Keith Packard 13a14cbf56 Fix a few memory tracking mistakes.
The built-in memory tracking code in fontconfig relies on a lot of manual
function call tracking. A pain, but it helps debug leaks.
2008-05-04 01:26:40 -07:00
Keith Packard a0a1da22a4 Include fcftaliastail.h so that the freetype funcs are exported.
This header file needs to be included at the end of every file that
exports any freetype symbols.
2008-01-07 16:31:06 -08:00
Keith Packard dbd065ad31 Remove freetype requirement for build-time applications.
This avoids requiring the freetype development files when cross compiling
2008-01-02 08:47:14 -08:00
Stephan Kulow 9b74b78fe8 Make FcPatternDuplicate copy the binding instead of always using Strong.
I noticed that Qt always uses a different font than fc-match advertises.
Debugging the issue, I found that a call that looks pretty innocent is
changing all weak bindings to strong bindings and as such changes the
semantic of the match: FcPatternDuplicate.
2007-03-12 10:21:35 -07:00
Keith Packard 2b77216ee2 Avoid writing uninitialized structure pad bytes to cache files.
The union inside the FcValue structure contains pad bytes. Instead of
copying the whole structure to the cache block, copy only the initialized
fields to avoid writing whichever bytes serve as padding within the
structure.
2006-12-02 13:04:05 -08:00
Keith Packard 23816bf9ac Eliminate .so PLT entries for local symbols. (thanks to Arjan van de Ven)
Using a simple shell script that processes the public headers, two header
files are constructed that map public symbols to hidden internal aliases
avoiding the assocated PLT entry for referring to a public symbol.

A few mistakes in the FcPrivate/FcPublic annotations were also discovered
through this process
2006-09-05 02:24:01 -07:00
Keith Packard 9e612141df Reference count cache objects.
Caches contain patterns and character sets which are reference counted and
visible to applications. Reference count the underlying cache object so that
it stays around until all reference objects are no longer in use.

This is less efficient than just leaving all caches around forever, but does
avoid eternal size increases in case applications ever bother to actually
look for changes in the font configuration.
2006-09-04 22:20:25 -07:00
Keith Packard bc5e487f2a Pass directory information around in FcCache structure. Freeze charsets.
Instead of passing directory information around in separate variables,
collect it all in an FcCache structure. Numerous internal and tool
interfaces changed as a result of this.

Charsets are now pre-frozen before being serialized. This causes them to
share across multiple fonts in the same cache.
2006-09-01 01:15:14 -07:00
Keith Packard e9a564e2cd Serialized value lists were only including one value.
The next pointer in the serialized value list wasn't getting set, so they
were truncated at a single value.
2006-08-31 09:07:32 -07:00
Keith Packard 09f9f6f62a Rework Object name database to unify typechecking and object lookup.
Eliminate ancient list of object name databases and load names into single
hash table that includes type information. Typecheck all pattern values to
avoid mis-typed pattern elements.
2006-08-30 18:50:58 -07:00
Keith Packard c02886485b FcCharSetSerialize was using wrong offset for leaves. Make fc-cat work.
FcCharSetSerialize was computing the offset to the unserialized leaf,
which left it pointing at random data when the cache was reloaded.

fc-cat has been updated to work with the new cache structure.

Various debug messages extended to help diagnose serialization errors.
2006-08-30 13:51:03 -07:00
Keith Packard 7ce1967331 Rework cache files to use offsets for all data structures.
Replace all of the bank/id pairs with simple offsets, recode several
data structures to always use offsets inside the library to avoid
conditional paths. Exposed data structures use pointers to hold offsets,
setting the low bit to distinguish between offset and pointer.

Use offset-based data structures for lang charset encodings; eliminates
separate data structure format for that file.

Much testing will be needed; offsets are likely not detected everywhere in
the library yet.
2006-08-30 04:16:22 -07:00