draw character from glyph name



  • Hello,

    I'm trying to draw a character on the canvas by calling an index from a list of glyph names.

    newPage('A4Landscape')
    font('SFMono-Regular')
    fontSize(60)
    txt = listFontGlyphNames()
    text(txt[60], (30, 30))
    

    What is the way to convert a glyph name to the character that represents it?

    Cheers,
    Artur



  • FormattedString is your best friend here, as you can add a glyph name to the string and get the glyph with the appendGlyph method.

    so for your code:

    newPage('A4Landscape')
    font('SFMono-Regular')
    fontSize(60)
    txt = listFontGlyphNames()
    t = FormattedString()
    t.appendGlyph(txt[60])
    text(t, (30, 30))
    


  • Thanks Ben!


Log in to reply