75 Commits

Author SHA1 Message Date
Jany Belluz
1cb5ef57dd [designspaceLib] Allow non-zero Upright values in STAT entries 2022-10-19 10:44:36 +01:00
Jany Belluz
3577728a43 [designspaceLib] Fix check for Upright STAT entry 2022-10-19 09:58:15 +01:00
Jany Belluz
12d13f0b26 [designspaceLib] Fix recursion error with linkedUserValue in both directions 2022-10-18 17:32:14 +01:00
Harry Dalton
2da2653837 Allow "minimum"/"maximum" keys to be missing, as well as None
Some areas of the library check for both representations, and so doing
this here too means we are less likely to break existing code.

Despite this, flexibility introduces ambiguity, and so if typing gives
us confidence that such an input is unlikely, we could re-review this;
conditions with missing keys are not safe to use across the entire code-
base.
2022-09-01 17:21:04 +01:00
Harry Dalton
fef9e9a071 Fix handling of unbounded conditions
For unbounded conditions, the previous code expects "minimum" or
"maximum" to be entirely absent, whereas actually they will be
consistently present with one having a value of None.

This means that math.inf and -math.inf are never substituted in for the
absent bound, and a crash occurs when the None value propagates.

This commit corrects the behaviour by checking for a value of None,
instead of checking for the presence of the keys, bringing the
behaviour inline with the rest of the library.
2022-09-01 13:49:58 +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
Jany Belluz
f19aa60e65
Merge pull request #2634 from fonttools/ds-avoid-isinstance
[designspaceLib] Check for descriptor types with hasattr()
2022-06-09 17:50:47 +01:00
Jany Belluz
737abf5020
[designspaceLib] Add DiscreteAxisDescriptor default in docstring 2022-06-08 10:03:04 +01:00
Jany Belluz
86cdcbb9e5 [designspaceLib] Add new classes to __all__ 2022-06-06 09:19:17 +01:00
Jany Belluz
ec4bcf54c9 Check for descriptor types with hasattr() to allow custom classes that don't inherit the default descriptors 2022-06-01 12:00:52 +01:00
Nikolaus Waxweiler
fc174a9170 Undo warning 2022-05-04 14:54:07 +01:00
Nikolaus Waxweiler
26bf33bb60 Use assert instead of standalone error 2022-05-04 14:37:08 +01:00
Nikolaus Waxweiler
ada9828121 Add some proper exceptions 2022-04-29 16:56:50 +01:00
Nikolaus Waxweiler
d8bf4c3123 Fix typo to actually transfer font references 2022-04-26 10:15:37 +01:00
mike maxfield
47bbe6f7ca correct naming of dataclasses '__post_init__' method 2022-04-23 16:18:41 -06:00
Jany Belluz
35e560603e [designspaceLib] Add designspace 5 code 2022-04-14 15:03:58 +01:00
Simon Cozens
0f03e6529a
[docs] Fix sphinx warnings (#2453)
* Add default auto doc options

* Ensure all references are unique

* Use anonymous links to avoid duplicate references

* Remove default options, fix wrong module name

* Don’t index repeated class

* Remove repeated classes included through automodule

* Fix warnings

* We don’t use our own static directory

* Correctly format XML in docs

* Fix indentation

* Fix overline

* Bring TOC to top

* Fix definition list

* Offset definition lists and examples

* Fix erroneous markup

* Fix markup

* Already included in automodule

* Fix args markup

* Correct markup for example

* Don’t reindex repeated module

* Correct XML code block markup

* Fix markup errors, change example to doctest

* Correct list markup

* Make ttx docstring both valid RST and valid help output

* Various other boring markup fixes

* Fix example indenting

* Make docstring valid RST and valid help output

* Mock import for reportlab

* It’s ok if manual links don’t appear in toctrees

* Oops typo, I guess doctests are useful
2021-12-02 15:31:49 +00:00
Khaled Hosny
232b2ccbc4 Move the rest of py23 module to textTools
Change all imports to use textTools module, except the test_py23.py test
which is kept until we decide to remove the module (if ever).
2021-08-20 01:29:45 +02:00
Eigi
84d77e5c3a fix for issue #2299
translate leading backslashes of UNC path to forward slashes.
2021-05-09 18:59:34 +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
Cosimo Lupo
ca3306da57
designspaceLib: add add{Axis,Source,Instance,Rule}Descriptor methods
as suggested by Just here:
https://github.com/fonttools/fonttools/pull/1860#issuecomment-601762751
2020-03-20 16:04:24 +00:00
Cosimo Lupo
2d27490c7d
designspaceLib: allow to construct descriptors from keyword args
like data classes
2020-03-20 16:04:23 +00:00
Just van Rossum
b8fafdd259
[WIP] [designspaceLib] designspace docs edits (#1750)
Various changes in the designspaceLib readme.rst
- added docs for DesignSpaceDocument object, methods and attributes
- removed comments on validation, localisation and generating UFO instances.
- added note that axis minimum, default and maximum are in userspace coordinates.
- added clarification to map input (userpace!) / output (designspace!) values.
- added note that sourceDescriptor location is in designspace coordinates.
- moved comment on rule subs to rule descriptor object.
- added proposed "processing" flag to rules element
- move note on sub element
- implementation differences
- varlib vs. mutatormath
- older versions
- rules and generating static ufo instances
- Updated the description of the `copyInfo` flag of the sourceDescriptor.
- Change the example import.
- Remove additional mention of copyInfo.
2019-11-07 19:30:51 +01:00
justvanrossum
f9b04572f6 fix error message, reformatted long line 2019-10-18 13:24:32 +02:00
justvanrossum
d42b7d74ca Implement <rules> attribute 'processing' according to spec update #1750, as well as the related doc.rulesProcessingLast flag 2019-10-18 13:20:28 +02:00
Nikolaus Waxweiler
01328213c7 Remove __future__ imports 2019-08-09 12:20:13 +01:00
Nikolaus Waxweiler
0b9ad5ab80 Add a default InstanceDescriptor.font attribute 2019-08-02 13:40:15 +01:00
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