Nagwa-Limited-Community / Glyphs-MATH-Plugin

11 stars 1 forks source link

Plugin crashes on "Generate Instances" #15

Closed jenskutilek closed 8 months ago

jenskutilek commented 8 months ago

When I call "File > Generate Instances", the plugin crashes with this message:

A plugin caused a crash

The Plugin MATHPlugin.glyphsPlugin has caused a crash. Please update it by opening the Plugin Manager or re-downloading it from the original source.

Details:
Traceback (most recent call last):

  File "plugin.py", line 1193, in open_
    varData[id] = [gn(n) for n in names]

  File "plugin.py", line 1193, in <listcomp>
    varData[id] = [gn(n) for n in names]

  File "plugin.py", line 1187, in gn
    return GSGlyphReference(font.glyphs[n])

  File "GlyphsApp/GlyphsApp/__init__.py", line 1832, in __getitem__

TypeError: key for glyphs must be int or str, not GSGlyphReference

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "GlyphsApp/GlyphsApp/__init__.py", line 1457, in callback_

  File "plugin.py", line 1198, in open_
    except AppKit.MPMissingGlyph as e:

  File "_lazyimport.py", line 208, in __getattr__
    raise AttributeError(name)

AttributeError: MPMissingGlyph

App:3.2-3230 Plugin:1.4.1-1.4.1 System:14.2.0
khaledhosny commented 8 months ago

I don’t know what is going on, it seems like _open() is called on a file already opened? But a simple fix would to change gn to:

def gn(n):
    if isinstance(n, GSGlyphReference):
        return n
    return GSGlyphReference(font.glyphs[n])
khaledhosny commented 8 months ago

I fixed the crash, but the math constants are not interpolated (instances not at master locations does not have them at all). This is the first time I encounter File → Generate Instances, so I’m not sure how this is supposed to work. I guess we would need to interpolate the constants, but how do we know Glyphs is generating instances?

schriftgestalt commented 8 months ago

It seem that I need to add another call-back that lets you prepare the instances and the interpolation. I’ll have a look.

schriftgestalt commented 8 months ago

The callback is already there. I just pushed some stub methods.

khaledhosny commented 8 months ago

Thanks Georg, please let me know when there is something we can use.

schriftgestalt commented 8 months ago

It is there already. Have you seen the two (empty) methods that I put at the end of the plugin file? I added it in (c091935e9f7fbb)

khaledhosny commented 8 months ago

Oh, I missed that. Thanks, I guess I need to wait for the next release to be able to actually test that, right?

schriftgestalt commented 8 months ago

No. This api is available for some time (2018?)