Commit Graph

206 Commits

Author SHA1 Message Date
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 c2fcde498a [varfonts] Map from OpenType to Fontconfig weight values
Oops.
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 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 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 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 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
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
Akira TAGOH add5f7329f Remove unused code 2016-06-15 20:10:31 +09:00
Behdad Esfahbod d05d083e9f [GX] Improve weight mapping
Align the 'wght' axis default value to OS/2 weight value and
adjust accordingly.  This makes both default=1.0 and default=400
models to work.
2016-03-08 17:20:55 -08:00
Behdad Esfahbod 00c8408c6a [GX] Support instance weight, width, and style name 2016-03-08 13:39:05 -08:00
Akira TAGOH 6f929ff37c Fix a memory leak in FcFreeTypeQueryFace 2015-06-17 16:34:29 +09:00
Behdad Esfahbod 346073d9dc Don't set FC_SIZE for bitmap fonts
They get FC_PIXELSIZE set, which is later converted to FC_SIZE using
FC_DPI.
2015-05-27 14:12:49 -07:00
Behdad Esfahbod cb2f096e15 Add bitmap-only font size as Double, not Range
The whole size setting part still smells to me.
2015-05-27 14:12:49 -07:00
Behdad Esfahbod 51756aab18 Only set FC_SIZE for scalable fonts if OS/2 version 5 is present
Part of https://bugs.freedesktop.org/show_bug.cgi?id=80873
2015-05-27 14:12:49 -07:00
Behdad Esfahbod bcfe167e3d Add su[pport for symbol fonts
Adds FC_SYMBOL.

This affects fonts having a cmap with platform 3 encoding 0.
We now map their glyphs from the PUA area to the Latin1 area.

See thread "Webdings and other MS symbol fonts don't display"
on the mailing list.

Test before/after with:
$ pango-view --markup --text='<span fallback="false">&#xd7;&#xf0d7;</span>' --font=Wingdings
2015-05-18 15:26:03 -07:00
Akira TAGOH 3a4136778c Drop unmaintained code
Use four-byte code for foundry as is instead.

https://bugs.freedesktop.org/show_bug.cgi?id=88679
2015-04-22 16:29:25 +09:00
Behdad Esfahbod d997d7c770 Simplify some more 2015-03-03 16:00:39 -08:00
Behdad Esfahbod 9c99baba66 Remove dead code after previous commit 2015-03-03 16:00:39 -08:00