Typophile

Robofab generateGlyph ?

RachelR

Hi all

I'm looking for a simple way to generate the Accents glyphs with a Robofab/Python script. From the Robofab documentation it looks like generateGlyph should do the trick.


from robofab.world import CurrentFont
f = CurrentFont()
glyphs = ['ccaron','amacron','Cacute','Cdotaccent','Abreve','cdotaccent','ccircumflex','Aogonek','abreve','cacute','Ccaron','Amacron','aogonek','Ccircumflex']

for glyph in glyphs:
nglyph = f.generateGlyph(glyph)
nglyph.autoUnicodes()
nglyph.mark = 10
#
f.update()

This works fine for generating the glyphs and adding the base glyphs but doesn't add the accent. Is it possible to add the accent with Robofab so the code would work like - Glyph > Generate Gkyohs in FontLab.

Rr

Have you had a look at Ben Kiel's 'accentTools'? http://www.benkiel.com/typeDesign/
It might be of inspiration, or actually what you are looking for.

I tired that script but it seemed to be doing the same thing - adding the base glyph but not the accent.

It sounds like you don't have your accents named correctly. Also, check that you have your anchors named correctly in your base glyphs and in the accents (and remember the accents are supposed to start with an _).

Hi,

You can try with this:

----------------------------------------------------
from robofab.world import CurrentFont
from robofab.tools.accentBuilder import AccentTools

font = CurrentFont()

accents = ['ccaron','amacron','Cacute','Cdotaccent','Abreve','cdotaccent']
accentTool = AccentTools(font, accents)

accentTool.buildAnchors(ucXOffset=30, ucYOffset=70, lcXOffset=20, lcYOffset=50, doProgress=True)

accentTool.printAnchorErrors()
accentTool.buildAccents(doProgress=True)
accentTool.printAccentErrors()
font.autoUnicodes()

#font.update()
# This glyph update isn't the best way, but it works...
for glyph in font:
glyph.update()
----------------------------------------------------

If you use standard names, you shouldn't even need a script. In the "Generate glyphs" dialog, you can just paste glyph names or link to a text file with the names of the glyphs you want to generate. I'm actually not really sure why people bother to use scripts. There is a FL system file which specifies how base glyphs and accents combine, so you can modify this if you want to use case specific accents.

Captured from web.archive.org on 3 Feb 2010. view this capture