43 Commits

Author SHA1 Message Date
Harry Dalton
bbb26c2cea Confirm split functions can handle unbounded conditions with absent keys
As we make an effort to support conditions with "minimum" or "maximum"
absent, as well as with "minimum" or "maximum" None, this commit
confirms that the split functions can handle these to some degree also.
2022-09-01 17:34:51 +01:00
Harry Dalton
d1ec8e6979 Test that DS5 splitting code handles unbounded conditions gracefully
Conditions with unbounded values have a "minimum" or "maximum" value of
None.

These tests check that:
a) The public-facing split functions can receive None values without
     crashing; and
b) That their internal helper functions correctly translate the None
     values to math.inf and -math.inf to express them.

These tests are expected to fail, indicating where a fix is required.
2022-09-01 13:41:44 +01:00
Jany Belluz
b5f9499d2d [designspaceLib] Don't make up bad PS names when no STAT data
See GitHub issue: https://github.com/googlefonts/ufo2ft/issues/630
2022-07-07 11:56:51 +01:00
Nikolaus Waxweiler
9f984d93f7 Fix up tests 2022-04-29 18:13:03 +01:00
Nikolaus Waxweiler
177e0a71b8 Clean up one of the DSv5 documents somewhat 2022-04-29 16:57:06 +01:00
Cosimo Lupo
619e55d72a Add test for designspaceLib.types.Range dataclass
test for https://github.com/fonttools/fonttools/pull/2597
2022-04-26 10:50:36 +01:00
Nikolaus Waxweiler
d8bf4c3123 Fix typo to actually transfer font references 2022-04-26 10:15:37 +01:00
Jany Belluz
a7974986c3 [designspaceLib] Add designspace 5 tests 2022-04-14 15:04:38 +01:00
Cosimo Lupo
64299aa4b1 drop Python 3.6, require >= 3.7
3.10 is out next week, while 3.6 reaches end of life by the end of this year.
It's time to require 3.7 or greater, so we can finally use built-in dataclasses and more.

Fixes https://github.com/fonttools/fonttools/issues/2350
2021-09-27 13:21:08 +02: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
Nikolaus Waxweiler
b07940421d Fix test_addRuleDescriptor
Use API correctly.
2020-05-13 15:45:27 +01:00
Cosimo Lupo
3997c15179
designspace_test: add tests for add*Descriptor methods 2020-03-20 16:07:30 +00:00
justvanrossum
f4925fff44 perform some testing with <rules processing=...> and doc.rulesProcessingLast 2019-10-18 13:33:29 +02:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Cosimo Lupo
44f74dc8bb
designspaceLib: add loadSourceFonts method with custom opener
Allows to load the SourceDescriptor.font attribute from its path, using a custom callable (e.g. defcon.Font or ttLib.TTFont, etc.).
2019-05-10 16:32:11 +01:00
Cosimo Lupo
b327287f97
designspaceLib: remove defaultLoc attribute, use up-to-date default location in findDefault
Fixes #1554
2019-04-08 16:59:01 +01:00
Nikolaus Waxweiler
5f7afa23b2 newDefaultLocation: Return location in design space 2019-03-10 22:20:00 +00:00
Nikolaus Waxweiler
c4899330c5 designspaceLib, findDefault: consider axis mapping 2019-03-10 22:12:06 +00:00
Cosimo Lupo
0475246eef designspaceLib_test: fix test_normalization4 expected results 2019-02-27 15:17:24 -08:00
Cosimo Lupo
448b946636
varLib/designspaceLib: require font-less source to have a path; remove getSourcePath
simpler is better. Also, refactored updatePaths and added more tests to it.
2019-01-03 14:21:09 +00:00
Cosimo Lupo
b3e8f76b64
designspace_test: compare normalized paths
https://github.com/fonttools/fonttools/issues/1259#issuecomment-450910787
2019-01-02 16:33:03 +00:00
Cosimo Lupo
a0e4c04c1e
designspace_test: use tmpdir fixture and platform-independent path separator 2019-01-02 15:34:40 +00:00
Cosimo Lupo
3558d4e537
Merge remote-tracking branch 'origin/master' into varlib-build-accept-ds-object 2019-01-02 14:12:56 +00:00
Cosimo Lupo
88eacd3804
designspace_test: test getSourcePath method prefers 'path' attribute when present 2019-01-02 14:10:22 +00:00
Cosimo Lupo
1470ef7258
designspaceLib: add getSourcePath method
and remove BaseDocReader.getSourcePaths as it was broken anyway (it was assuming 'sources'
attribute of DesignSpaceDocument object was a dict, whereas it is now a list of
SourceDescriptor objects
2019-01-02 14:06:55 +00:00
Just van Rossum
327b05d8c0
[designspaceLib] [t1Lib] [misc.macRes] fix some cases where pathlib.Path objects were not accepted (#1421)
* fix two cases where pathlib.Path objects were not accepted

* make macRes reader accept os.PathLike objects

* use __fspath__ explicitly to support os.PathLike paths

* use __fspath__ explicitly to support os.PathLike paths

* convert tmpdir to str

* only test pathlib.Path on Python 3.6 and up
2018-12-30 12:07:05 +01:00
Cosimo Lupo
f99afc70d3
Merge pull request #1326 from BoboTiG/fix-resource-leak
Fix several ResourceWarning: unclosed file and some related improvement
2018-11-16 23:00:24 +00:00
Cosimo Lupo
931f8024eb
designspace_test: must use plistlib.Data for py2 compatibility
grr...
2018-10-18 20:10:59 +01:00
Cosimo Lupo
97d5044109
designspaceLib_test: fixup expected test results 2018-10-18 20:04:27 +01:00
Mickaël Schoentgen
52e855e4a4 Use the 'with' context manager when dealing with files 2018-10-01 08:42:45 +02:00
Erik van Blokland
e4c90b9afe WIP uncomment test for conditions without min or max.
Add _axesAsDict to the test because there it is needed.
2018-05-30 22:26:59 +02:00
Erik van Blokland
855a475ad2 WIP removed test for incomplete rules. Added test for stray conditions. Removed high unicode character from lib test. Read stray unwrapped conditions, put them in a conditionset. 2018-05-27 19:18:13 +02:00
Erik van Blokland
8582dbdd2a WIP. Some comments. 2018-05-27 09:50:00 +02:00
Erik van Blokland
16cba5ad81 WIP Remove _locationFromElement. Single method for newDefaultLocation. Split some of the tests into smaller things. Add some thoughts to normaliseLocation and why this needs a separate method from the one in varLib. 2018-05-25 11:43:58 +02:00
Erik van Blokland
9d91c82bbe WIP test documentLib. Add a warning if a findDefault can't find a suitable location. 2018-05-24 21:49:33 +02:00
Erik van Blokland
086de222fa WIP axes are compulsory, so don't accomodate missing axes. Raise error if document is missing axes.
We know what the default location is before we start reading the masters and there is no guessing.
findDefault() method: default master is at all default values of all axes, or if that fails, the master with the copyInfo flag.
Warn if a location contains an axis that is not defined in the axes element. Otherwise ignore this value, no guessing.
Remove rulesToFeature() function.
2018-05-23 13:19:23 +02:00
Cosimo Lupo
ceb41ec484 WIP: implement conditionSets in designspaceLib.RuleDescriptor (#1255)
* [designspaceLib] WIP: add conditionSets to RuleDescriptor...

the BaseDocReader still needs to be updated to be able to read both
legacy condition-without-conditionset and new-style conditionset
elements.

* test_rules: replace rule.conditions with conditionSets

* Tests: update test.designspace to use conditionset; replace 'with' with 'byname' in sub element

I don't like too much that now 'byname' precedes alphabetically 'name'.
We need to see if ElementTree allows to sort attribute arbitrarily

* Change versionnumber to 4.0 - would that be enough, or should there be seperate major / minor fields?
If we bump the version up to numeral 4, I'd like the check for the with / byname attributes. We can read the old `byname` and only write the new `with`.
Remove support for `initial` in axis attributes.

* WIP - formatversion, with attribute,

* WIP
anything that is not version 4.0 is version 3.0
added some local paths to the test so I can see what it's generating. I can take this out later.

* WIP
read the conditionsets properly. This makes the tests fail no longer.

* WIP
disambiguate axis tags from axis names. Test axes are now called "axisName_x", tags are called "TAGX"

* WIP forgot to push

* WIP
Raise `DesignSpaceDocumentError` when no maximum or minimum are given in a condition.
Add test for such an incomplete rule.
Remove path cruft.

* WIP improved test of raised error.

* WIP because no bot.

* WIP more spaces around percents.

* WIP - don't skip empty subs, just load whatever is there.

* WIP do not permit empty axes in a location when evaluating a rule. Fix some tests.

* WIP missed a str(tempdir), some rule tests.

* WIP proposal for changes to the designspace spec to the `rule` and `sub` elements.

* WIP edits.

* WIP. Typo.
2018-05-14 11:29:48 +02:00
Erik van Blokland
c79a4326ac Remove old test. 2018-05-03 10:04:07 +02:00
Erik van Blokland
1fededb376 Changed sourceDescriptor object attribute to layerName.
Changed non-standard axis name to all caps.
2018-04-28 13:01:25 +02:00
Erik van Blokland
1c6c35dc38 Change to designspace documentation: add layer attribute to the source element.
Add `layerName` attribute to the sourcedescriptor object
Read and write layerName.
Add a source layer test.
XXX this also disables the test_check() test for the moment because it generates odd results.
2018-04-27 13:24:11 +02:00
Jany Belluz
03f8ec3b87 [designspaceLib] Add tests for the new parameters 2018-02-14 15:24:32 +00:00
Jany Belluz
84f61d6fc4 Fix some test comments 2017-11-30 12:21:29 +00:00
Jany Belluz
ac329fbd69 Move the tests to pytest 2017-11-29 17:08:23 +00:00