155 Commits

Author SHA1 Message Date
ReadRoberts
0586c06199 [varLib subset CFF2] Set PrivateDict nominal and default WidthX to None
@bedhad
Address issues raised in #1403

I do think setting the dummy CFF2 PrivateDict nominalWidthX and defaultWidthX to None, which leads to the charstring.width also being None,  is a good idea. I originally set them to 0, which produces a charstring width of 0, in order to avoid problems with logic that assumes that the field is good for math. However, I now think that it is better to find errors around charstring type assumptions earlier than later.

 "drop_hints()" is actually not wrong - I did look at this when making the changes. For CFF2 charstrings, self.width is always equal to self.private.defaultWidthX, so the width is never inserted. This is because in psCharstrings.py::T2WidthExtractor.popallWidth(), the test "evenOdd ^ (len(args) % 2)" is alway False.  Left to myself, I would not change this code. If the CFF2 charstring is correct, there is not a problem. if the CFF2 charstring is not correct, then both in drop_hints() and in T2WidthExtractor.popallWidth(), the logic will stack dump. I did add asserts, but am not totally sure it is worth the extra calls.
2018-12-06 11:55:48 -08:00
ReadRoberts
1f2600ff65 [cff2] Add subset.cff functions for CFF/CFF2 class:
desubroutinize
remove_hints
remove_unused_subroutines

Fix issue in cff2mergePen.py because of  removing CFFS2Subrs class in prior commit.
2018-12-04 18:34:22 -08:00
Behdad Esfahbod
cce640a146 [CFF] Minor 2018-11-30 00:13:38 -05:00
Behdad Esfahbod
8b1730774a [CFF] Move varLib.mutator-specific code out of subset.cff 2018-11-29 17:07:51 -05:00
Behdad Esfahbod
f97b802869 [CFF] Minor 2018-11-29 14:20:45 -05:00
Behdad Esfahbod
fb3248ff1b [CFF] Whitespace 2018-11-29 14:15:54 -05:00
Behdad Esfahbod
18cfe2371a [CFF} Rename subset.cffLib to subset.cff 2018-11-29 14:09:57 -05:00
Behdad Esfahbod
d423236019 [CFF] Unbreak subsetter 2018-11-29 14:08:42 -05:00
ReadRoberts
c2abd045b3 [varLib.mutator] Add interpolation of glyph metrics.
Added interpolation of glyph advance width, from HVAR/hmtx, and derivation of new LSB.
Updated tests to match.
Needed to cherrypick from another branch an update for psCharstrings to allow the CFFSubr.draw() method to work.
2018-11-20 12:44:21 -08:00
ReadRoberts
d2d31e57c8 [varLib.mutator] Move CFFs interpolation functions
from subset.__init.py and mutator.py into subset.cffLib.py
2018-11-19 20:10:46 -08:00
ReadRoberts
cf38e84f85 [varLib.mutator] Move test for interpolating CFF2 tables
from varLib_test.py to mutator_test.py
2018-11-19 20:09:11 -08:00
Cosimo Lupo
f99afc70d3
Merge pull request #1326 from BoboTiG/fix-resource-leak
Fix several ResourceWarning: unclosed file and some related improvement
2018-11-16 23:00:24 +00:00
Behdad Esfahbod
e30b830403
Merge pull request #1368 from fonttools/varLib-sparse-masters
[varLib] Support sparse masters
2018-11-15 15:00:00 -08:00
Behdad Esfahbod
0ab515b39e [subset] If charString dehinted to empty, add "endchar"
Fixes https://github.com/fonttools/fonttools/issues/1379
2018-11-15 01:30:26 -05:00
Behdad Esfahbod
986562fe10 [subset] Remove old cruft 2018-11-08 23:16:43 -05:00
Behdad Esfahbod
76c85e3c3b [subset] Fix --no-hinting --desubroutinize
Fixes https://github.com/fonttools/fonttools/issues/1360
2018-11-02 17:52:15 -04:00
Cosimo Lupo
50dae4cc90 subset: don't error if STAT has no AxisValue tables
the minimalist STAT table that varLib produces only contains one DesignAxisRecord
for each fvar axis, and has AxisValueCount=0, thus the AxisValueArray offset is None.
2018-10-30 10:32:36 +00:00
Rob McKaughan
7d59b729ab Include nameIDs referenced by STAT table 2018-09-26 14:50:22 -04:00
Mickaël Schoentgen
ee244406ee Fix several ResourceWarning: unclosed file in subset 2018-09-25 23:04:26 +02:00
Michiharu Ariza
90176ef842 --no-hinting to drop LanguageGroup etc 2018-09-19 22:33:39 +02:00
Behdad Esfahbod
1bec227849 [subset] Fix partial subsetting of AlternateSubst 2018-09-10 15:12:38 +02:00
Behdad Esfahbod
022536212b [subset] Add --no-layout-closure
As oft requested.

I think this fixes https://github.com/fonttools/fonttools/issues/43
2018-09-10 15:09:11 +02:00
Behdad Esfahbod
c895f4f4a2 [subset] Add --layout-scripts
Fixes https://github.com/fonttools/fonttools/issues/1303
2018-08-01 14:29:06 -07:00
Cosimo Lupo
d7ac0ad359
subset: write default file extension based on --flavor or sfntVersion
Fixes https://github.com/fonttools/fonttools/issues/1298
2018-07-21 18:28:33 +01:00
Cosimo Lupo
d570fc038a
use otRound when rounding visual coordinates or deltas
So we now round towards +Infinity in:

- floatToFixed (which fully examplify that quotes from OT spec)
- psCharStrings: when packing floats as fixed 16.16
- t2CharStringPen: when rounding coordinates and advance widths
- subset: when rounding advance widths to compute average
- TupleVariation: rounding gvar deltas
- _g_l_y_f: when rounding coordinates: both in GlyphComponent.{x,y}
  and for GlyphCoordinates.toInt()
- _h_m_t_x: for rounding horiz/vert metrics
- varLib: rounding horiz metrics and deltas
2018-06-14 17:40:11 +01:00
Behdad Esfahbod
2e28fa4a31 [subset] Remove activeLookup tracking during GSUB closure
The memoize handles this as well...

This alone contributes a 10% speedup to the closure op.
2018-06-12 01:01:41 -04:00
Behdad Esfahbod
a856e83112 [subset] Another improvement to GSUB closure algorithm
Save number of subset-glyphs each lookup was closed at, and don't redo work
if number didn't change.  10% speedup with NotoNastaliqUrdu-Regular.
2018-06-11 23:53:22 -04:00
Behdad Esfahbod
40ca30a82b [subset] Improve GSUB closure memoize algorithm
Instead of memoizing the tuple of <lookup-idx,current-glyphs>, use a mapping of
lookup-idx->current-glyphs instead. Saves some work. Speeds up 5%ish on
NotoNastaliqUrdu-Regular.
2018-06-11 23:46:42 -04:00
Behdad Esfahbod
f3c06fba3f Revert "[subset] Set to None empty Coverage tables in MarkGlyphSets"
This reverts commit 02616ab9b39d2e9618baebc4e051ae0a85200751.

Make OTS happy. Phew.
https://github.com/khaledhosny/ots/issues/172
2018-05-08 16:28:17 -07:00
Behdad Esfahbod
2ab38f9ba4 [subset] Handle None coverages in MarkGlyphSets 2018-05-08 15:24:36 -07:00
Behdad Esfahbod
02616ab9b3 [subset] Set to None empty Coverage tables in MarkGlyphSets 2018-04-25 20:59:18 -07:00
Behdad Esfahbod
fc819d6235 [subset] Don't drop a GDEF that only has VarStore 2018-04-25 16:10:57 -07:00
Behdad Esfahbod
1917d6913b [subset] Remove more nonsensical code
Remaining parts of 4e3192163470ca168ff753cb526480e59bc77e1a
2018-04-25 16:09:30 -07:00
youlun
2bcca15c56 Add font-number parameter for subset 2018-04-16 12:47:25 +02:00
Cosimo Lupo
78faa0c416
subset: minor: remove duplicate 'cvar' from list of hinting tables 2018-04-13 17:39:10 +02:00
Behdad Esfahbod
ebdd52512b [subset] Passthrough 'cvar'
https://github.com/fonttools/fonttools/issues/1237#issuecomment-381150772
2018-04-13 16:38:46 +02:00
Cosimo Lupo
4dfc7bf24e
subset: remove assert to handle HVAR direct mapping
It looks like this was (at least partially) implemented in
f01c86ca9b

Should fix https://github.com/fonttools/fonttools/issues/1237

I'm still not sure about that "File a bug." when AdvWidthMap is None,
but either LsbMap or RsbMap are not None..

And we still need to add tests for this though.
2018-04-13 15:16:31 +02:00
Behdad Esfahbod
4e31921634 [varLib] Remove nonsensical code
GSUB has no positioning, so cannot have any Device tables with variations.
2018-02-21 00:19:54 -08:00
Behdad Esfahbod
ba52a32fed [varStore] Refactor code around 2018-02-19 19:07:22 -08:00
Behdad Esfahbod
7657f0c899 [varStore] Minor 2018-02-19 18:59:12 -08:00
Behdad Esfahbod
64834d079d [varStore] Add subset_varidxes as method on VarStore 2018-02-19 18:57:09 -08:00
Behdad Esfahbod
f01c86ca9b [subset] Handle direct mapping in HVAR/VVAR
Untested. Sigh...

Last part of https://github.com/fonttools/fonttools/issues/1179
2018-02-18 23:25:42 -08:00
Behdad Esfahbod
200268846a [subset] Fold prune_post into subset for HVAR/VVAR
Need to finish direct mapping.
2018-02-18 23:18:34 -08:00
Behdad Esfahbod
3cfc4a4be2 [subset] Move code around 2018-02-18 23:16:00 -08:00
Behdad Esfahbod
e33ba6ddd6 [subset] Assert HVAR/VVAR case we do NOT handle
For now fixes https://github.com/fonttools/fonttools/issues/1179
2018-02-18 23:08:46 -08:00
Behdad Esfahbod
788a306e4a [subset] Prune HVAR/VVAR
Part of https://github.com/fonttools/fonttools/issues/1179
2018-02-18 23:06:21 -08:00
Behdad Esfahbod
d1b335505c [subset] Implement basic HVAR/VVAR support
Needs more work.

Part of https://github.com/fonttools/fonttools/issues/1179
2018-02-18 22:41:11 -08:00
Behdad Esfahbod
d5c480aabd [subset] If a table is dropped because we don't know it, warn, not log 2018-02-18 19:30:39 -08:00
Behdad Esfahbod
67814fd3b3 [subset] Prune GDEF VarStore
Mostly fixes https://github.com/fonttools/fonttools/issues/1179
2018-02-18 19:20:00 -08:00
Cosimo Lupo
d2298be083
[subset] modify --name-IDs help message to match new defaults 2018-02-16 17:58:14 +00:00