Commit Graph

2295 Commits

Author SHA1 Message Date
Xavier Claessens 73353b3376 meson: Use version comparison function 2020-10-03 21:33:44 -04:00
Xavier Claessens af052688d8 meson: Fix build when 'tools' option is disabled 2020-10-03 21:33:44 -04:00
Chun-wei Fan e50fbc1beb meson: Look for FreeType using CMake too
Some systems build FreeType using CMake rather than autotools (such as Visual
Studio), which will give us CMake config files rather than pkg-config files, so
if we can't find FreeType using pkg-config, try again using CMake.

Please note that according to FreeType's docs/VERSIONS.TXT, the version we want
when checking with CMake is 2.8.1 or later.
2020-10-02 11:09:08 +08:00
Akira TAGOH 74f05951e8 Update COPYING
Add missing copyright notice.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/219
2020-09-29 15:37:34 +09:00
Akira TAGOH dc1443ac83 Split up a code again coming from different copyright notice
to show up easier in COPYING.
it was originally merged from separate file by 2e2121f9 though.
2020-09-29 15:37:14 +09:00
Akira TAGOH dbef9d10de Make sure a combination of family and familylang is available 2020-09-21 14:55:21 +09:00
Akira TAGOH 5a291467a7 Add Regular style when no meta data available to guess a style
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
2020-09-21 14:55:18 +09:00
Akira TAGOH dbd67ccc63 Update meson.build 2020-09-16 15:06:43 +09:00
Akira TAGOH c78e7fd6de Add fullname later once FcConfigSubstitute() is done
So user's changes in family and style will be reflected into fullname.
2020-09-16 13:40:48 +09:00
Akira TAGOH 0f9040406c Construct fullname from family and style
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
2020-09-16 13:40:48 +09:00
Akira TAGOH 76f88e780a fc-scan: add --sysroot option
and fix scanning to get things work with sysroot

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/225
2020-09-15 18:17:36 +09:00
Akira TAGOH 9d419e22d6 Add CONFIGDIR to the fallback config where can be specified by --with-configdir 2020-09-15 18:14:30 +09:00
Akira TAGOH 3ae08a8601 Make more clearer the license terms
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
2020-09-03 06:25:30 +00:00
Matthias Clasen e735abcfe1 Fix a problem in FcConfigSubstitute
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.
2020-08-30 12:05:24 -04:00
Akira TAGOH 9c1946d330 Make sure a minimum version of python 2020-08-27 18:32:53 +09:00
Akira TAGOH ef28c78350 Integrate python scripts to autotools build
Recently some python scripts has been added to the build toolchain for meson build support. but we don't want to maintain multiple files for one purpose. since autotools build support will be guradually discontinued, integrating those scripts into autotools would be better.
2020-08-26 13:33:07 +00:00
Matthias Clasen ff7d314ab5 Fix up FC_LIKELY macros
__builtin_expect returns the same type as the expression,
so enforce that we pass in a boolean expression.

Pointed out by Emmanuele Bassi.
2020-08-25 18:12:07 -04:00
Matthias Clasen e117d6768c Fixup: Handle patterns without family
Pointed out by Akira Tagoh.
2020-08-25 12:15:45 -04:00
Matthias Clasen 51d40491fc Use FC_UNLIKELY 2020-08-25 12:15:45 -04:00
Matthias Clasen 76699a4813 Add FC_LIKELY and FC_UNLIKELY macros
These wrap __builtin_expect where it exists.
2020-08-25 12:15:45 -04:00
Matthias Clasen 835f9bbdbe Fixup: Promote ints to ranges when appropriate
Pointed out by Akira Tagoh.
2020-08-25 12:15:45 -04:00
Matthias Clasen 148ebf98ed Use __builtin_expect in a few places
utf8 is extremely rare in the strings we see in
font configuration, so this seems to be a good
case for __builtin_expect.
2020-08-25 12:15:45 -04:00
Matthias Clasen 13015a0a6e Use a hash table for families in FcConfigSubstitute
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.
2020-08-25 12:15:18 -04:00
Matthias Clasen 7deb07e38e Speed up FcCompareLang and FcCompareBool
Avoid FcCanonicalize here too.
2020-08-25 12:15:18 -04:00
Matthias Clasen 09729c9032 Speed up FcConfigCompareValue
Avoid FcValueCanonicalize when we can, to avoid
unnecessary copying of FcValue structs.
2020-08-25 12:15:18 -04:00
Matthias Clasen 9d4e5d0f25 Speed up FcConfigCompareValue
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.
2020-08-25 12:15:18 -04:00
Matthias Clasen 922168afe8 Speed up fonthashint matching
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.
2020-08-25 12:15:18 -04:00
Matthias Clasen 1b0cb23adc Add a shortcut for FcQualAny matching
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.
2020-08-25 12:15:18 -04:00
Matthias Clasen 8022ab4aff Use a hash table for family matching
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.
2020-08-25 12:15:18 -04:00
Matthias Clasen 055843631b Add a hash function for families
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.
2020-08-25 12:10:53 -04:00
Matthias Clasen 46d818df26 Special-case some of the string walking code
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.
2020-08-25 12:10:53 -04:00
Akira TAGOH abbd87ac2c Add some tweaks into runtest.sh to see progress 2020-08-25 12:50:27 +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
Jan Tojnar 9133e799b5 Turn unknown attributes into warning
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.
2020-08-18 04:13:21 +00:00
Akira TAGOH a53f79b4a2 Fix build issues regarding formatter for Win32
Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/248
2020-08-06 13:02:00 +09:00
Tim-Philipp Müller a5fd5dc471 meson: print configuration summary()
Fixes #249
2020-07-31 15:17:09 +01:00
Tim-Philipp Müller 57a224f51d Add Meson build system
See https://mesonbuild.com
2020-07-31 07:26:11 +00:00
Tim-Philipp Müller 03aa12c75e Guard dirent.h includes
Might not be available on Windows.
2020-07-27 13:43:23 +00:00
Alan Coopersmith 9bc88933b2 Fix some typos/spelling errors
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-07-21 18:42:40 -07:00
Akira TAGOH 437f03299b Fix empty XDG_CACHE_HOME Behavior
Use the default $HOME/.cache one for empty XDG_CACHE_HOME.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/243
2020-07-14 19:48:11 +09:00
Ben Wagner 4a1cf888cf Replace FT_UNUSED with FC_UNUSED.
FreeType is trying to hide FT_UNUSED, so use FC_UNUSED instead.
2020-07-07 10:25:02 -04:00
Tim-Philipp Müller a30e4db967 fccompat: fix build on Windows without unistd.h
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=vs-2019
2020-07-07 03:48:34 +00:00
Akira TAGOH 97d709e888 Fix a typo in doc/confdir.sgml.in
Since changes introduced by e181ab4d
2020-07-02 13:55:04 +09:00
Tim-Philipp Müller 93e65a8541 Fix build on Windows some more 2020-07-01 20:04:13 +01:00
Tim-Philipp Müller a98b620683 Use FC_PATH_MAX to fix build on Windows 2020-07-01 20:00:57 +01:00
Mathieu Duponchelle 7b293e3292 Some build fixes to support compilation with MSVC on Windows 2020-07-01 20:00:42 +01:00
Tim-Philipp Müller 344925fc53 doc: fix FcPatternFilter documentation
The second argument should be ARG2 not ARG1.
2020-07-01 10:49:20 +01:00
Jan Tojnar 37c7c74874 Drop elements with its namespace from fonts.conf.in
This appears to have been forgotten in https://gitlab.freedesktop.org/fontconfig/fontconfig/merge_requests/97
2020-06-24 00:00:12 +00:00
Akira TAGOH fcb0420281 Drop Bitstream Vera fonts from 60-latin.conf
Bitstream Vera fonts seems broken so dropped them there.

Fixes https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/26
2020-06-02 17:33:15 +09:00
Akira TAGOH 68d021b634 Add FC_ORDER property into cache
"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
2020-05-25 18:22:55 +09:00