【问题标题】:Alphanumeric ligatures字母数字连字
【发布时间】:2015-11-06 23:08:48
【问题描述】:

我正在使用 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()

但是,当我将字符串 'cmetsmultiple' 更改为 'cmetsmultiple128' 时,它会引发错误:

查找子表包含构成整个子表的未使用字形 1 无效

其中 '1' 是字符串中的第一个数字。当我调用 addPosSub() 时抛出此错误

如何在连字中添加数字?

【问题讨论】:

    标签: python fontforge


    【解决方案1】:

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

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

    您的字形应使用Adobe Glyph List 命名

    数字必须是名字:

    0 = zero
    1 = one
    2 = two
    3 = three
    4 = four
    5 = five
    6 = six
    7 = seven
    8 = eight
    9 = nine
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-05
      • 1970-01-01
      • 2021-08-04
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 2013-01-12
      相关资源
      最近更新 更多