83 Commits

Author SHA1 Message Date
Cosimo Lupo
dbcb9d6cee parametrize test_subset_single_glyph_per_svg, as per review 2021-11-16 14:06:24 +00:00
Cosimo Lupo
07455790b1 simplify ranges() generator 2021-11-16 14:06:24 +00:00
Cosimo Lupo
863c9de57c subset/svg_test: test more complex document with cross-references 2021-11-15 17:08:55 +00:00
Cosimo Lupo
a79106d09a add simple subset/svg_test.py 2021-11-15 17:08:55 +00:00
Cosimo Lupo
6df6db840e test subsetter doesn't fail when (optional) ClipList is empty
Kudos to Qunxin for catching the bug
2021-10-11 16:43:18 +02:00
Khaled Hosny
232b2ccbc4 Move the rest of py23 module to textTools
Change all imports to use textTools module, except the test_py23.py test
which is kept until we decide to remove the module (if ever).
2021-08-20 01:29:45 +02:00
Cosimo Lupo
99743c14df subset: explicitly subset ClipList, avoids warning when lazy-loading
relying on ClipList.compile to drop unused clips based on updated glyphOrder won't work when font is loaded lazily (default for subsetter), because ClipList gets decompiled too late (after glyphOrder has already been modified) and this produces warnings about missing glyphIDs.
Better to make the subsetter explicilty prune unused clips.
2021-08-18 09:42:10 +02:00
Khaled Hosny
000bf81700 Default to "\n" for newlinestr instead of None
If newlinestr is None, os.linesep is used, bu it is the third millennium
and we don’t need or want different line endings per-platform.
2021-07-30 04:12:33 +02:00
Cosimo Lupo
11871673ff [subset] fixed CPAL pruning after removal of ColorIndex 2021-07-23 17:27:57 +01:00
Cosimo Lupo
d0d59d2f2c Add PaintScale* and Paint{Rotate,Skew}* variants
This updates fonttools to match the latest draft COLRv1 spec at https://github.com/googlefonts/colr-gradients-spec/pull/290

Summary of changes:
- Added 8 new PaintScale* tables: with/without centers, uniform vs non-uniform
- Added *AroundCenter variants to PaintRotate and PaintSkew (default versions no longer have centerX/Y defaulting to origin)
- PaintRotate, PaintSkew and PaintComposite formats re-numbered
2021-06-28 18:38:47 +01:00
Cosimo Lupo
1cb7e36bbd COLRv1: rename otData structs to remove 'V1' to match updated draft spec
This is a breaking change (but the COLRv1 API was already marked as unstable and subject to change)

The changes in this PR are meant to match the changes from the COLRv1 draft spec at:
https://github.com/googlefonts/colr-gradients-spec/pull/302
2021-06-28 16:13:47 +01:00
Cosimo Lupo
6a97d4cfdd subset_test: check we keep empty 'size' but drop empty 'ssXX' features
https://github.com/fonttools/fonttools/issues/2324
2021-05-27 09:33:29 -06:00
Cosimo Lupo
447116fdba Add test to reproduce issue 2312 2021-05-19 20:05:36 +01:00
Cosimo Lupo
2981e5f6ca subset: test mixed COLR v0/v1 with subset excluding all v0 glyphs
This currently throws a KeyError: ('uniE004', 'BaseGlyphRecordArray')
2021-05-14 10:43:24 +01:00
Cosimo Lupo
2136aac0f0 subset: fix pruning unused CPAL palettes when 0xFFFF is present
FIxes https://github.com/fonttools/fonttools/issues/2257
2021-04-06 19:43:45 +01:00
Cosimo Lupo
a4f42d3b18 subset_test: add tests for PairPos2 useClass0 #2221 2021-03-29 16:18:42 +01:00
Just van Rossum
5fc65d7168
Misc py23 cleanups (#2243)
* Replaced all from ...py23 import * with explicit name imports, or removed completely when possible.
* Replaced tounicode() with tostr()
* Changed all BytesIO ans StringIO imports to from io import ..., replaced all UnicodeIO with StringIO.
* Replaced all unichr() with chr()
* Misc minor tweaks and fixes
2021-03-29 11:45:58 +02:00
Behdad Esfahbod
6b2b2f4949 [Tests] Fix most test expectations for ClassDef[12] .Format removal 2021-03-23 11:43:46 -07:00
Behdad Esfahbod
b62170e86d [Tests] Fix most tests expectations for LigatureSubst .Format change 2021-03-23 11:43:15 -07:00
Behdad Esfahbod
61b06a7fe0 [Tests] Fix most tests expectations for SingleSubst .Format change 2021-03-23 11:43:03 -07:00
Behdad Esfahbod
de81aae164 [Tests] Fix more tests expectations for Coverage/ClassDef .Format change 2021-03-23 11:42:54 -07:00
Behdad Esfahbod
975f85ed72 [Tests] Fix most tests expectations for Coverage/ClassDef .Format change 2021-03-23 11:42:38 -07:00
Cosimo Lupo
09af39ab53
subset: donwgrade COLRv1 to v0 if all v1 glyphs are dropped 2021-02-15 11:58:56 +00:00
Cosimo Lupo
55c9a0a1ef
update subset_test.py using new COLRv1 dict format 2021-02-15 11:15:42 +00:00
Cosimo Lupo
056aba8e4a
prune unused CPAL palette entries after subsetting COLR glyphs
Fixes https://github.com/fonttools/fonttools/issues/2174
2021-02-15 11:15:42 +00:00
Cosimo Lupo
dda10e0f00
WIP: add test_subset_COLRv1 2021-02-15 11:12:16 +00:00
Nikolaus Waxweiler
03655e55d3 Change test data to make it pass 2021-01-13 16:30:46 +00:00
Nikolaus Waxweiler
586144442d Add test 2021-01-12 17:21:22 +00:00
Khaled Hosny
d8e546df5f [subset] Allow LangSys tags in --layout-scripts
Allow specifying which LangSys tags to accept for each script, using
script.lang form. For example:

    --layout-scripts=arab.dflt,arab.URD,latn

To keep DefaultLangSys and “URD” language for “arab” script, and all
languages for “latn” script.
2020-11-20 23:38:29 +02:00
Cosimo Lupo
8bbf30d569
subset_test: add subset of Iosekva-Medium.ttf with ContextSubstFormat3 2020-05-11 18:32:32 +01:00
Cosimo Lupo
c8f591ea8a
subset: remove FeatureVariations table and downgrade to version 0x10000 when empty
https://github.com/fonttools/fonttools/issues/1881#issuecomment-620719882
2020-04-28 18:34:15 +01:00
Cosimo Lupo
ec6205199e
subset_test: add test for dropping 'rvrn' feature and all FeatureVariationRecords
Added a TODO for the partial dropping of FeatureVariationRecords
https://github.com/fonttools/fonttools/issues/1881#issuecomment-619415044
2020-04-25 18:40:19 +01:00
Cosimo Lupo
cf0567d8a5
subset_test: test subsetting font to empty glyf table 2020-02-12 14:25:25 +00:00
Cosimo Lupo
a32fd30c2d
subset_test: add test for optimizing SinglePos format when all subsetted values are same 2020-01-16 18:30:07 -08:00
Cosimo Lupo
9c0c3a1375
subset_test: Add (failing) test to repro #1777
the 'rvrn' feature is being incorrectly dropped because the feature indexes
change if some other feature occuring before 'rvrn' is dropped, like
in this test case.
2019-12-12 12:29:08 +00:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Khaled Hosny
4db8cb237f [subset] Support sbix table
Test font is a subset of:
https://github.com/djrrb/Bungee/blob/master/fonts/Bungee_Color_Fonts/BungeeColor-Regular_sbix_MacOS.ttf
2019-08-01 01:52:38 +02:00
Cosimo Lupo
33fa149c31
subset: Add tests for --flavor option 2019-06-19 11:32:34 +01:00
Khaled Hosny
a56b1af2f6 [subset] Gracefully handle partial MATH table (#1635)
Both MathGlyphInfo and MathVariants can be None, so check for that first
before trying to access their methods.
2019-06-08 17:59:53 -07:00
Khaled Hosny
2861d65e56 [subset] Update font extents in head table
When --recalc-bounds option is used the font extents in the head table
need to be updated, but since tables are lazy-loaded by default the
table will not be recompiled and will keep the old value. Force
recompiling the table by adding it to prune_post_subset tables, though
I’m not 100% sure this is the best approach.
2019-05-17 21:10:11 +02:00
Garret Rieger
dce15980fd Make --retain-gids truncate empty glyphs after the last non-empty glyph. 2019-05-16 10:13:33 -07:00
Cosimo Lupo
96c81ebd8a
Merge pull request #1598 from fonttools/update-OTF-testfonts
Convert OTF font files in test data to ttx files.
2019-05-13 13:09:37 +01:00
Khaled Hosny
b1999a1a0e Add test for previous commit 2019-05-03 01:14:09 +02:00
ReadRoberts
77f72bc62b Convert OTF font files in test data to ttx files.
This required a fix to fontTools/cffLib. When reading a CFF2 variable font (VF) from XML, the VF state in FontDict and PrivateDict does not get set. I made a temporary fix by adding a loop to set PrivateDict.vstore for all the PrivateDict objects after the XML file has been read. This should not be necessary, and in the near future I will revisit both this issue, and the related use of isCFF2 when compiling/decompiling.
2019-05-01 16:01:43 -07:00
Miguel Sousa
9cbfef1972
Merge pull request #1588 from fonttools/hvar-vvar-retain-gids
[subset] HVAR/VVAR with --retain-gids
2019-04-26 06:55:17 -07:00
Miguel Sousa
45596108e2 (Re)calculate OS/2.usMaxContext value
The value is only modified in the context of fontBuilder or subset. It will NOT be modified when using ttx.

maxContextCalc.py was copied from https://github.com/googlefonts/ufo2ft/blob/master/Lib/ufo2ft/maxContextCalc.py

Fixes #1191
Fixes #466
2019-04-24 18:31:12 -07:00
Michiharu Ariza
00dddb1c32 fixed non retain-gids with no AdvWidthMap behavior
deltas in VarData[0] are directly look up by GID so compacted
if any deltas are referenced by LsbMap / RsbMap but not used for advance widths, they are moved to the end of VarData[0]

updated expected test result expect_HVVAR.ttx accordingly
2019-04-24 16:46:21 -07:00
Michiharu Ariza
f028c75d2a issue #1587: AdvWidthMap null with Lsb/RsbMaps non-null
along with tests
2019-04-23 17:03:04 -07:00
justvanrossum
e22453c933 followup to #1531 2019-03-06 16:47:16 +01:00
Read Roberts
7ae6ca8106 [subset CFF] Fix de-subroutinizing bug when subroutines contain hints (#1499)
* [subset CFF] Fix bug in de-subroutinizing when subroutines contain hints, issue 1493

The  code was skipping executing a subroutine if it had already been desubroutinized. The initial set of vstemhm and hstemhm operators and values may be in a subroutine. If a charstring is being executed which calls such subroutines, they still need to be executed in order to count the number of hint values seen, so that the byte length of the hintmask can be calculated.

I fixed this bug by executing subroutines even if they have already been desubroutinized, as long  as  (we don't know yet if we are doing hintmasks) or ( we do need a hintmask, but have not yet seen it).

Clean up code per Cosimo's suggestions:

In arg list for stop_hint_count(), use *args to accept unused argument, rather than a dummy positional argument.

Change stop_hintcount_ops to a from a global variable to a class variable  in _DesubroutinizingT2Decompiler.

Remove un-needed 'return' at line 387

Remove duplicate assignment of cs at line 437

Add patch for the bug where AttributeError is encountered when remove_hints is run after desubroutinize: remove lines deleting the GlobalSubrs for each FontDict. This always needed to be done only once, and is now in any case done in cff.GlobalSubrs.clear(), at the end of the desubroutinize() function.

Changed test case subset_test.py::'test_no_hinting_desubroutinize_CFF' to reference a font with a non-empty GlobalSubr, in order to trigger AttributeError traceback.
2019-02-18 09:43:27 +00:00