226 Commits

Author SHA1 Message Date
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
1df4f1eac1 subset: drop empty features unless 'size' with FeatureParams table
Fixes #2324
2021-05-27 09:33:29 -06:00
Cosimo Lupo
926f721832 return True from SinglePos.prune_post_subset to not change semantics
the useless subtable might have been there to stop the next subtable from applying...
https://github.com/fonttools/fonttools/pull/2313#issuecomment-844497422
2021-05-20 10:01:58 +01:00
Cosimo Lupo
defe0f997a subset: don't prune_post_subset if no SinglePos Value
Fixes https://github.com/fonttools/fonttools/issues/2312
2021-05-19 20:16:14 +01:00
Cosimo Lupo
6e23150507 subset: prune v0 base glyphs and layers when none are left after subsetting COLRv1 table
Thanks Qunxin for reporting the bug!
2021-05-14 10:47:20 +01:00
Behdad Esfahbod
3a6ebb8dc7 [subset] Fix drop-hints implementation in Device tables
Fixes https://github.com/fonttools/fonttools/issues/2272
2021-04-22 12:29:16 -06:00
Behdad Esfahbod
33d9e3d6de [subset] Use bytearray() instead of array.array('B') 2021-04-08 09:41:45 -06:00
Behdad Esfahbod
492118c7b5 [subset] Set glyph.data to b'' instead of ''
Fixes tests after 7adbe44154c1bd8a99668512e88facbcb034f05f
2021-04-08 09:41:45 -06: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
Behdad Esfahbod
8c59d4be0c [subset] Improve PairPosFormat2 subsetting
This does two things:

1. Intersect subsetter glyphset with the table's Coverage before
   passing to ClassDef1 for subsetting.  Anything that doesn't
   get past Coverage wouldn't ever get to ClassDef1,

2. Never reuse class0 of ClassDef2.  There's unspoken assumption
   that ClassDef2's class0 is never used for actual kerning, since
   that's the unbounded "every other glyph" class.  Previously our
   ClassDef subsetter was reusing class0 if "every other glyph"
   happened to become empty because of the subset glyphset.  Don't
   do that for PairPos's ClassDef2.  As a result of this assumption,
   don't keep a PairPosClass2 subtable if only ClassDef2's class0
   survived subsetting.

Would be good to add tests for both.

Related to https://github.com/harfbuzz/harfbuzz/issues/2703
2021-03-29 16:17:27 +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
c321fbe3fa [subset] Call VariationStore.subset_varidxes() as method 2021-03-11 14:12:03 -07:00
Behdad Esfahbod
abc1ba07a4 [misc.roundTools] New module; move otRound() here
Code relying on old place (fixedTools.otRound) still works.
2021-03-04 09:20:43 -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
109c07d16c
subset: support subsetting COLRv1 base glyphs
In COLR.closure_glyphs augment the subset with the glyphs rechable from the COLRv1 base glyphs already in the subset.
In COLR.subset_glyphs, subset and rebuild LayerV1List and BaseGlyphV1List with the base glyphs to keep. Drop COLR if emptied
2021-02-15 11:15:42 +00:00
Nikolaus Waxweiler
06913cc715 Implement format 12 cmap pruning 2021-01-13 16:30:46 +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
Caleb Maclennan
7e3c4acfde
Use 0 not False to disable checkChecksums as documented and used
While False does get the job done, the value is not always treated as
a boolean. It is overloaded so that 1 or greater is True, but more than
1 has a different meaning than 1. Hence usage should always be as an
integer as documented so that it's clear(er) this isn't just an on/off
toggle.
2020-09-10 16:41:30 +03:00
Jouni Seppänen
93a5cbd118 Remove import of py23 fron subset/__init__.py
This import is causing an unsightly DeprecationWarning.

I checked manually: the only names being used from py23 are
open, range and zip, which are defined to be the same as the
corresponding Python 3 builtins, so this should cause no
visible change except for suppressing the warning.
2020-08-02 08:04:19 +03:00
Cosimo Lupo
e63ecc5b5e
subset: FeatureVariations may None in GSUB 1.1
Fixes https://github.com/fonttools/fonttools/issues/2023
2020-07-27 16:53:15 +01:00
Behdad Esfahbod
26ac716a8d [subset/merge] Fix namespace clash
Fixes https://github.com/fonttools/fonttools/issues/1955
2020-06-02 15:13:30 -07:00
Cosimo Lupo
842289c00e
Merge pull request #1944 from anthrotype/fix-subset-context-format-3
subset: fix AttributeError while subsetting Context{Subst,Pos} Format 3
2020-05-13 10:19:10 +01:00
Simon Cozens
2cef07af80
[doc] Add help options to fonttools CLI (#1920)
This adds a `help` verb (and `--help` option) to the `fonttools` command line tool. Submodules will be listed in the help text if they have an importable `main` function with a docstring, and `main`'s docstring will be used as the one-line description for the help text.
2020-05-12 06:31:13 +01:00
Cosimo Lupo
890c5061b5
subset: fix issue subsetting Context{Subst,Pos}Format3
Fixes https://github.com/fonttools/fonttools/issues/1879

In ChainContext{Subst,Pos}Format3, the array of input coverages is called
InputCoverage, whereas in non-Chain Context{Subst,Pos}Format3 subtables it
is called simply Coverage.
2020-05-11 13:32:18 +01:00
Cosimo Lupo
d91724d76c
Revert "[doc] Add help options to fonttools CLI" 2020-05-04 17:37:24 +01:00
Simon Cozens
02f23a214c [doc] Add help options to fonttools CLI 2020-05-03 22:59:54 +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
Behdad Esfahbod
cab7d13dc0 [subset] FeatureVariations subsetting is wrong
Fixes https://github.com/fonttools/fonttools/issues/1881
2020-04-20 12:10:05 -07:00
Cosimo Lupo
53c99df8f8
subset: downgrade SinglePos to format 1 if all ValueRecords are same
Fixes https://github.com/fonttools/fonttools/issues/1709
2020-01-16 18:34:12 -08:00
Cosimo Lupo
d68a59a2f2
subset: remap FeatureVariations SubstitutionRecord.FeatureIndex
Fixes #1777
2019-12-12 12:38:31 +00:00
Cosimo Lupo
246e52be70
susbet: minor 2019-09-10 16:52:56 +02:00
Cosimo Lupo
644d7e3b9a
Merge pull request #1698 from khaledhosny/subset-ebdt-fix
[subset] Prune empty strikes in EBDT data
2019-09-10 16:45:29 +02:00
Chris Simpkins
791f619029 refactor array.tostring to array.tobytes
the array.tostring method is deprecated
2019-08-29 23:21:22 -04:00
Khaled Hosny
61bc8458ef [subset] Prune empty strikes in EBDT data
After subsetting some strikes might be empty (strikes don’t have to
cover all glyphs equally) which would cause a key error later when
saving the table.

Fixes https://github.com/fonttools/fonttools/issues/1633
2019-08-17 00:59:44 +02: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
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
Behdad Esfahbod
ce21271c2d [subset] Use _list_subset() more 2019-05-27 13:56:46 -04:00
Behdad Esfahbod
77b394101f [subset] Skip out-of-range class values in mark attachment
Fixes https://github.com/fonttools/fonttools/issues/1478
2019-05-27 13:52:26 -04:00
Behdad Esfahbod
d38e26d324 [subset] Whitespace 2019-05-27 13:44:20 -04: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
ReadRoberts
dbcdde1bee Fix bug in subsetting T2 CharStrings from CFF font. The logic seeks to avoid unnecessarily executing subroutines that have already been subroutinized. It is necessary execute all subroutines when counting hints in order to determine the byte length of mask arguments, but we want to quit doing this when we know that counting hints is no longer necessary,. The previous logic stopped when a [vh]stem operator was seen, as this means there will not be need for hintmask mask arguments However, the [vh]stem operators can be used even when there is a cntrmask, so the logic stopped counting hints too early. 2019-04-30 09:43:13 -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
6ca384fecd tweaks reflecting review 2019-04-24 09:26:17 -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