graphicore / ufoJS

Javascript API for the Unified Font Object
lib.ufojs.org
GNU General Public License v3.0
52 stars 10 forks source link

ufoJS ignores file not found, which confuses its clients #7

Closed rrthomas closed 9 years ago

rrthomas commented 10 years ago

This arose from Metapolator issue #134: https://github.com/metapolator/metapolator/issues/134

The problem in this case is that GlyphSet.js contains the code

                if(error instanceof IONoEntryError)
                    // missing, consider the glyphset empty.
                    return {};

Commit 38cbb962, which seems to be the source of this treating IONoEntryError as "empty" has the unenlightening commit message "started adding async apis for some methods".

So, I guess there's a reason for this behavior, but unfortunately it means that clients aren't told if they've passed a non-existent directory, so they'd have to do their own checks, which isn't terribly logical. Can we fix this?

graphicore commented 10 years ago

The reason for this behavior is twofold:

  1. legacy: robofab does the same thing in GlyphSet see: http://code.robofab.com/browser/branches/ufo3k/Lib/ufoLib/glifLib.py#L137
  2. ufoJS is not complete yet, we don't provide the whole UFOReader etc. infrastructure that is provided by RoboFab because its not ported yet. I predict that, when ufoJS is complete and the proper APIs are beeing used, this and many other other issues with validating UFOs go away.

As far as the commit message goes: You can consider almost everything in ufoJS as beeing rooted in http://code.robofab.com/browser/branches/ufo3k/ so if you don't like a specific behavior of ufoJS its probably in robofab, too. The biggest changes I introduced where:

I suggest, as it is not possible to use UFOReader with ufoJS at the moment (because it doesn't exist) that metapolator checks these cases. It's an unfortunate situation of course.

rrthomas commented 10 years ago

In most cases, this behaviour seems fine (in other words, it's an internal "validation hack"). However, in my particular case it seems unfortunate, as the entire font does not exist. Surely this can result in failure?