googlefonts / googlefonts/glyphsLib

Hints: handle up and down targets

Open
#376 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
201
Forks
56
Avg merge
17m
Merged PRs (30d)
1

Description

It's apparently easy to accidentally add hints. One glyph contained in its lib field:

```
{'com.schriftgestaltung.Glyphs.glyph.rightMetricsKey': '=|',
'com.schriftgestaltung.hints': [{'horizontal': True, 'options': 0, 'origin': [0, 2], 'stem': -2, 'target': ['d', 'o', 'w', 'n'], 'type': 'TopGhost'}],
'public.markColor': '0.04,0.57,0.04,1'}
```

glyphsLib output:
```
Traceback (most recent call last):
...
File "/Users/.../venv/lib/python3.6/site-packages/glyphsLib/builder/__init__.py", line 115, in to_glyphs
return builder.font
File "/Users/.../venv/lib/python3.6/site-packages/glyphsLib/builder/builders.py", line 343, in font
self.to_glyphs_glyph(glyph, layer, master)
File "/Users/.../venv/lib/python3.6/site-packages/glyphsLib/builder/glyph.py", line 216, in to_glyphs_glyph
self.to_glyphs_hints(ufo_glyph, layer)
File "/Users/.../venv/lib/python3.6/site-packages/glyphsLib/builder/hints.py", line 57, in to_glyphs_hints
value = Point(*hint[attr])
TypeError: __init__() takes from 1 to 4 positional arguments but 5 were given
```

https://github.com/googlei18n/glyphsLib/blob/b35f4abe16df4d49f687833dbf841b9d7b0ec281/Lib/glyphsLib/builder/hints.py#L55

Contributor guide

Open the contributing guide

Research direction

Start at Lib/glyphsLib/builder/hints.py around line 55 and reproduce the conversion using a glyph containing a hint whose target is ['d', 'o', 'w', 'n']. Confirm the current Point construction failure, then verify that handling these targets completes without the TypeError and preserves the hint data.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.