metapolator/metapolator — pull request #172 by monkeyiq (2014-09-19 02:57:25+00:00)
Title: issue144: first support for continue loading on bad glyphs.

The idea is that a callback is passed down the readGlyph (with default in place). The callback can record what error happened for what glyphs. The default callback just throws an exception stopping processing.

A core change from the code just throwing an exception is that it now needs to "cleanup" after running the callback. This allows the callback to record that an error has happened and return. The calling code then needs to fix things, for example, by dropping the splines or skeletons in a single glyph if they are bad. This allows a partial import.

The advantage to this design is that the glyph and other metadata can still be imported. So for example, the "at" glyph from DroidSans which causes an error will still import the advance width and unicode hex settings for the glyph. The outline/contour is dropped however because it has import issues.

The new callback records which glyphs failed, why they failed, and when they failed. This way the GUI or tools can show these failures and allow reimport of just those previously failed glyphs.

I'm not 100% sure of where to record the metadata about glyph load failure. Two options present themselves; (a) have ProjectMaster record this information in a YAML file, and (b) push this information down to the Glyph object level. For (b) one might see the glif file as something like:

...

The code for this PR implements option (a) because it was the simplest to do. YAML<->js object is simple.