remove wrapping around from Angle converter, let the struct.error propagate
This commit is contained in:
parent
7225ac22a6
commit
60f0724144
@ -17,7 +17,6 @@ from .otTables import (lookupTypes, AATStateTable, AATState, AATAction,
|
||||
InsertionMorphAction, MorxSubtable, VariableFloat,
|
||||
VariableInt, ExtendMode as _ExtendMode,
|
||||
CompositeMode as _CompositeMode)
|
||||
import math
|
||||
from itertools import zip_longest
|
||||
from functools import partial
|
||||
import struct
|
||||
@ -429,16 +428,12 @@ class F2Dot14(FloatValue):
|
||||
return fl2str(value, 14)
|
||||
|
||||
class Angle(F2Dot14):
|
||||
# angles are specified in degrees, and encoded as F2Dot14 fractions of half
|
||||
# circle: e.g. 1.0 => 180, -0.5 => -90, -2.0 => -360, etc.
|
||||
factor = 1.0/(1<<14) * 180 # 0.010986328125
|
||||
@staticmethod
|
||||
def wrapAround(angle):
|
||||
# Upon compile/dump, normalize angles that span beyond a full circle.
|
||||
# We want to keep the orientation after modulo: e.g. -415 => -55, not 305
|
||||
return angle % math.copysign(360, angle)
|
||||
def read(self, reader, font, tableDict):
|
||||
return super().read(reader, font, tableDict) * 180
|
||||
def write(self, writer, font, tableDict, value, repeatIndex=None):
|
||||
value = self.wrapAround(value)
|
||||
super().write(writer, font, tableDict, value / 180, repeatIndex=repeatIndex)
|
||||
@classmethod
|
||||
def fromString(cls, value):
|
||||
@ -446,7 +441,6 @@ class Angle(F2Dot14):
|
||||
return otRound(float(value) / cls.factor) * cls.factor
|
||||
@classmethod
|
||||
def toString(cls, value):
|
||||
value = cls.wrapAround(value)
|
||||
return nearestMultipleShortestRepr(value, cls.factor)
|
||||
|
||||
class Version(SimpleValue):
|
||||
|
Loading…
x
Reference in New Issue
Block a user