Skip to content

Commit

Permalink
[varLib] include default maps for all avar axes, even without <map> e…
Browse files Browse the repository at this point in the history
…lements

This is a follow-up to Jens' comment:

19c4b37#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.
  • Loading branch information
anthrotype committed Aug 16, 2017
1 parent 77876e8 commit 04eacf1
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions Lib/fontTools/varLib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 04eacf1

Please sign in to comment.