New Plugin: Guten Tag [beta]

Yesterday I learned about tags in Glyphs. When you select one or more glyphs in the font view you can tag the selected glyphs with the Tags field in the lower left.

Tags can then be used in feature code like so:

# class of all glyphs with some tag
[$[tags contains "sometag"]]
# class of all glyphs without some tag
[$[not tags contains "sometag"]]

They are immensely useful to my workflow so I also want to see and edit them from the edit view. That is what Guten Tag does:

Screenshot

You can view, add, remove, and overwrite tags. Clicking on the little triangle to the right shows a list of all glyphs with the selected tag.

That’s it! Guten Tag is my first attempt at a Glyphs plugin so I expect there still to be many rough edges; do let me know if anything does not work or look like it should.

You can get the plugin from GitHub:
https://github.com/florianpircher/GutenTag


Some notes:

I did try to translate the few words that are required for the UI, but I did not hire a professional (the project is just too small in scope). If you speak a language you can check whether my translations are incorrect/missing by looking at the translation tables.

I tried to implement autocomplete, such that tags that exist on other glyphs are suggested when typing a new tag but tokenField:completionsForSubstring:indexOfToken:indexOfSelectedItem: crashes the entire application regardless of what value I return. Maybe an experienced plugin developer can tell me what I am doing wrong.

3 Likes

Two questions for the Glyphs team:

  1. Is there an API to get an image for a glyph? I would like to add a template image thumbnail to each menu-item when viewing the list of tagged glyphs:

  1. What is the legal character set for tags? Are spaces allowed? Currently I split on spaces and commas, but I could also revert to only using commas.

No separate API. You would need to build the NSMenu item yourself in PyObjC.

I do build the NSMenuItem in PyObjC:

1 Like

Generating a general purpose layer to image API wasn’t something I needed. The requirements are too different: Do you need it centered on the bounding box (would draw in different scales and positions) or better center on the metrics box (would keep scale and position but will cut off stuff). And in the size needed for a menu to work it would not show much anyway. Have a look at the context popups in the feature code editor (Option+click on a class name).
you could add a custom view for each item. Then you can get bigger lines and draw the images in place. (GSLayerDrawHelper).

I’ll add some comments to the code in GitHub.

That’s understandable. I don’t need the thumbnail, they would just be a nice addition.

I was planing on sizing the images approximately as large as in the feature code popover. I am almost certain NSMenuItem won’t complain about images of larger sizes.

Thanks, I’ll have a look.

Where would I find documentation on this symbol?

Glyphs 3.app/Contents/Frameworks/GlyphsCore.framework/Versions/A/Headers/GSLayerDrawHelper.h

1 Like

I have made some changes that are now on GitHub.

  1. Autocomplete works now thanks to @GeorgSeifert’s pointer:

  1. Spaces are now allows in tag names.
  2. The tag menu now shows a thumbnail for the glyphs with that tag:

  1. Also, menu items are now selectable; clicking on a glyph opens it in a new tab.
  2. Performance improvements and bug fixes.
3 Likes

I tried it and it looks very good.
some tiny things:

  • I would increase the corner radius of the color labels (to 3 or 4).
  • don’t open a new tab but show the glyph in the current tab, like the kerning panel
    def openGlyph_(self, sender):
         if font := self.currentFont():
            glyph = font.glyphs[sender.title()]
            self.windowController().graphicView().replaceActiveLayersWithGlyphs_([glyph])
  • you can use methods direction as actions, no need to use objc.selector: item.setAction_(self.openGlyph_)
1 Like

I use a 1pt radius — directly emulating the corner radius of the font feature preview. Even got xScope involved to copy your design! But, OK, I’ll try 3pt/4pt.

Bildschirmfoto 2021-02-01 um 01.24.19

That works if the user is already in the edit view but crashes in the font view. The idea is good, so I will add a conditional and open a new tab only from the font view.

Good to know, will change. That’s what happens when I copy code I found online. Thanks for the updated code snippet.