From b20c583e2d72a676178229d0849315ada0dabacc Mon Sep 17 00:00:00 2001 From: schriftgestalt Date: Wed, 24 Oct 2018 21:42:28 +0200 Subject: [PATCH 1/2] support Variable length indexPaths --- Lib/glyphsLib/classes.py | 9 +++++---- Lib/glyphsLib/types.py | 9 +++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) mode change 100644 => 100755 Lib/glyphsLib/types.py diff --git a/Lib/glyphsLib/classes.py b/Lib/glyphsLib/classes.py index 4e1daf280..85a30980a 100755 --- a/Lib/glyphsLib/classes.py +++ b/Lib/glyphsLib/classes.py @@ -27,6 +27,7 @@ ValueType, Transform, Point, + IndexPath, Rect, parse_datetime, parse_color, @@ -244,7 +245,7 @@ def parse_hint_target(line=None): if line is None: return None if line[0] == "{": - return Point(line) + return IndexPath(line) else: return line @@ -2145,9 +2146,9 @@ class GSHint(GSBase): _classesForName = { "horizontal": bool, "options": int, # bitfield - "origin": Point, # Index path to node - "other1": Point, # Index path to node for third node - "other2": Point, # Index path to node for fourth node + "origin": IndexPath, # Index path to node + "other1": IndexPath, # Index path to node for third node + "other2": IndexPath, # Index path to node for fourth node "place": Point, # (position, width) "scale": Point, # for corners "stem": int, # index of stem diff --git a/Lib/glyphsLib/types.py b/Lib/glyphsLib/types.py old mode 100644 new mode 100755 index 4f391301e..199991167 --- a/Lib/glyphsLib/types.py +++ b/Lib/glyphsLib/types.py @@ -156,6 +156,15 @@ def y(self, value): if self.rect: self.rect.value[1] = value +class IndexPath(Vector(4)): + def __repr__(self): + return "".format(", ".join([str(i) for i in self.value])) + + def fromString(self, line): + src = line[1:-1] + elements = src.split(", ") + self.dimension = len(elements) + return [int(i) for i in elements] class Size(Point): def __repr__(self): From bec9466836f303a5c019c1f43094a8d81a262a32 Mon Sep 17 00:00:00 2001 From: schriftgestalt Date: Wed, 24 Oct 2018 23:55:38 +0200 Subject: [PATCH 2/2] add/remove some whitespace --- Lib/glyphsLib/types.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/glyphsLib/types.py b/Lib/glyphsLib/types.py index 199991167..e2e78f00a 100755 --- a/Lib/glyphsLib/types.py +++ b/Lib/glyphsLib/types.py @@ -156,16 +156,18 @@ def y(self, value): if self.rect: self.rect.value[1] = value + class IndexPath(Vector(4)): def __repr__(self): return "".format(", ".join([str(i) for i in self.value])) - + def fromString(self, line): src = line[1:-1] elements = src.split(", ") self.dimension = len(elements) return [int(i) for i in elements] + class Size(Point): def __repr__(self): return "".format(self.value[0], self.value[1])