[varLib] include default maps for all avar axes, even without <map> elements

This is a follow-up to Jens' comment:

19c4b377b8 (commitcomment-23458151)

Now, if there's any axis that has 'interesting' segment maps (and thus
an avar table is added), we also ensure that for the rest of the axes
that aren't modified (either because no <map> elements are defined or
because an identity mapping is defined in the designspace), we always
have a non-empty segment maps array containing the three default maps:
{-1.0: -1.0, 0.0: 0.0, 1.0: 1.0}.

This is to work around CoreText and DirectWrite rendering issue with
empty avar segment maps arrays.
This commit is contained in:
Cosimo Lupo 2017-08-16 16:30:11 +01:00
parent 77876e8df4
commit 04eacf13cd

View File

@ -109,7 +109,14 @@ def _add_avar(font, axes):
interesting = False
for axis in axes.values():
curve = avar.segments[axis.tag] = {}
# Currently, some rasterizers require that the default value maps
# (-1 to -1, 0 to 0, and 1 to 1) be present for all the segment
# maps, even when the default normalization mapping for the axis
# was not modified.
# https://github.com/googlei18n/fontmake/issues/295
# https://github.com/fonttools/fonttools/issues/1011
# TODO(anthrotype) revert this (and 19c4b37) when issue is fixed
curve = avar.segments[axis.tag] = {-1.0: -1.0, 0.0: 0.0, 1.0: 1.0}
if not axis.map:
continue
@ -135,16 +142,6 @@ def _add_avar(font, axes):
keys = [models.normalizeValue(v, keys_triple) for v in keys]
vals = [models.normalizeValue(v, vals_triple) for v in vals]
# Work around rendering issue with CoreText when avar table
# contains segment maps with zero axis value maps.
# Currently, CoreText requires that the three default value maps
# (-1 to -1, 0 to 0, and 1 to 1) be present for all the segment
# maps, even when the default normalization mapping for the axis
# was not modified.
# https://github.com/googlei18n/fontmake/issues/295
# TODO(anthrotype) revert this change once CoreText is modified
curve.update({-1.0: -1.0, 0.0: 0.0, 1.0: 1.0})
if all(k == v for k, v in zip(keys, vals)):
continue
interesting = True