我正在使用 fontforge 创建带有连字的字体,其中一些使用数字。我可以使用纯字母的连字来正常工作,但是,当我使用数字时,它会引发错误。
这是我到目前为止的代码:
import fontforge
font = fontforge.font()
font.encoding = 'UnicodeFull'
font.version = '1.0'
font.weight = 'Regular'
font.fontname = 'icon'
font.familyname = 'icon'
font.fullname = 'icon'
font.em = 1008
font.ascent = 864
font.descent = 144
# Set up ligatures
font.addLookup('liga', 'gsub_ligature', (), (('liga', (('latn', ('dflt')), )), ))
font.addLookupSubtable('liga', 'liga')
def createEmptyChar(font, char):
glyph = font.createChar(ord(char)).glyphPen()
glyph.moveTo((0, 0))
glyph = None
# Empty all characters to remove gibberish...
for code in range(0, 256):
createEmptyChar(font, chr(code))
# Name of ligature
name = str('commentsmultiple')
icon = font.createChar(-1, name)
icon.addPosSub("liga", tuple(name))
icon.importOutlines('fonts/icon/svg/e601_commentsmultiple128.svg')
font.generate('fonts/icon/icon.woff')
font.close()
但是,当我将字符串“commentsmultiple”更改为“commentsmultiple128”时,会引发错误:
查找子表包含未使用的字形 1,使整个子表无效
其中 '1' 是字符串中的第一个数字。当我调用 addPosSub() 时引发此错误
如何在连字中添加数字?