Sources I've looked at:
- http://stackoverflow.com/questions/12713444/inverted-glyph-bitmap-svg-via-autotrace-glyph-via-fontforge
- http://stackoverflow.com/questions/22124130/import-a-sequence-of-svg-files-into-fontforge-as-glyphs-and-output-a-font-file
- http://dmtr.org/ff.php
I have a hunch that createMappedChar()
doesn't work unless you've done loadNameList('glyphlist.txt')
or loadNameList('aglfn.txt')
(BSD-licensed Adobe glyph lists). An alternative seems to be to go by codepoint with createChar()
.
import fontforge
#fontforge.loadNameList('aglfn.txt') # Might be optional
#font = fontforge.open('existing.sfd')
font = fontforge.font() # new font
glyphNameAndOutlineFilename = {
('A', 'capital-a-glyph.svg'),
('Adieresis', 'capital-adieresis-glyph.svg'),
...
}
#characterAndOutlineFilename = {
# ('A', 'capital-a-glyph.svg'),
# ('Ä', 'capital-adieresis-glyph.svg'),
# ...
#}
for name, filename in glyphNameAndOutlineFilename:
glyph = font.createMappedChar(name)
glyph.importOutlines(filename)
# May need to set glyph.width here
#for c, filename in characterAndOutlineFilename:
# glyph = font.createChar(ord(c))
# glyph.importOutlines(filename)
# # May need to set glyph.width here
#font.generate('output-font.ttf')
font.save('output-font.sfd')
And i get:
Multiple names when parsing glyphlist for unicode ae
Failed to parse color
Failed to parse color
Internal Error: Some fragments did not join
Failed to parse color
Failed to parse color
Rename A by U0041
Rename B by U0042