Skip to content

Commit

Permalink
Merge pull request #83 from daltonmaag/fix-x0-guidelines
Browse files Browse the repository at this point in the history
Leave guidelines alone when at x or y = 0
  • Loading branch information
anthrotype committed May 13, 2021
2 parents 783ec14 + 2afb3a3 commit 186dbc1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Expand Up @@ -47,4 +47,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coverage run setup.py test
coveralls
coveralls --service=github
4 changes: 2 additions & 2 deletions src/ufonormalizer/__init__.py
Expand Up @@ -524,9 +524,9 @@ def _normalizeDictGuideline(guideline):
# The spec was ambiguous about y=0 or x=0, so don't raise an error here,
# instead, <x=300 y=0> or <x=0 y=300> are allowed, and the 0 becomes None.
if angle is None:
if x == 0:
if x == 0 and y is not None:
x = None
if y == 0:
if y == 0 and x is not None:
y = None
# either x or y must be defined
if x is None and y is None:
Expand Down
14 changes: 14 additions & 0 deletions tests/test_ufonormalizer.py
Expand Up @@ -710,13 +710,27 @@ def test_normalizeFontInfoPlist_guidelines_vertical_y_is_zero(self):
_normalizeGlifGuideline(element, writer)
self.assertEqual(writer.getText(), '<guideline x="100"/>')

def test_normalizeFontInfoPlist_guidelines_vertical_y_is_zero2(self):
# Actually a vertical guide
element = ET.fromstring("<guideline y='0'/>")
writer = XMLWriter(declaration=None)
_normalizeGlifGuideline(element, writer)
self.assertEqual(writer.getText(), '<guideline y="0"/>')

def test_normalizeFontInfoPlist_guidelines_horizontal_x_is_zero(self):
# Actually an horizontal guide
element = ET.fromstring("<guideline x='0.0' y='100'/>")
writer = XMLWriter(declaration=None)
_normalizeGlifGuideline(element, writer)
self.assertEqual(writer.getText(), '<guideline y="100"/>')

def test_normalizeFontInfoPlist_guidelines_horizontal_x_is_zero2(self):
# Actually an horizontal guide
element = ET.fromstring("<guideline x='0.0'/>")
writer = XMLWriter(declaration=None)
_normalizeGlifGuideline(element, writer)
self.assertEqual(writer.getText(), '<guideline x="0"/>')

def test_normalizeGLIF_lib_defined(self):
e = '''
<lib>
Expand Down

0 comments on commit 186dbc1

Please sign in to comment.