Drawbot in Glyphs question

Maybe is a silly question, but her I go. How can I use the current font in glyphs to “write” a string?

Thanks in advance!

That should work as in all other versions of DrawBot. There has to be sample code.

This is super old but does anyone have an answer to this? I suppose you could export the font you’re editing and install it temporarily, but then you’d lose access to the Glyphs python API, right?

It still work and that’s what I do if I need to display more text than just a short string. Btw you don’t need to install the font system wide, you just need to export it somewhere and can call it from DB (maybe that’s what you meant).
If it’s counterproductive to export fonts at this point of your design process, the easiest way I found is to keep track of the width of the glyph you just displayed and pass that to Translate() before displaying your next glyph. Can get more complex if you want kerning though.

I have the same question. In RoboFont, there is an API .testInstall() to install the font locally and can be used within the drawbot app (it works by generating the otf files). There is an api in drawbot to install the font too. In this meantime, I’ll just go with this way, to write my custom testInstall function:

from GlyphsApp import *

def testInstall():
    font = Glyphs.font
    path = '/var/tmp/'
    format = 'OTF'
    ext = '.otf'
    names = []

    for instance in font.instances:
        if instance.active:
            fontName = instance.fontName
            instance.generate(Format=format, FontPath=path, Containers=[PLAIN])
            n = installFont(path + fontName + ext)
    return names

installedFonts = testInstall()


t = FormattedString()

for f in installedFonts:
    t += 'hamburgefontsiv\n'

textBox(t, (30, 30, width()-60, height()-60))

Use it with the drawbot Glyphs plugin. But there is an issue with the installFont function when I rerun the code that sometimes it doesn’t recognize the font:

*** DrawBot warning: font: 'FontName-Regular' is not installed, back to the fallback font: 'LucidaGrande' ***

@GeorgSeifert do you know what is the problem? It seems to occur on the original drawbot app as well.

Installing fonts in the system is dangerous – font cache problems and such. Have you tried to uninstall the fonts, first?

The installFont() function in Drawbot doesn’t install fonts in the system, they’re supposed to be active for the current Drawbot session only I think.
I’ve had the same occasional issue as @sovichet but I think it’s something that should better be brought to the Drawbot people?

Even when it is only active for the current process it is still processed by the system.

Oh, I didn’t know that, thought it would work like the Adobe fonts folder, or your Text Preview app.

I see. I thought the same as @joachimvu.

Yeah that’s what I meant. Ideally I would prefer not to do that, because I like how easy it is to access some elements through the Glyphs API, like for drawing nodes and handles. But I’ve been looking at the DrawBot documentation and I think I might still be able to do what I want this way, so I’ll give it a try.

Adobe is not useing the system font handling at all. They do all of it themselves. And the Textpreview app is specially crafted around the system.