700 Commits

Author SHA1 Message Date
Cosimo Lupo
f97d126f96
[varLib.builder] ensure VarRegionAxis coordinates are stored as float
These are decompiled as F2Dot14 by otData.py, thus they are written as float when dumping to TTX
2017-03-01 17:26:07 +00:00
Miguel Sousa
3dc8e4fa95 minor change 2017-02-28 05:16:15 -08:00
Cosimo Lupo
ca95a07f24
[interpolate_layout] handle optional 'axes' item; require 'sources'
remove 'instances' as it's not used
2017-02-27 19:44:54 +00:00
Cosimo Lupo
c131bd93f6
[varLib] Fix AttributeError: odict.keys() has no index attribute 'index'
43efa63732 (commitcomment-21073943)
2017-02-27 19:17:04 +00:00
Cosimo Lupo
01d8145288
[varLib] fix undefined name 'masters'
Ouch!
2017-02-27 18:31:38 +00:00
Cosimo Lupo
ee9f2bf24a
[designspace] clarify that designspace items are optional in docstring 2017-02-27 18:12:31 +00:00
Cosimo Lupo
66c6662572
[designspace] refactor
- remove unused import
- use snake_case instead of camelCase
- add two empty lines between module-level definitions
- rename 'elt' variable to 'element'
- don't make extra dict copy in _load_axis
2017-02-27 16:59:35 +00:00
Cosimo Lupo
558e5e172d
[varLib] raise VarLibError if 'sources' missing or empty; treat 'axes' and 'instances' as optional 2017-02-27 16:34:41 +00:00
Cosimo Lupo
ba44e64108
[designspace] rename 'masters' to 'sources', like in original .designspace document
I don't see why our parser should call this element differently than its official name.
2017-02-27 16:21:35 +00:00
Cosimo Lupo
51f4302ec8
[designspace] if elements not defined, don't set key/value pair in returned dict
According to https://github.com/LettError/designSpaceDocument

> Not all values might be required by all applications.

So if any of 'elements', 'sources' or 'instances' is missing, the dictionary
returned by designspace.load will not contain those keys.
2017-02-27 16:17:13 +00:00
Behdad Esfahbod
b9ff863b2c Move Snippets/interpolatable.py to fontTools.varLib.interpolatable 2017-02-26 10:43:11 -08:00
Cosimo Lupo
ae58d3872c Merge pull request #864 from miguelsousa/pr857-followup
Followup to PR #857
2017-02-26 16:44:18 +00:00
Miguel Sousa
f061231049 [varLib] Make designspace.load() return a dictionary instead of a tuple 2017-02-26 07:49:44 -08:00
Miguel Sousa
43efa63732 [varLib] Build axes according to ’axes’ element in designspace file 2017-02-25 20:53:48 -08:00
Miguel Sousa
0dd2227e49 [varLib] Make parsing of ‘axes’ element more robust 2017-02-25 20:45:47 -08:00
Behdad Esfahbod
76e73f0ee4 [varLib] Remove TODO item 2017-02-25 10:59:31 -08:00
ReadRoberts
69ae7f0da5 Python2 .5-> Python3/2.7: "axes.has_key(iden)" -> "iden in axes" 2017-02-24 08:58:39 -08:00
ReadRoberts
33177bf65b If the design space file uses an <axes> element, use this to define the axis map, and preserve the axis order. 2017-02-22 21:22:34 -08:00
Behdad Esfahbod
55a5ace5d8 [varLib] Update invocation command 2017-02-22 14:46:23 -06:00
Sascha Brawer
c436365cef [varLib] Add missing import
After this change, the command line mentioned in the comment at the
beginning of the file works again.
2017-02-22 20:18:05 +01:00
Behdad Esfahbod
d7e8af9510 [varLib] Fix regression where GPOS values were stored as 0
Another fallover from merging of VariationMerger and InstancerMerger.

New code is closer to the selfless merger we want to have.

Fixes https://github.com/fonttools/fonttools/issues/834
2017-02-09 19:35:24 -08:00
Behdad Esfahbod
d801056100 [varLib] Allow merging of class-based kerning when ClassDef1's are different
This should allow building varfonts for a whole class of font sources
that failed so far.
2017-02-08 14:29:02 -08:00
Behdad Esfahbod
9544a538ee [varLib] Minor rename in prep for ClassDef1 merging 2017-02-08 14:14:08 -08:00
Behdad Esfahbod
dc07fe4f8f [varLib] Allow merging of class-based kerning when ClassDef2's are different
With this, we can build varfont for NotoSansThai and a couple more.

This is the first use of fontTools.misc.classifyTools module.
2017-02-07 16:09:14 -08:00
Behdad Esfahbod
ef0eb9dc8f [varLib] Move code around 2017-02-05 18:52:27 -08:00
Behdad Esfahbod
b5c34ceb15 [varLib] Fix building variation of PairPosFormat2
I broke this with a738464f775c190bf70e26d0a32ff2344ec43201
Ouch!
2017-02-05 18:48:15 -08:00
Cosimo Lupo
3717dc6549
[varLib.merger] set initializer for reduce() to handle empty sequences; import reduce from functools for py3
When reduce() receives an empty sequence, it raises TypeError, unless it is given a third 'initializer' argument

ValueFormat values should default to 0, so we shall use that as initializer.

Also, the reduce() built-in is no longer available on Python 3.
It's still accessible for both py2 and py3 from functools.

Fixes https://github.com/googlei18n/fontmake/issues/241
2017-01-30 16:51:41 +00:00
Behdad Esfahbod
a738464f77 [varLib] Let VariationMerger use AligningMerger for PairPos
VariationMerger now has all the intelligence of AligningMerge.
Should be good for a while...
2017-01-25 23:34:28 -08:00
Behdad Esfahbod
dd6fb82d66 [varLib] Move common code into a parent merger 2017-01-25 20:43:00 -08:00
Behdad Esfahbod
fece08bc32 [varLib] Enable subclassing of mergers
Theoretically diamond shapes and mixins should work as well.
2017-01-25 20:39:21 -08:00
Behdad Esfahbod
a34a7c906e [varLib] Towards making subclassed mergers working 2017-01-25 20:30:44 -08:00
Behdad Esfahbod
5e1be9e5e7 [varLib] Move code around 2017-01-25 20:11:35 -08:00
Behdad Esfahbod
2532fac11f [varLib] Improve assert fail breadcrumbs 2017-01-25 19:00:08 -08:00
Behdad Esfahbod
1631c5c941 [varLib.interpolate_layout] Implement flattening of multiple PairPosFormat1 subtables
Also fixes issues with merging of PairPos.

Trying on Noto Sans Thai still fails, now because of issues in class differences in
PairPosFormat2. :(  Investigating.

This is part of fixing https://github.com/fonttools/fonttools/issues/719
though, the changes are currently in interpolate_layout, and need to be ported /
merged with varLib.__init__ variation-font-builder.
2017-01-18 18:42:45 -08:00
Behdad Esfahbod
d38ecf02ec [varLib] Minor 2017-01-18 18:42:45 -08:00
Cosimo Lupo
78ad48eaf3
Move all *_test.py modules and test data to external Tests/ folder 2017-01-16 09:14:12 +00:00
Cosimo Lupo
49bcbb916b
consistently do sys.exit(unittest.main()) in all test modules
So that when run as scrips they report test failures with exit code

Follow up on b7bb391033ef3255c90134da3d7aef50d2d5326d
2017-01-11 13:05:35 +00:00
Cosimo Lupo
2e2125f173
[minor] remove redundant sys import 2017-01-11 12:24:04 +00:00
Cosimo Lupo
b7bb391033
don't use sys.exit(...) inside main(), but only under if __name__ == "__main__"
The convention is that sys.exit(...) is called only if a module is run as a script,
and that main() entry points use return statements to report exit codes: 0 (or None)
for successful execution, or any non-zero integer for errors.

E.g. see the console scripts generated when installing with pip.
2017-01-11 12:10:58 +00:00
Cosimo Lupo
ae05b2a583
[logging] for runnable modules, spell out module name instead of using __name__
If a module is run as script, as in `python module.py` or when using
`runpy.run_module()`, then __name__ == "__main__".

So when we instantiate modules' loggers with `logging.getLogger(__name__)`,
those loggers' name may become "__main__" when run as scripts, and hence
fall outside of the "fontTools" logging namespace.

fontTools.configureLogger() by default only configures the "fontTools"
library loggers, anything outside of it (e.g. logger called "__main__")
is not attached a handler.

So here I name loggers explicitly instead of relying on __name__, but
only for modules which can be run as "__main__".

Fixes #801
2017-01-11 11:58:17 +00:00
Cosimo Lupo
7ec4fd0605
[varLib] replace print() with logging
Fixes #795
2017-01-09 10:37:47 +00:00
Cosimo Lupo
4af078a629
[varLib] re-enable building HVAR for TTFs; remove --build-HVAR option
The option was meant to be temporary, and is no longer needed since
https://github.com/fonttools/fonttools/issues/705 is now fixed.
2017-01-09 10:34:34 +00:00
Sascha Brawer
1d28abdb65 [gvar] Rename GlyphVariation to TupleVariation
In the OpenType 1.8 specification, this is called TupleVariation
so let's be consistent with the spec. (The initial implementation
in fonttools pre-dates OpenType 1.8).
2017-01-04 12:41:55 +01:00
Behdad Esfahbod
cada4607fb [varLib] Use "VF" (for variable-font" instead of "GX" in output name 2016-12-08 20:48:08 -08:00
justvanrossum
289fd62d8f added assert, as suggested by @behdad in #749 2016-12-02 14:24:46 +01:00
justvanrossum
e5d2d49900 two more doctests 2016-11-29 14:42:20 +01:00
justvanrossum
8fa2ee1d95 Do the capping before calculating the normalized value to avoid ZeroDivisionError when default == lower or default == upper. Added doctests to verify. Fixes #749 2016-11-29 14:38:46 +01:00
Behdad Esfahbod
7915a45ddf [varLib] Handle fonts without GPOS
Fixes https://github.com/fonttools/fonttools/issues/699
2016-11-08 15:44:39 -08:00
Rob McKaughan
1bebcec00d Do not emit null axes in fvar (default==min==max) 2016-11-04 14:53:43 -07:00
Cosimo Lupo
df967e70fc
varLib: rename --buildHVAR option to --build-HVAR; add 'build_HVAR=False' kwarg to 'build' function
better not having to pass an argparse.Namespace object to varLib.build
2016-11-03 10:59:00 +00:00