Skip to content

Commit

Permalink
Merge pull request #36 from daltonmaag/fix-guidelines
Browse files Browse the repository at this point in the history
Fix issue with guidelines when x, y or angle are set to 0
  • Loading branch information
miguelsousa committed Jun 1, 2016
2 parents f7d5355 + 2a4b820 commit 105bbc5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions normalization/test_ufonormalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,12 @@ def test_normalizeFontInfoPlist_guidelines_no_identifier(self):
result = _normalizeDictGuideline(guideline)
self.assertEqual(result, expected)

def test_normalizeFontInfoPlist_guidelines_zero_is_not_None(self):
guideline = dict(x=0, y=0, angle=0)
expected = dict(x=0, y=0, angle=0)
result = _normalizeDictGuideline(guideline)
self.assertEqual(result, expected)

def _test_glifFormat(self):
glifFormat = {}
glifFormat[1] = GLIFFORMAT1.strip().replace(" ", "\t")
Expand Down
12 changes: 6 additions & 6 deletions normalization/ufonormalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,26 +453,26 @@ def _normalizeDictGuideline(guideline):
color = guideline.get("color")
identifier = guideline.get("identifier")
# either x or y must be defined
if not x and not y:
if x is None and y is None:
return
# if angle is specified, x and y must be specified
if (not x or not y) and angle:
if (x is None or y is None) and angle is not None:
return
# if x and y are specified, angle must be specified
if (x and y) and not angle:
if (x is not None and y is not None) and angle is None:
return
# value errors
if x:
if x is not None:
try:
x = float(x)
except ValueError:
return
if y:
if y is not None:
try:
y = float(y)
except ValueError:
return
if angle:
if angle is not None:
try:
angle = float(angle)
except ValueError:
Expand Down

0 comments on commit 105bbc5

Please sign in to comment.