3542 Commits

Author SHA1 Message Date
Cosimo Lupo
79449bc2d4
ttGlyphPen: always skip non-existing components
It doesn't make sense to add components that reference non-existing base glyphs
(ie. glyphs not in the input glyphSet, hence missing from the generated glyf table).
Even if we let them in here, it will fail immediately as soon as we attempt to
compile this glyf table containing 'dangling' component references.
Better to warn and skip.
2018-06-11 19:25:15 +01:00
Cosimo Lupo
ae69133924
ttGlyphPen: gracefully handle missing components while decomposing 2018-06-11 18:40:11 +01: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
bf5c3a42c6
Bump version: 3.27.0 → 3.27.1.dev0 2018-06-11 14:05:04 +01:00
Cosimo Lupo
4cfb4f8389
Release 3.27.0 2018-06-11 14:05:03 +01:00
Cosimo Lupo
e35151a051
Merge remote-tracking branch 'origin/master' into add-feature-variations 2018-06-11 12:49:31 +01:00
ReadRoberts
c239d1a03d
[cffLib] Fix bug in cffLib.py.CFFFontSet.convertCFFToCFF2() that broke converting name-keyed fonts.
Also clean up setting FontDict to support CFF2.
2018-06-11 12:09:00 +01:00
ReadRoberts
528bc8ff17
[cffLib] Use std operator delattr() instead of exec ("del ...") 2018-06-11 12:09:00 +01:00
ReadRoberts
942a7610fd
[cffLib] Fix bugs in converting CFF to CFF2 when the font has an FDArray.
The FontDict as well as the PrivateDict needs to have fields removed when these are deprecated in CFF2.
2018-06-11 12:09:00 +01:00
ReadRoberts
21bbb15cd0
[cffLib] Fix bugs in compiling a CFF2 font with an FDArray.
A FontDict in CFF2 is permitted only a subset of the fields supported by CFF 1.0.
2018-06-11 12:09:00 +01:00
Cosimo Lupo
846941c8ef
[glyf] ensure GlyphCoordinates never overflow
in _checkFloat (used whenever we're about to update the inner array) we check whether the value exceeds a short integer, and if so we convert the array to floats.
Also, we make sure we call __setitem__ (which in turn calls _checkFloat) instead of updating the inner array directly in the rest of the math methods.
2018-06-07 12:53:42 +01:00
Cosimo Lupo
e48e8ea7c9
Revert "models: convert delta array to float if overflows signed short integers"
This reverts commit 0055f9414ca5094b0c9beb0176ac4998cdbbba70.
2018-06-07 12:53:42 +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
Cosimo Lupo
fbab1227ce
loggingTools: memoize 'log' property of LogMixin
the logger name is constant (based on the user class's name and module)
so we can cache it.

(this means the LogMixin will only work on regular dict-based classes,
not on 'slotted' classes. But that's ok
2018-06-07 11:40:33 +01:00
Cosimo Lupo
65eac8ef92
Merge pull request #1267 from fonttools/designspaceLib-checkDefault
designspaceLib remove checkDefault, checkAxes
2018-06-07 11:14:43 +01:00
Cosimo Lupo
a84c097c10
py23: alias itertools.izip as 'zip'
so we consistently use python3 zip iterator on both py2 and py3
2018-06-06 18:21:15 +01:00
Cosimo Lupo
b38e2bd8ac
varLib.plot: use plot, not plot_wireframe, as we are using 1D lists
plot_wireframe requires 2D arrays.

In recent versions of matplotlib passing a 1D array fails with an error:

https://stackoverflow.com/questions/47225830/axes3d-plot-wireframex-y-z-error

https://github.com/matplotlib/matplotlib/pull/5166
https://github.com/matplotlib/matplotlib/issues/3116
2018-06-06 12:43:05 +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
Cosimo Lupo
01173c4599
Merge pull request #1261 from chrissimpkins/ttx-tests
Add ttx tests
2018-05-23 20:13:22 +01: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
Chris Simpkins
267d314233 [ttx] remove unreachable code 2018-05-21 23:50:26 -04:00
Cosimo Lupo
fc6f758d20
feaLib: add __all__ to ast module
for * imports
2018-05-21 12:40:14 +01: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
ReadRoberts
4da8f43eeb
[varLib] Fix bug in varLib.build() for CFF2.
The logic should attempt to build a cvar table only if there is a glyf table. This stack dumps when the font is a CFF2 font.
2018-05-10 10:12:28 +01:00
Behdad Esfahbod
f3c06fba3f Revert "[subset] Set to None empty Coverage tables in MarkGlyphSets"
This reverts commit 02616ab9b39d2e9618baebc4e051ae0a85200751.

Make OTS happy. Phew.
https://github.com/khaledhosny/ots/issues/172
2018-05-08 16:28:17 -07:00
Behdad Esfahbod
2ab38f9ba4 [subset] Handle None coverages in MarkGlyphSets 2018-05-08 15:24:36 -07:00
Cosimo Lupo
ca92b172f5
ttFont: allow to build glyph order without post nor cmap, just maxp.numGlyphs
could be useful to read in incomplete sfnt fonts e.g. containing only GPOS or GSUB tables
and a bare maxp table with the numGlyphs
2018-05-06 15:33:18 +01:00
Jens Kutilek
ae4472860f No need to use .keys() 2018-05-04 13:37:59 +02:00
Jens Kutilek
4a16d1839d Add __len__ method to TTFont._TTGlyphSet 2018-05-04 13:12:18 +02:00
Cosimo Lupo
a2f21a2155
Bump version: 3.26.0 → 3.26.1.dev0 2018-05-03 16:10:00 +01:00
Cosimo Lupo
e7e2bb9312
Release 3.26.0 2018-05-03 16:09:59 +01:00
Erik van Blokland
6958481eb0
Merge pull request #1253 from fonttools/designspacelib-layer-spec
Designspacelib layer spec
2018-05-03 10:32:57 +02:00
Behdad Esfahbod
0ecf5c5c94 [varLib.models] Refine modeling one last time
In a523a697164a4 I changed the model such that when computing master
supports and we hit another master, cut the box in one dimension only,
to avoid interferring with other master.  The axis to cut against was
chosen as axis that minimizes volume loss.  That was fine in a sense,
but missed a great amount of information resulting from relative
positioning of the two masters.  As such, it could not distinguish
between the following two situations:

behdad:fonttools 0 (master*)$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .5,.5 .55,.75
Sorted locations:
[{},
 {'A': 1.0},
 {'B': 1.0},
 {'A': 1.0, 'B': 1.0},
 {'A': 0.5, 'B': 0.5},
 {'A': 0.55, 'B': 0.75}]
Supports:
[{},
 {'A': (0, 1.0, 1.0)},
 {'B': (0, 1.0, 1.0)},
 {'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
 {'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
 {'A': (0, 0.55, 1.0), 'B': (0.5, 0.75, 1.0)}]
behdad:fonttools 0 (02616ab...)$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .5,.5 .75,.55
Sorted locations:
[{},
 {'A': 1.0},
 {'B': 1.0},
 {'A': 1.0, 'B': 1.0},
 {'A': 0.5, 'B': 0.5},
 {'A': 0.75, 'B': 0.55}]
Supports:
[{},
 {'A': (0, 1.0, 1.0)},
 {'B': (0, 1.0, 1.0)},
 {'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
 {'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
 {'A': (0, 0.75, 1.0), 'B': (0.5, 0.55, 1.0)}]

Check the last line. In both cases the box was cut against the second axis.
After this change, we get:

behdad:fonttools 0 (master)$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .5,.5 .55,.75
Sorted locations:
[{},
 {'A': 1.0},
 {'B': 1.0},
 {'A': 1.0, 'B': 1.0},
 {'A': 0.5, 'B': 0.5},
 {'A': 0.55, 'B': 0.75}]
Supports:
[{},
 {'A': (0, 1.0, 1.0)},
 {'B': (0, 1.0, 1.0)},
 {'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
 {'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
 {'A': (0, 0.55, 1.0), 'B': (0.5, 0.75, 1.0)}]
behdad:fonttools 0 (master)$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .5,.5 .75,.55
Sorted locations:
[{},
 {'A': 1.0},
 {'B': 1.0},
 {'A': 1.0, 'B': 1.0},
 {'A': 0.5, 'B': 0.5},
 {'A': 0.75, 'B': 0.55}]
Supports:
[{},
 {'A': (0, 1.0, 1.0)},
 {'B': (0, 1.0, 1.0)},
 {'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
 {'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
 {'A': (0.5, 0.75, 1.0), 'B': (0, 0.55, 1.0)}]

Just draw the boxes on a piece of napkin and convince yourself that this
is a good change.

If the ratios are equal, we cut against the first axis in the axisOrder:

behdad:fonttools 0 (master)$ ./fonttools varLib.models 0,0 0,1 1,0 1,1 .5,.5 .75,.75
Sorted locations:
[{},
 {'A': 1.0},
 {'B': 1.0},
 {'A': 1.0, 'B': 1.0},
 {'A': 0.5, 'B': 0.5},
 {'A': 0.75, 'B': 0.75}]
Supports:
[{},
 {'A': (0, 1.0, 1.0)},
 {'B': (0, 1.0, 1.0)},
 {'A': (0, 1.0, 1.0), 'B': (0, 1.0, 1.0)},
 {'A': (0, 0.5, 1.0), 'B': (0, 0.5, 1.0)},
 {'A': (0.5, 0.75, 1.0), 'B': (0, 0.75, 1.0)}]
2018-04-27 16:50:32 -07: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
Behdad Esfahbod
02616ab9b3 [subset] Set to None empty Coverage tables in MarkGlyphSets 2018-04-25 20:59:18 -07:00
Behdad Esfahbod
795f2f95fb [otBase] Fix sharing of tables referred to by different offset sizes
When an offset refers to a table, we keep the size of the offset to
the referred-to table. When sharing tables, we were ignoring this,
which could result in a long offset being written out as a short, or
vice versa.  Fix it by not sharing such tables. This is not optimal
but fixes the bug.

Bug has been there forever.
2018-04-25 20:57:19 -07:00
Behdad Esfahbod
fc819d6235 [subset] Don't drop a GDEF that only has VarStore 2018-04-25 16:10:57 -07:00
Behdad Esfahbod
1917d6913b [subset] Remove more nonsensical code
Remaining parts of 4e3192163470ca168ff753cb526480e59bc77e1a
2018-04-25 16:09:30 -07:00
Behdad Esfahbod
95838bd4df [otBase] If decoding tables fails, append breadcrumb to exception 2018-04-25 15:53:43 -07:00