[varLib] Round outline deltas using banker's round as well
See https://github.com/fonttools/fonttools/pull/2214#issuecomment-790742479
This commit is contained in:
parent
07a7dd3eb5
commit
d56b844142
@ -71,7 +71,7 @@ class Vector(tuple):
|
|||||||
def __neg__(self):
|
def __neg__(self):
|
||||||
return self._unaryOp(operator.neg)
|
return self._unaryOp(operator.neg)
|
||||||
|
|
||||||
def __round__(self):
|
def __round__(self, *, round=round):
|
||||||
return self._unaryOp(round)
|
return self._unaryOp(round)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
@ -34,6 +34,7 @@ from fontTools.varLib.mvar import MVAR_ENTRIES
|
|||||||
from fontTools.varLib.iup import iup_delta_optimize
|
from fontTools.varLib.iup import iup_delta_optimize
|
||||||
from fontTools.varLib.featureVars import addFeatureVariations
|
from fontTools.varLib.featureVars import addFeatureVariations
|
||||||
from fontTools.designspaceLib import DesignSpaceDocument
|
from fontTools.designspaceLib import DesignSpaceDocument
|
||||||
|
from functools import partial
|
||||||
from collections import OrderedDict, namedtuple
|
from collections import OrderedDict, namedtuple
|
||||||
import os.path
|
import os.path
|
||||||
import logging
|
import logging
|
||||||
@ -253,7 +254,7 @@ def _add_gvar(font, masterModel, master_ttfs, tolerance=0.5, optimize=True):
|
|||||||
|
|
||||||
# Update gvar
|
# Update gvar
|
||||||
gvar.variations[glyph] = []
|
gvar.variations[glyph] = []
|
||||||
deltas = model.getDeltas(allCoords, round=round) # builtin round calls into GlyphCoordinates.__round__()
|
deltas = model.getDeltas(allCoords, round=partial(GlyphCoordinates.__round__, round=round))
|
||||||
supports = model.supports
|
supports = model.supports
|
||||||
assert len(deltas) == len(supports)
|
assert len(deltas) == len(supports)
|
||||||
|
|
||||||
@ -363,7 +364,7 @@ def _merge_TTHinting(font, masterModel, master_ttfs):
|
|||||||
return
|
return
|
||||||
|
|
||||||
variations = []
|
variations = []
|
||||||
deltas, supports = masterModel.getDeltasAndSupports(all_cvs, round=round) # builtin round calls into Vector.__round__
|
deltas, supports = masterModel.getDeltasAndSupports(all_cvs, round=round) # builtin round calls into Vector.__round__, which uses builtin round as we like
|
||||||
for i,(delta,support) in enumerate(zip(deltas[1:], supports[1:])):
|
for i,(delta,support) in enumerate(zip(deltas[1:], supports[1:])):
|
||||||
if all(v == 0 for v in delta):
|
if all(v == 0 for v in delta):
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user