I want to create a font with a large volume of glyphs. Think Japanese kanji, in the thousands. So there will definitely be some scripting / batch processing required. Luckily FontForge supports python scripting! Unluckily I haven't been able to get it working. [sadface]
Firstly, thanks to the user Hoff for posting code here that answered a big part of my question. But upon running his script I encounter problems which raise more questions:
Failed to find NameList: AGL For New Fonts
Warning: Font contained no glyphs
Updates:
- The "font contained no glyphs" error is apparently a bug in FontForge that occurs when the font contains one or less glyph. Adding a second glyph 'B' resolved this.
- I found the same syntax can be used whether saving .ttf .sfd .otf etc.
- The NameList failure actually doesn't prevent the font file from being written. I was happy to discover this, but still don't understand how to provide the NameList it wants.
Here is Hoff's code:
import fontforge
font = fontforge.open('blank.sfd')
glyph = font.createMappedChar('A')
glyph.importOutlines('sourceimg.svg')
font.generate('testfont.ttf')
After five hours of struggling yesterday with building FontForge (a confusing process on a Mac). I appear to have it up and running properly. I had at first installed a pre-built version from a .dmg only to find it lacked python support. But since Hoff seemed not to encounter the same error I did, I'm not ruling out a build issue.
Either way, I don't understand the error involving AGL. What is AGL? I looked it up: "Adobe Glyph List - a standard glyph naming convention". Sounds like FontForge tried to map Unicode values to glyph names and couldn't.
So, why the AGL NameList problem? Thanks in advance for any help.
blank.sfd
a kanji font? Maybe start with an new font:fontforge.font()
. Maybe load a namelist:fontforge.loadNamelist('some_name_list.txt')
– Residence