6880 Commits

Author SHA1 Message Date
Cosimo Lupo
d9ad9d8ef5
instancer: set OS/2 weight/width and post.italicAngle 2019-05-08 18:46:43 +01:00
Cosimo Lupo
2d99beb0da
instancer: distinguish full/partial instance in log and outfile
and call argparse parser.error() instead of letting ValueError propagate
when parsing CLI options in parseArgs
2019-05-08 17:23:24 +01:00
Cosimo Lupo
178840dcf9
instancer: add --no-overlap to CLI options 2019-05-08 17:23:24 +01:00
Cosimo Lupo
5871a754de
instancer: set mac overlap glyf flags when fully instancing
like varLib.mutator does
2019-05-08 17:23:24 +01:00
Cosimo Lupo
5a530880c0
instancer: prune unused name records after instancing 2019-05-08 11:38:38 +01:00
Cosimo Lupo
0010a3cd9a
instancer: return default deltas as floats from instantiateTupleVariationStore
Do not round them to integer, but let the caller do the rounding immediately before adding them to the default instance (or just before compiling the binary table as with glyf).

This ensures that the glyphs' left sidebearings are calculated in the same way as they were by varLib.mutator.
If we round deltas too early, then we may get off-by-one differences.
See the glyf table setCoordinates method where left sidebearings are computed.
2019-05-07 14:05:27 +01:00
Cosimo Lupo
1041cf90ef
_g_l_y_f: don't return component flags in getCoordinatesAndControls
varLib._GetCoordinates (which this method is copied from) did not return such data either.

The problem with also including component flags in the returned controls
tuple is that different masters may happen to have different component
flags (e.g. if one master has USE_MY_METRICS, another doesn't).
2019-05-03 18:59:32 +01:00
Cosimo Lupo
82662e31f0
Merge pull request #1596 from anthrotype/partial-instantiate-avar
[instancer] partially instantiate avar, STAT and fvar
2019-05-03 13:38:26 +01:00
Cosimo Lupo
89ce41be55
instancer_test: add test for instantiateSTAT
added a dummy STAT table to PartialInstancer-VF.ttx font that has all 4 AxisValue formats.
It doesn't have contain AxisValue for each fvar NamedInstance like the spec recommends, but it's ok for the sake of this test
2019-05-03 13:32:06 +01:00
Cosimo Lupo
3bfff09c8c
instancer: remap STAT AxisValue.AxisIndex
if STAT table contains no DesignAxisRecord, then keep it empty and skip.
2019-05-03 13:29:43 +01:00
Cosimo Lupo
aa6c9a1110
instancer: drop STAT DesignAxes and AxisValues for pinned axes 2019-05-01 19:25:41 +01:00
Cosimo Lupo
b8a33d0c75
instancer: drop STAT when varfont fully instanced
varLib.mutator does the same.

Ideally we would keep STAT if has any extra (inter-family) DesignAxis or it font was only partially instanced. We can improve on this later as needed.
2019-05-01 18:30:49 +01:00
Cosimo Lupo
8eed2a2ec0
instancer_test: add test for instantiateFvar 2019-05-01 15:54:58 +01:00
Cosimo Lupo
c8d82e809d
instancer_test: add test for instantiateAvar 2019-05-01 15:48:00 +01:00
Cosimo Lupo
cbf1a854ee
instancer_test: fix MVAR/HVAR tests now that pinned VarRegionAxis are dropped 2019-05-01 15:48:00 +01:00
Cosimo Lupo
d478ef050f
instancer: partially instantiate avar and fvar
for avar, we drop segments of the axes being pinned.

for fvar, we drop the pinned axes and all the named instances whose coordinates are different from the pinned location.
2019-05-01 15:47:56 +01:00
Cosimo Lupo
691547b00b
Merge pull request #1583 from anthrotype/partial-instantiate-HVAR
[instancer] support instantiating HVAR and VVAR  (TTF only for now)
2019-05-01 12:50:45 +02:00
Cosimo Lupo
76fb26306d
instancer: add comments in instantiateHVAR
as per nyshadhr9's review in https://github.com/fonttools/fonttools/pull/1583
2019-05-01 11:49:01 +01:00
Cosimo Lupo
2a1e6a1fd5
instancer_test: test instancing HVAR table
Aldo added AdvWidthMap to PartialInstancer-VF.ttx test font
2019-04-29 12:51:34 +02:00
Cosimo Lupo
c5ec06d82f
instancer: remove unused regions from VarRegionList
if the original VarStore had any regions in VarRegionList that wasn't
even referenced in any VarData VarRegionIndex, this makes sure we
remove those as well from VarRegionList (and remap the VarRegionIndex
accordingly)
2019-04-29 12:51:34 +02:00
Cosimo Lupo
002de44c13
instancer_test: add vmtx to PartialInstancer-VF.ttx
used in gvar unit tests in instancer_test.py
2019-04-29 12:51:34 +02:00
Cosimo Lupo
7b5202cd79
glyf: only recalcBounds once in setCoordinates
glyph.recalcBounds is called unconditionally a few lines below within the same
setCoordinates method, just after setting the new glyph's coordinates.
We don't need to call recalcBounds twice.
Only empty glyphs with numberOfContours == 0 may not have xMin set.
recalcBounds ensure it's set to 0 for those.
2019-04-29 12:51:34 +02:00
Cosimo Lupo
1e6f8bc39b
instancer: support partial instancing VVAR table as well
for TrueType VF only yet
2019-04-29 12:51:34 +02:00
Cosimo Lupo
91089b7a1b
glyf: support setting vmtx advance/tsb from phantom points 2019-04-29 12:51:34 +02:00
Cosimo Lupo
2b50b94ed7
instancer: support partial instancing HVAR
We don't actually apply deltas to hmtx since these have already been applied
from the gvar deltas when we call glyf.setCoordinates method using the glyf
phantom points.

We simply call instantiateItemVariationStore on HVAR.VarStore to remove
regions and scale remaining deltas, but ignore the return value.
We only run VarStore.optimize() if the HVAR originally has an AdvWidthMap,
if it does not then it uses a direct implicit GID->VariationIndex mapping
for advance widths deltas, and we keep the VariationIndex unchanged by
not optimizing VarStore.

If all axes in fvar are being instanced, then we simply delete HVAR
(just like varLib.mutator currently does).

VVAR is not supported yet because we do not set the 3rd and 4th phantom points
from gvar to the vmtx table yet (this should be done in glyf.setCoordinates).

Also, supporting CFF2 would need more work, in that HVAR there is required
and we need to apply the deltas to hmtx/vmtx in here.
2019-04-29 12:51:33 +02:00
Cosimo Lupo
bdef36501f
instancer: raise NotImplementedError with CFF2 table for now 2019-04-29 12:51:33 +02:00
Cosimo Lupo
1b5393acdd
instancer: call optimize() after instantiateItemVariationStore, not inside
for HVAR/VVAR without indirect mappings, we can skip calling VarStore.optimize() and
keep a direct mapping from GID to VarIdx
2019-04-29 12:51:33 +02:00
Cosimo Lupo
349417d57e
varLib: rename {H,V}VAR_FIELDS constants
we shall reuse them from varLib.instancer too
2019-04-29 12:51:33 +02:00
Cosimo Lupo
aacbc7153d
instancer: capitalise 'MVAR' in method names 2019-04-29 12:51:33 +02:00
Cosimo Lupo
f74e82fec5
Merge remote-tracking branch 'origin/master' into partial-instancer 2019-04-29 12:47:37 +02:00
Cosimo Lupo
06e44e8503
Bump version: 3.41.0 → 3.41.1.dev0 2019-04-29 12:41:26 +02:00
Cosimo Lupo
1db1cdb4c7
Release 3.41.0 2019-04-29 12:41:25 +02:00
Cosimo Lupo
ba70056dac
Update changelog [skip ci] 2019-04-29 12:39:12 +02:00
Read Roberts
5b3db36670
Sparse cff2vf support (#1591)
* Added getter (in the form of a property decorator) for T2Charstring.vsindex. Fixes endless compile loop in some circumstances.

Fixed bug in mutator: need to remove vsindex from snapshotted charstrings, plus formatting clean up

* 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.

* in varLib/cffLib.py, add support for sparse sources, and sources with more than one model, and hence more than one VarData element in the VarStore.

CFF2 source fonts with multiple FontDicts in the FDArray need some extra work. With sparse fonts, some of the source fonts may have a fewer FontDicts than the default font. The getfd_map function() builds a map from the FontDict indices in the default font to those in each region font. This is needed when building up the blend value lists in the master font FontDict PrivateDicts, in order to fetch PrivateDict values from the correct FontDict in each region font.

In specializer.py, add support for CFF2 CharStrings with blend operators. 1) In generalizeCommands, convert a blend op to a list of args that are blend lists for the following regular operator. A blend list as a default font value, followed by the delta tuple. 2) In specializeCommands(), convert these back to blend ops, combining as many successive blend lists as allowed by the stack limit.

Add test case for sparse CFF2 sources.
The test font has 55 glyphs. 2 glyphs use only 2 sources (weight = 0 and 100). The rest use 4 source fonts: the two end points of the weight axis, and two intermediate masters. The intermediate masters are only 1 design space unit apart, and are used to change glyph design at the point in design space. For the rest, at most 2 glyphs use the same set of source fonts. There are 12 source fonts.

Add test case for specializer programToCommands() and commandsToProgram by converting each CharString.program in the font to a command list, and back again, and comparing original and final versions.
2019-04-26 09:33:52 -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
6edf6257e6
Merge pull request #1582 from fonttools/max_ctx_recalc
(Re)calculate OS/2.usMaxContext value
2019-04-26 06:52:32 -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
Cosimo Lupo
eb49e464a2
Merge pull request #1586 from silnrsi/bugfix4
Fix typo in silf table
2019-04-23 18:43:15 +02:00
Michiharu Ariza
12d1b053f7 renaming 2019-04-23 09:28:03 -07:00
Martin Hosken
5a97d0ace2 Fix typo in silf table 2019-04-23 23:24:25 +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
fe1fb45eff
Merge remote-tracking branch 'origin/master' into partial-instancer 2019-04-20 17:51:56 +01:00
Cosimo Lupo
5a7fe0556f
otTables: set CompCount in LigatureSubst.fromXML
https://github.com/fonttools/fonttools/issues/1584#issuecomment-485140779
2019-04-20 17:45:38 +01:00
Cosimo Lupo
71812bbb29
otBase: call populateDefaults() in BaseTTXConverter.fromXML
https://github.com/fonttools/fonttools/issues/1584

This will initialise to None all the missing fields for top-level OT tables like GPOS or GSUB after importing fromXML
2019-04-20 17:44:47 +01:00
Cosimo Lupo
fb03be3182
Merge pull request #1580 from anthrotype/instantiate-gdef-gpos
[partial-instancer] support instantiating GDEF and GPOS
2019-04-20 10:30:40 +01:00
Cosimo Lupo
544f6aae43
instancer_test: add test for instancing GPOS with kern and mark features 2019-04-18 17:37:08 +01:00
Cosimo Lupo
7209862e89
varLib: initialize all fields to None in new empty GDEF
code elsewhere assumes that all optional fields in OT tables are initialized
to None (that is the case when decompiling from a file).
This patch makes sure that the new GDEF table build by varLib when creating
a new VF is properly initialised.
Ideally we wouldn't have to do that manually, but the constructor would
take care of that. But otData-generated classes are special...
2019-04-18 17:29:56 +01:00