Commit Graph

1143 Commits

Author SHA1 Message Date
Akira TAGOH d7133f4ed7 Don't call FcStat when the alias has already been added
We could assume that the targeted location is mapped at the different place
when there are in the alias table.
2017-11-20 17:37:22 +05:30
Akira TAGOH cf5acaed96 Replace the path of subdirs in caches as well 2017-11-20 17:37:22 +05:30
Akira TAGOH 6d3b306cbe Replace the original path to the new one 2017-11-20 17:37:22 +05:30
Akira TAGOH 6f226ad67e Replace the font path in FcPattern to what it is actually located. 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
Akira TAGOH 7b48fd3dd4 Use uuid-based cache filename if uuid is assigned to dirs 2017-11-20 17:37:22 +05:30
Akira TAGOH e73b5dcbf2 Correct debugging messages to load/scan config 2017-11-16 11:37:36 +09:00
Akira TAGOH 2ed243f323 Validate cache more carefully
Reject caches when FcPattern isn't a constant.
This is usually unlikely to happen but reported.
I've decided to add more validation since this isn't reproducible
and easy to have a workaround rather than investigating 'why'.

https://bugs.freedesktop.org/show_bug.cgi?id=103237
2017-11-14 20:55:24 +09:00
Akira TAGOH 9a0fcb948f Add the ruleset description support
Trying to address what these configuration files really do.
This change allows to see the short description that mention
the purpose of the content in the config file and obtain
them through API.

This change also encourage one who want to make some UI for
the user-specific configuration management. it is the main
purpose of this change for me though.

Aside from that, I've also made programs translatable. so
we see more dependencies on the build time for gettext,
and itstool to generate PO from xml.
2017-11-07 15:24:54 +09:00
Alexander Kanavin 90271ae079 src/fcxml.c: avoid double free() of filename
It's also freed after bail1, so no need to do it here.
2017-10-12 11:27:07 +09:00
Behdad Esfahbod f4a2a1e577 Remove assert 2017-10-11 17:27:02 +02:00
Akira TAGOH 9fde3461e3 Fix a compiler warning 2017-09-29 14:33:17 +09:00
Behdad Esfahbod f504b2d6a1 Require freetype >= 2.8.1
2.8.0 had a bad bug with loading 'avar' table.  Let's update requirement and cleanup
fifteen years of ifdefs!
2017-09-28 19:49:05 -04:00
Behdad Esfahbod 1580593ecc Merge branch 'varfonts2'
https://lists.freedesktop.org/archives/fontconfig/2017-September/006048.html
2017-09-28 14:52:41 -04:00
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
Behdad Esfahbod 161c738547 Use binary-search for finding name table entries
VotoSerifGX has over 500 named instances, which means it also has over a thousand
name table entries.  So we were looking for names for over 500 pattern, looking for
some thirty different name-ids, and using linear search across the 1000 entries!

Makes scanning VotoSerifGX three times faster.  The rest is probably the lang
matching, which can also be shared across named-instances.  Upcoming.
2017-09-27 18:47:42 -04:00
Behdad Esfahbod 261464e0e2 Simplify name-table platform mathcing logic
There's no "all other platforms", there was just ISO left.
Hardcode it in.
2017-09-27 18:37:00 -04:00
Behdad Esfahbod 55d04e25d6 Don't convert nameds to UTF-8 unless we are going to use them 2017-09-27 18:37:00 -04:00
Behdad Esfahbod f99278112d Whitespace 2017-09-27 18:37:00 -04:00
Behdad Esfahbod 554041d596 Fix whitespace-trimming loop and empty strings... 2017-09-27 18:37:00 -04:00
Behdad Esfahbod a74109a114 Move whitespace-trimming code to apply to all name-table strings
If it's good, it's good for everything!
2017-09-27 18:37:00 -04:00
Behdad Esfahbod 869dfe0bdc [varfonts] Reuse charset for named instances
This didn't give me the speedup I was hoping for, though I do get around 15% for VotoSerifGX.
2017-09-27 18:37:00 -04:00
Behdad Esfahbod bf4d440e7f Separate charset and spacing code
For variable-font named-instances we want to reuse the same charset and redo the spacing.
2017-09-27 12:37:23 -04:00
Akira TAGOH 052115aa83 Fix again to keep the same behavior to the return value of FcConfigParseAndLoad
https://bugs.freedesktop.org/show_bug.cgi?id=102141
2017-09-21 14:04:10 +09:00
Akira TAGOH 5603e06aeb Revert "Keep the same behavior to the return value of FcConfigParseAndLoad"
This reverts commit dc56ff8040.
2017-09-21 14:03:51 +09:00
Behdad Esfahbod 15b5016ccd [varfonts] Don't reopen face for each named instance
Makes scanning of Voto (over 500 named instaces) twice faster.

Next, avoid charset / lang recalculation for each of those.
2017-09-20 19:39:59 -07:00
Behdad Esfahbod 2d0063948a [varfonts] Do not set postscriptname for varfont pattern 2017-09-20 16:36:03 -07:00
Behdad Esfahbod be735d6a68 [varfonts] Skip named-instance that is equivalent to base font 2017-09-20 16:36:03 -07:00
Behdad Esfahbod 8183194ae3 [varfonts] Don't set style for variable-font pattern 2017-09-20 13:21:52 -07:00
Behdad Esfahbod 131219f9e5 [varfonts] Comment 2017-09-20 13:21:52 -07:00
Behdad Esfahbod e85afde2d6 [varfonts] Minor 2017-09-20 13:21:52 -07:00
Behdad Esfahbod 5ee9c38df7 Revert "[varfonts] Use fvar data even if there's no variation in it"
This reverts commit 57764e3a36449da25bb829c34cb08c54e9e5de90.

For regular font pattern we don't look into fvar, so it doesn't make sense to
get non-variation from it either.
2017-09-20 13:21:52 -07:00
Behdad Esfahbod 7e1b84100d Minor 2017-09-20 13:21:52 -07:00
Behdad Esfahbod 01f14de417 [varfonts] Use fvar data even if there's no variation in it 2017-09-20 13:21:52 -07:00
Behdad Esfahbod 38a6d6fba0 Fix possible div-by-zero 2017-09-20 13:21:52 -07:00
Behdad Esfahbod 0ed241cb30 Implement more config bool operations for boolean types
Meh.
2017-09-20 13:21:52 -07:00
Behdad Esfahbod 2544bc5343 Add FcDontCare value to FcBool
This can be used for FC_VARIABLE=FcDontCare for example, to opt into getting
variable fonts for clients that support using them.
2017-09-20 13:21:13 -07:00
Behdad Esfahbod c2fcde498a [varfonts] Map from OpenType to Fontconfig weight values
Oops.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod a79f367c3f Fix range comparision operators implementation 2017-09-20 13:13:35 -07:00
Behdad Esfahbod 5bbdffd2c2 Add separate match compare function for size
Has two distinctions from FcCompareRange():
1. As best value, it returns query pattern size, even if it's out of font range,
2. Implements semi-closed interval, as that's what OS/2 v5 table defines
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 2db7ca7d58 In RenderPrepare(), handle ranges smartly
If font claims to support range [100,900], and request is for [250], then
return [250] in "rendered" pattern.  Previously was returning [100,900].

This is desirable for varfonts weight and width, but probably not for size.
Will roll back size to return request size always, for non-empty ranges.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 6a13a21e40 [varfonts] Fetch optical-size for named instances 2017-09-20 13:13:35 -07:00
Behdad Esfahbod 0f9bbbcf8f [varfonts] Query variable font in FcFreeTypeQueryAll()
Returns varfont pattern at the end.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 585f08715b Fix instance-num handling in collections
Ouch!
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 83b4161108 [varfonts] Query varfonts if id >> 16 == 0x8000
If "instance-number" part of face id is set to 0x8000, return a pattern
for variable font as a whole.  This might have a range for weight, width,
and size.

If no variation is found, NULL is returned.

Not hooked up to FcQueryFaceAll() yet.  For now, can be triggered using
fc-query -i 0x80000000
2017-09-20 13:13:35 -07:00
Behdad Esfahbod d3a7c3ce69 [varfonts] Change FC_WEIGHT and FC_WIDTH into ranges 2017-09-20 13:13:35 -07:00
Behdad Esfahbod f034c86756 Print ranges as closed as opposed to half-open
There's nothing assymetrical about how we match them.  Previously we "considered"
them half-open because the OS/2 spec had usLowerOpticalPointSize as inclusive
and usUpperOpticalPointSize as exclusive.  But we do not respect that.

Note that the parsing code accepts both anyway, because of the way our sscanf()
usage is written...
2017-09-20 13:13:35 -07:00
Behdad Esfahbod a4bd5b7c7a [varfonts] Change id argument in FcFreeTypeQuery* to unsigned int
Going to use the top bit to query varfonts.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 819d3a5541 [varfonts] Add FC_VARIABLE
For now, we mark all fonts as non-variable.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 80e155c1c0 [varfonts] Add FC_FONT_VARIATIONS
This is for clients to passthru font variation settings.  Modeled
similar to FC_FONT_FEATURES.  Each element value is for one axis
settings, eg. "abcd=2.3" where 'abcd' is the OpenType Font Variations
axis tag.

Needs docs update.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod de00bdb01f Indent 2017-09-20 13:13:35 -07:00
Behdad Esfahbod 66f082451d Check instance-index before accessing array
Ouch!
2017-09-20 13:13:35 -07:00
Behdad Esfahbod b6440cbd7f In FcSubstituteDefault(), handle size range
Takes the midpoint...
2017-09-20 13:13:35 -07:00
Behdad Esfahbod b4813436a3 Rewrite FcCompareRange()
Much simpler now.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod e7a0a0a999 Rename FcCompareSizeRange() to FcCompareRange() 2017-09-20 13:13:35 -07:00
Behdad Esfahbod 7519c567e1 Remove FcCompareSize()
Use FcCompareNumber().  The FcCompareSize() returns 0 ("perfect match")
if v2 is zero.  I cannot think of a use-case for this.  The code has been
there from initial commit in 2002.  I suppose back then Keith had a use
for size=0 to mean scalable or something.  Anyway, remove and see.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 6eb7e5ae81 Accept NULL in for spacing in FcFreeTypeCharSetAndSpacing() 2017-09-20 13:13:35 -07:00
Behdad Esfahbod 27a6a299e0 Add FcFreeTypeQueryAll()
Like FcFreeTypeQuery(), but adds patterns for all fonts found, including named
instances of variable fonts.  If id is -1, then all collection faces are queried.
Returns number of fonts added.

This merges the same face loop that was in fc-query. and fcdir.c.

Needs documentation update.
2017-09-12 17:17:05 -04:00
Behdad Esfahbod a8bbbfb601 Minor 2017-09-12 17:02:27 -04:00
Behdad Esfahbod 60b2cf8e4c Call FT_Get_Advance() only as long as we need to determine font width type 2017-09-12 17:02:27 -04:00
Behdad Esfahbod ad0a82b8f8 Inline FcFreeTypeCheckGlyph() 2017-09-12 17:02:27 -04:00
Behdad Esfahbod 1af7518583 Simplify advance-width calculations 2017-09-12 17:02:27 -04:00
Behdad Esfahbod 6f98286e15 Use inline functions instead of macros for a couple of things 2017-09-12 17:02:27 -04:00
Behdad Esfahbod 15eba74ffe Use multiplication instead of division 2017-09-12 17:02:27 -04:00
Behdad Esfahbod ac802955cd Remove unneeded check
FcFreeTypeCheckGlyph() has only one call-site left, and that checks for
glyph != 0 already.
2017-09-12 17:02:27 -04:00
Behdad Esfahbod d7f5332410 Move variables to narrower scope and indent 2017-09-12 17:02:27 -04:00
Behdad Esfahbod 894e5675c8 Mark more parameters FC_UNUSED 2017-09-12 17:02:27 -04:00
Behdad Esfahbod 8f4c4d278d Remove blanks facility from the library
XML parser does not accept it anymore either.
2017-09-12 17:02:27 -04:00
Behdad Esfahbod 3bd4dd27bd Remove fc-glyphname 2017-09-12 17:02:27 -04:00
Behdad Esfahbod c7ef8808c4 Remove unused variable 2017-09-12 17:02:27 -04:00
Behdad Esfahbod 16d7791159 Remove use of psnames for charset construction
This is ancient.  No font we care baout uses them.  Kill.

This also makes fc-glyphname machinery obsolete.  Should be removed.
2017-09-12 17:02:27 -04:00
Behdad Esfahbod 82d6286657 Remove check that cannot fail 2017-09-12 17:02:27 -04:00
Behdad Esfahbod f309819d77 Remove a few unused blanks parameters
The entire blanks thingy is now unused.  We should remove more of it.
2017-09-12 17:02:27 -04:00
Behdad Esfahbod e517886ded Remove unnecessary check
Argument advance is never set to NULL coming into this function.
2017-09-12 17:02:27 -04:00
Behdad Esfahbod 5f6c0594f9 Minor: adjust debug output
Ignore control chars for purpose of emptiness check.  I *think* U+0000 and U+000D
are rendered empty, but since they are not in blanks, for now just ignore them.
2017-09-12 17:02:27 -04:00
Behdad Esfahbod 659afb2987 Add back code for choosing strike, and cleanup
The FT_Select_Size() call is important for bitmap-only fonts.
Put it back.  It was removed in e327c4e54544dac5415e8864e80d6b75a0c900fd
Remove some unused abstractions.
2017-09-12 17:02:27 -04:00
Behdad Esfahbod cd4043da0d Check for non-empty outline for U+0000..U+001F
See comment for reason.
2017-09-12 17:02:27 -04:00
Behdad Esfahbod 028b91c781 Don't even check loca for glyph outline detection
Basically we trust the font cmap table now...

New numbers:

behdad:src 0$ time fc-scan ~/fonts/ > after-noloca

real	0m55.788s
user	0m15.836s
sys	0m17.008s
behdad:src 0$
behdad:src 0$ time fc-scan ~/fonts/ > after-noloca

real	0m24.794s
user	0m12.164s
sys	0m12.420s

Before this change it was:

behdad:src 130$ time fc-scan ~/fonts/ > after

real    0m24.825s
user    0m12.408s
sys     0m11.356s

Not any faster!  I suppose most time is being spent in loading cmap and advances now.
I'll see about loading hmtx ourselves.

With I/O numbers.  Before:

behdad:src 0$ \time fc-scan ~/fonts/ > after
11.66user 12.17system 0:24.03elapsed 99%CPU (0avgtext+0avgdata 487684maxresident)k
2320inputs+50480outputs (21major+11468549minor)pagefaults 0swaps

after:

behdad:src 130$ \time fc-scan ~/fonts/ > after-noloca
11.94user 11.99system 0:24.11elapsed 99%CPU (0avgtext+0avgdata 487704maxresident)k
16inputs+50688outputs (0major+11464386minor)pagefaults 0swaps

We are definitely doing a lot less I/O.  Surprisingly less in fact.  I don't get it.
2017-09-12 17:02:27 -04:00
Behdad Esfahbod ab02a49490 Instead of loading glyphs (with FreeType), just check loca table
Part of https://bugs.freedesktop.org/show_bug.cgi?id=64766#c47

This is the approach introduced in
https://bugs.freedesktop.org/show_bug.cgi?id=64766#c30

Testing it with 11GB worth of stuff, before/after:

behdad:src 130$ time fc-scan ~/fonts/ > before

real	2m18.428s
user	1m17.008s
sys	0m20.576s

behdad:src 0$ time fc-scan ~/fonts/ > after

real	1m12.130s
user	0m18.180s
sys	0m19.952s

Running the after case a second time is significantly faster:

behdad:src 130$ time fc-scan ~/fonts/ > after

real	0m24.825s
user	0m12.408s
sys	0m11.356s

Next I'm going to try to not even read loca...
2017-09-12 17:02:27 -04:00
Behdad Esfahbod 6fb9b8fe49 Minor 2017-09-12 17:01:15 -04:00
Akira TAGOH ee609da358 Fix to work the debugging option on fc-validate 2017-08-22 20:30:34 +09:00
Akira TAGOH 5efa1137b4 Accept 4 digit script tag in FcLangNormalize(). 2017-08-22 17:58:22 +09:00
Akira TAGOH 651f122764 Do not ship fcobjshash.gperf in archive 2017-08-15 18:20:15 +09:00
Akira TAGOH dc56ff8040 Keep the same behavior to the return value of FcConfigParseAndLoad
reverting the behavior accidentally changed by 12b750

https://bugs.freedesktop.org/show_bug.cgi?id=102141
2017-08-13 16:18:46 +09:00
Behdad Esfahbod 41bc5eab84 Fix weight mapping
Ouch!
2017-08-08 15:34:57 -07:00
Behdad Esfahbod 8b29103196 Fix warning 2017-08-04 14:23:10 +01:00
Behdad Esfahbod 484cb300ea Fix sign-difference compare warning 2017-08-04 14:23:10 +01:00
Behdad Esfahbod 9bb36b42c9 Minor 2017-08-04 12:23:28 +01:00
Behdad Esfahbod 064440d597 Ignore 'und-' prefix for in FcLangCompare
See https://bugs.freedesktop.org/show_bug.cgi?id=94551#c54

For example, matching for :lang=und-zsye matches emoji font, but searching
for :lang=und-xyz wouldn't match an emoji font anymore.  Neither does :lang-und.
2017-08-03 11:17:35 +01:00
Akira TAGOH 1bb8e691bd Add und-zsye.orth to support emoji in lang 2017-08-02 15:18:53 +01:00
Behdad Esfahbod 241cc86932 Pass --pic to gperf 2017-07-31 15:56:06 +01:00
Akira TAGOH 5b6af242e1 Fix gcc warnings with enabling libxml2 2017-07-11 15:38:01 +09:00
Akira TAGOH 12b7501bad Add FcConfigParseAndLoadFromMemory() to load a configuration from memory.
https://bugs.freedesktop.org/show_bug.cgi?id=78452
2017-07-07 15:52:15 +09: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 047b42fcca Fix distcheck error 2017-07-05 17:35:28 +09:00
Josselin Mouette e831f12a38 Treat C.UTF-8 and C.utf8 locales as built in the C library.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=717423
https://bugs.freedesktop.org/show_bug.cgi?id=101605
2017-06-27 21:21:18 +09:00
Florent Rougon 60e1fe550a FcCharSetFreezeOrig(), FcCharSetFindFrozen(): use all buckets of freezer->orig_hash_table
As written at:

  https://lists.freedesktop.org/archives/fontconfig/2017-June/005929.html

I think FcCharSetFreezeOrig() and FcCharSetFindFrozen() should use the %
operator instead of & when computing the bucket index for
freezer->orig_hash_table, otherwise at most 8 buckets among the 67
available (FC_CHAR_SET_HASH_SIZE) are used.

Another way would be to change FC_CHAR_SET_HASH_SIZE to be of the form
2**n -1 (i.e., a power of two minus one). In such a case, the & and %
operators would be equivalent.
2017-06-12 17:03:37 +09:00
Florent Rougon b0a5b4b48e FcLangSetCompare(): fix bug when two charsets come from different "buckets"
In fcLangCountrySets, it may happen that two charsets for the same
language but different territories are found in different FcChar32
"buckets" (different "columns" on the same line). This is currently the
case for the following pairs:

  mn-cn  and mn-mn
  pap-an and pap-aw

The FcLangSetCompare() code so far used to return FcLangDifferentLang
instead of FcLangDifferentTerritory when comparing:

  an FcLangSet containing only mn-cn with one containing only mn-mn

or

  an FcLangSet containing only pap-an with one containing only pap-aw

This commit fixes this problem.
2017-06-12 13:36:22 +09:00
Florent Rougon 209619b1a6 Fix erroneous test on language id in FcLangSetPromote()
FcLangSetIndex() indicates "not found" with a non-negative return value.
Return value 0 doesn't imply "not found", it rather means "language
found at index 0 in fcLangCharSets".
2017-06-09 15:52:23 +09:00
Florent Rougon 4970c7e810 Fix an off-by-one error in FcLangSetIndex()
This commit fixes a bug that can be reproduced like this:
  - remove all languages starting with 'a' in fc-lang/Makefile.am (in
    ORTH's definition);
  - rebuild fontconfig with this change (-> new fc-lang/fclang.h);
  - create an FcLangSet 'ls1' that contains at least the first language
    from fcLangCharSets (i.e., the first *remaining* in lexicographic
    order); let's assume it is "ba" for the sake of this description;
  - create an FcLangSet 'ls2' that only contains the language "aa" (any
    language starting with 'a' should work as well);
  - check the return value of FcLangSetContains(ls1, ls2);

The expected return value is FcFalse, however it is FcTrue if you use
the code before this commit.

What happens is that FcLangSetIndex() returns 0, because this is the
index of the first slot after the not-found language "aa" in
fcLangCharSets (since we removed all languages starting with 'a').
However, this index happens to be non-negative, therefore
FcLangSetContainsLang() mistakenly infers that the language "aa" was
found in fcLangCharSets, and thus calls FcLangSetBitGet(ls1, 0), which
returns FcTrue since we've put the first remaining language "ba" in the
'ls1' language set.

The "return -low;" statement previously in FcLangSetIndex() was
inconsistent with the final return statement. "return -(low+1);" fixes
this inconsistency as well as the incorrect behavior described above.
2017-06-09 14:35:43 +09:00