Skip to content

fontlab_glyport.plugins.fontlab_host

fontlab_host

The plugin host contract on FontLab 9 (R025-R027).

What this module keeps (Glyphs-specific):

  • Menus: Glyphs menu names map to FontLab's main-window menus by title (FILE "File", EDIT "Edit", VIEW "View", GLYPH "Glyph", PATH "Contour", WINDOW "Window", SCRIPT "Script", HELP "Help"); FILTER_MENU and APP_MENU have no FontLab counterpart and go to an owned "Glyphs Plugins" menu. Each NSMenuItem becomes an owned QAction; its triggered runs item.fire() through the error sink, and item changes (title, state, enabled) update it.
  • Panels and filter dialogs are owned tool windows (FontLab's own panel registry is not scriptable here); a dialog closes with Apply or Cancel.
  • Painters go to the session's editor painters: native canvas painters (drawing.native_painters) when the build has them, else the overlay :class:~fontlab_glyport.drawing.editor.EditorPainters.
  • Tools: flWorkspace.registerPythonTool with a :class:~fontlab_glyport.plugins.tool_bridge.ToolBridge; builds without it raise UnsupportedCapability. Tools have no icon yet (SDK icons are PDF resources).
  • File formats: a File-menu action "Export with <title>…" calls exportFont_ with the current font.
  • Layers, fonts, snapshots and undo come from an injected model adapter (the GlyphsApp model of lane L1); without one those calls raise.

What App provides (generic): FontLabPluginHost is a :class:fontlabapp.qt.menus.OwnedMenus. That class adds the QActions, shows the tool windows, hands out the tokens and tears everything down. Its rules hold here unchanged: every token removes its widgets and connections exactly once; close() removes everything newest first, tries each item and re-raises the first failure. Nothing is disconnected or deleted while a signal of the host's own widgets dispatches (the PythonQtSignalReceiver crash pattern in AGENTS.md). Teardown, and any remove/close called from a host slot (menu action, Apply/Cancel, title-bar close, on_close callback), wait for App's shared zero-delay timer.

Why a subclass: OwnedMenus already has the seams this host needs (_token, _menu, _defer(first=True), _guarded), so the subclass adds only Glyphs mapping, NSMenuItem sync and the Apply/Cancel dialog. It never edits App's private queue. A missing main window is App's qtsafe.MainWindowNotFound; the host reports it as HostUnavailable.

Classes

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
MENU_TITLES attribute
OWNED_MENU attribute
qt_widget function (view: Any) -> Any A Cocoa view wrapper's Qt widget, or the widget itself (vanilla handles).