256 Commits

Author SHA1 Message Date
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
Michiharu Ariza
12d1b053f7 renaming 2019-04-23 09:28:03 -07:00
Michiharu Ariza
5e1dea329b subset HVAR/VVAR with retain-gids
1. if AdvWidthMap/AdvHeightMap missing, deltas for unused (emptied) glyphs are zeroed
2. If indexMap exists and unused glyph ID <= last used glyph ID, then its major/minor number set to 0/0
3. If indexMap exists and unused glyph ID > last used glyph ID, then its major/minor number set to that of the last used glyph (removed from table)
2019-04-22 16:56:01 -07:00
Cosimo Lupo
0cf54802c5
[subset] fixed VVAR subset failing with --retain-gids
Fixes https://github.com/fonttools/fonttools/issues/1552
2019-04-08 17:28:05 +01:00
ReadRoberts
635537604d Fix for subsetting HVAR tables that have an AdvanceWidthMap when the --retain-gid option is used. Needed to make subset_test.py::test_retain_gids_cff2 tests pass. 2019-03-19 16:27:21 +00:00
justvanrossum
723e7a1d3c updated inline github issue URLs 2019-03-06 16:01:28 +01:00
Khaled Hosny
835ee4a84b [subset] Update documentation to reflect reality [ci skip]
CBLC/CBDT are no longer dropped by default since
9189d1a1f04a7a808ad9940dc14eb072ff25f115.
2019-03-03 02:30:35 +02:00
Michiharu Ariza
c8d4149b32 Fix issue #1516: subset VVAR (#1517)
* fix #issue 1516: subset VOrgMap

* fixed BsbMap as well

* fix bad edit
2019-02-22 19:23:04 -05: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
Cosimo Lupo
8e8da97a4c [cffLib]: add clear() method to Index class to empty in-place 2019-02-07 01:58:22 +01:00
Cosimo Lupo
97006a0d67 [subset] Fix 'AttributeError: GlobalSubrs' with --desubroutinize option
Fixes #1483

'remove_unused_subroutines' method expects a 'GlobalSubrs' attribute but the 'desubroutinize'
method deletes it. We don't have to call 'remove_unused_subroutines' at the end of 'desubroutinize'
method, we can just delete all the local subroutines, and clear the GlobalSubrsIndex.

Only call 'remove_unused_subroutines' method once, when we are not desubroutinizing.
2019-02-07 01:51:05 +01:00
Garret Rieger
d376057fb6 Insert empty widths into hdmx when retaining gids. 2019-01-18 17:32:04 -08:00
Cosimo Lupo
fe40af6d99
minor 2019-01-16 16:10:13 +00:00
Cosimo Lupo
6b4474b2c4
[subset] actually, ignore the width of emptied charstrings
basically, implies setting them to their defaultWidthX, which is the most efficient
way to store these (unnecessary) piece of data.
2019-01-16 16:01:12 +00:00
Cosimo Lupo
3e400c8828
don't add width and endchar for empty glyphs if it's CFF2
This also seems to fix https://github.com/fonttools/fonttools/issues/1448
2019-01-16 14:34:41 +00:00
Cosimo Lupo
336abfcaf0
[subset] set charstring's effective width to 0 when --retain-gids
seems to be the consensus, despite this may add a few bytes when
the emptied glyph's width is different from PrivateDict.defaultWidthX
2019-01-15 15:24:26 +00:00
Cosimo Lupo
af1a0d1fe5
[subset] set emptied CFF charstrings to 'endchar' with --retain-gids
Part of #1446
2019-01-15 14:07:54 +00:00
Behdad Esfahbod
dd081d64dc [subset] Add --retain-gids to retain glyph indices 2019-01-14 16:45:50 -05:00
Behdad Esfahbod
03ad219493
Merge pull request #1402 from fonttools/clean-cff2vf-2
cff2 vf fixes. Make calc_bounds work, fix subsetting bug.
2018-12-11 20:31:11 -05:00
ReadRoberts
3a04a73b0c [cff2 varlib subset] Clean up syntax
x != None -> x is not None.
2018-12-11 17:07:51 -08:00
ReadRoberts
ebc1b0b779 [cff2 varlib subset] Add message to assert for when a CFF2 charstring has an initial width. 2018-12-10 10:44:59 -08:00