48 Commits

Author SHA1 Message Date
Cosimo Lupo
175399ecbc
designspaceLib: add examples to loadSourceFonts docstring 2019-05-10 18:43:42 +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
754c1c6a2f Minor: Remove redundant comment 2019-03-10 23:03:08 +00: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
a979af2019 designspaceLib: use axis maps with normalizeLocation
fixes https://github.com/fonttools/fonttools/issues/1226
2019-02-27 15:17:24 -08:00
Nikolaus Waxweiler
dd40dac5e0 Remove InstanceDescriptor.mutedGlyphNames
Closes https://github.com/fonttools/fonttools/issues/1417.
2019-01-19 14:13:32 +00:00
Cosimo Lupo
48e72dab9b
varLib: use addMultilingualName for localised instance style names
designspaceLib: ensure instance localised names are set as unicode strings
2019-01-13 15:04:55 +00:00
Cosimo Lupo
acbc65c1a9
varLib: use addMultilingualName method to support localized axes 'labelname'
now that addMultilingualName method also adds mac names by default, we can use it in
varLib instead of addName.
The language identifiers are expected to be minimized, i.e. not contain default script/region
subtags -- until we implement the minimizeSubtags algorithm from ICU/CLDR:
https://github.com/fonttools/fonttools/issues/930
2019-01-13 13:39:15 +00: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
e640806657
designspace: normalize platform path separator in getSourcePath 2019-01-02 16:11:32 +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
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
6a7493adbb
designspaceLib: port to using lxml via fontTools.misc.etree
indentation is now two spaces like lxml (unchangeable) default
https://github.com/fonttools/fonttools/pull/1335#issuecomment-431112494
2018-10-18 20:03:54 +01:00
Cosimo Lupo
76ba93e6db
designspaceLib: only raise when 'No axis defined' when self._strictAxisNames=True (default) 2018-09-11 18:12:25 +02:00
Cosimo Lupo
95f1909849
designspaceLib: add map_forward/backward methods to AxisDescriptor class 2018-09-11 18:10:51 +02:00
Cosimo Lupo
d8d8ed4016
designspaceLib: add asdict() method to descriptor objects
useful when pretty-printting in the logger
2018-09-11 18:09:22 +02:00
Cosimo Lupo
6cfa1a0bea
designspaceLib: add fromfile, fromstring and tostring methods 2018-09-11 15:12:43 +02:00
Cosimo Lupo
bf87025826
designspaceLib: fix formatting of DesigSpaceError exception
https://travis-ci.org/googlei18n/fontmake/jobs/390821469#L498
2018-06-11 16:35:02 +01:00
Cosimo Lupo
565e835c92
designspaceLib: cleanup formatting, remove unused vars, etc. 2018-06-07 12:44:49 +01:00
Cosimo Lupo
d7714ead35
designspaceLib: use LogMixin; fix undefined name
'ruleObject' name in _readConditionElements was undefined
2018-06-07 11:43:14 +01: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
554aa362bd WIP Change warnings.warn to logger.info and logger.warning.
findDefault only looks for the sourceDescriptor on the default of all axes. Returns None otherwise.
Remove _axesAsDict - not needed.
Shortened logger name to "DesignSpaceLog"
2018-05-30 22:21:05 +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
a24b00ba14 WIP Comments. 2018-05-27 12:36:57 +02:00
Erik van Blokland
6c649aa023 Remove checkAxes() 2018-05-27 12:19:16 +02:00
Erik van Blokland
1f7f4e42ab WIP reformat some of the docstrings. 2018-05-25 15:22:00 +02:00
Erik van Blokland
b774d8c3e8 WIP remove fontTools.varLib import. 2018-05-25 11:46:44 +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
46bfc1c907 WIP Rename self.axes and self.rules attributes of the reader and writer to self._axes and self._rules
Comment out self._locationFromElement - not sure why it exists, let's see if someone complains.
Only raise missing axes error if we read a location *and* we have no axes. This allows a designspace file with a lib but without sources.
Only do findDefault() if we have sources.
2018-05-24 22:47:31 +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
3b6708940f WIP remove guessAxes 2018-05-23 16:15:14 +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
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
Cosimo Lupo
8ca22ab002
designspaceLib: remove deprecated Element.getchildren 2018-02-26 12:09:45 +00:00
Cosimo Lupo
696edb6b6d
designspaceLib: try use cElementTree on py27 2018-02-26 12:09:05 +00:00
Jany Belluz
03f8ec3b87 [designspaceLib] Add tests for the new parameters 2018-02-14 15:24:32 +00:00
Jany Belluz
483e1489b4 [designspaceLib] Add documentation for new attributes 2018-02-14 12:46:51 +00:00
Jany Belluz
4c91f51aed [designspaceLib] Add properties to designspace documents 2018-02-14 12:46:26 +00:00
Erik van Blokland
e754f810b3 test commit to see if I can access this. 2018-02-09 16:38:19 +01:00
Jany Belluz
1f1dca9b6d Fix a flaky designspace test 2018-01-23 17:04:45 +00:00
Jany Belluz
bd0eca56d8 Remove fontClass, defcon, getFonts() 2017-11-30 12:21:09 +00:00
Jany Belluz
4f90d6e6df Fix the tests on posix systems 2017-11-30 12:08:48 +00:00
Jany Belluz
ac329fbd69 Move the tests to pytest 2017-11-29 17:08:23 +00:00
Jany Belluz
638fa46eea Move designSpaceDocument files in the correct folder 2017-11-28 10:18:28 +00:00