0

我正在使用 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() 时引发此错误

如何在连字中添加数字?

4

1 回答 1

0

元组需要包含要替换的字形名称。

liga = ('a','one', 'Delta')
icon.addPosSub("liga", liga)

您的字形应使用Adob​​e 字形列表命名

数字必须是名称:

0 = zero
1 = one
2 = two
3 = three
4 = four
5 = five
6 = six
7 = seven
8 = eight
9 = nine
于 2016-02-17T09:53:38.427 回答