Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Variable length indexPaths #447

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Lib/glyphsLib/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
ValueType,
Transform,
Point,
IndexPath,
Rect,
parse_datetime,
parse_color,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions Lib/glyphsLib/types.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ def y(self, value):
self.rect.value[1] = value


class IndexPath(Vector(4)):
def __repr__(self):
return "<indexPath [{}]>".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 "<size width={} height={}>".format(self.value[0], self.value[1])
Expand Down