robotools / fontParts

The replacement for RoboFab
MIT License
133 stars 44 forks source link

Change how anchor name value is gotten #679

Open benkiel opened 1 year ago

benkiel commented 1 year ago

This should account for getting a value that doesn't exist in a math glyph, addressing #678

typemytype commented 1 year ago

the anchor.name attribute is optional according the spec, so is anchor.color, this could also be changed to anchor.get("color")

benkiel commented 1 year ago

Agree, changed. Still not going to solve @LettError's problem, unfortunately

justvanrossum commented 1 year ago

But look how toMathGlyph always sets name and color:

https://github.com/robotools/fontParts/blob/f5250dc93916f45d5bf3e286cf44ff4c7dad9965/Lib/fontParts/base/glyph.py#L1641-L1649

I don't quite understand what "the spec" (which spec?) has to do with this.

benkiel commented 1 year ago

@justvanrossum UFO Spec: https://unifiedfontobject.org/versions/ufo3/glyphs/glif/#anchor

LettError commented 1 year ago

Would like to test, but how do I get this code to run locally?

justvanrossum commented 1 year ago

UFO Spec

Perhaps I'm nitpicking, but what I mean is, this is just an object implementation, and it can decide by itself whether it demands those attributes to exist or not. Perhaps it requires the "missing" attributes to be substituted by None. The spec specifies the format, not how objects should be implemented.