googlefonts / googlefonts/glyphsLib
Category guessing leads to bizarre results
- Dominant language
- Python
- Stars
- 201
- Forks
- 56
- Avg merge
- 17m
- Merged PRs (30d)
- 1
Description
Why aren't my marks attaching to my bases? I have a base glyph "brm_RR" and that works fine, and another base glyph "brm_R" and marks don't attach. Turns out it's because:
```IPython
In [4]: from glyphsLib.glyphdata import get_glyph
In [5]: get_glyph("brm_RR")
Out[5]: Glyph(name='brm_RR', production_name='brm_RR', unicode=None, category=None, subCategory=None, script=None, description=None)
In [6]: get_glyph("brm_R")
Out[6]: Glyph(name='brm_R', production_name='brm_R', unicode=None, category='Letter', subCategory='Ligature', script=None, description=None)
```
`brm_R` goes into ligatures not bases in GDEF, so marks aren't attached. But why is `brm_R` considered a ligature? Because...
https://github.com/googlefonts/glyphsLib/blob/10c8b1d9d7a6e71871a91f2ffbb4ce5b7ccbd582/Lib/glyphsLib/glyphdata.py#L245-L247
`brm_` is skipped, R is looked up, R is a letter, and so `_translate_category` is called, and inside `_translate_category`:
https://github.com/googlefonts/glyphsLib/blob/10c8b1d9d7a6e71871a91f2ffbb4ce5b7ccbd582/Lib/glyphsLib/glyphdata.py#L295-L298
This is **way too much magic**.
I literally told Glyphs that it was Category=Letter, but no, glyphsLib thinks it knows better.
Contributor guide
Research direction
Read Lib/glyphsLib/glyphdata.py around the linked lines and reproduce the get_glyph("brm_RR") and get_glyph("brm_R") calls. Trace how the name is categorized and review existing tests; done means the reported category behavior is resolved and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100