From 60f072414478dba95c743e8f6bbdb5792088c71b Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 19 Jul 2021 17:52:00 +0100 Subject: [PATCH] remove wrapping around from Angle converter, let the struct.error propagate --- Lib/fontTools/ttLib/tables/otConverters.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Lib/fontTools/ttLib/tables/otConverters.py b/Lib/fontTools/ttLib/tables/otConverters.py index c306fdf2e..1976acaa7 100644 --- a/Lib/fontTools/ttLib/tables/otConverters.py +++ b/Lib/fontTools/ttLib/tables/otConverters.py @@ -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):