本文整理汇总了Python中fontTools.ttLib.tables._f_v_a_r.NamedInstance.nameID方法的典型用法代码示例。如果您正苦于以下问题:Python NamedInstance.nameID方法的具体用法?Python NamedInstance.nameID怎么用?Python NamedInstance.nameID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fontTools.ttLib.tables._f_v_a_r.NamedInstance
的用法示例。
在下文中一共展示了NamedInstance.nameID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_toXML
# 需要导入模块: from fontTools.ttLib.tables._f_v_a_r import NamedInstance [as 别名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.NamedInstance import nameID [as 别名]
def test_toXML(self):
font = MakeFont()
inst = NamedInstance()
inst.nameID = AddName(font, "Light Condensed").nameID
inst.coordinates = {"wght": 0.7, "wdth": 0.5}
writer = XMLWriter(StringIO())
inst.toXML(writer, font)
self.assertEqual([
'',
'<!-- Light Condensed -->',
'<NamedInstance nameID="%s">' % inst.nameID,
'<coord axis="wght" value="0.7"/>',
'<coord axis="wdth" value="0.5"/>',
'</NamedInstance>'
], xml_lines(writer))
示例2: _add_fvar
# 需要导入模块: from fontTools.ttLib.tables._f_v_a_r import NamedInstance [as 别名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.NamedInstance import nameID [as 别名]
def _add_fvar(font, axes, instances):
assert "fvar" not in font
font['fvar'] = fvar = table__f_v_a_r()
for tag in sorted(axes.keys()):
axis = Axis()
axis.axisTag = tag
name, axis.minValue, axis.defaultValue, axis.maxValue = axes[tag]
axis.nameID = _AddName(font, name).nameID
fvar.axes.append(axis)
for name, coordinates in instances:
inst = NamedInstance()
inst.nameID = _AddName(font, name).nameID
inst.coordinates = coordinates
fvar.instances.append(inst)
示例3: MakeFont
# 需要导入模块: from fontTools.ttLib.tables._f_v_a_r import NamedInstance [as 别名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.NamedInstance import nameID [as 别名]
def MakeFont():
axes = [("wght", "Weight", 100, 400, 900), ("wdth", "Width", 50, 100, 200)]
instances = [("Light", 300, 100), ("Light Condensed", 300, 75)]
fvarTable = table__f_v_a_r()
font = {"fvar": fvarTable}
for tag, name, minValue, defaultValue, maxValue in axes:
axis = Axis()
axis.axisTag = tag
axis.defaultValue = defaultValue
axis.minValue, axis.maxValue = minValue, maxValue
axis.nameID = AddName(font, name).nameID
fvarTable.axes.append(axis)
for name, weight, width in instances:
inst = NamedInstance()
inst.nameID = AddName(font, name).nameID
inst.coordinates = {"wght": weight, "wdth": width}
fvarTable.instances.append(inst)
return font
示例4: AddFontVariations
# 需要导入模块: from fontTools.ttLib.tables._f_v_a_r import NamedInstance [as 别名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.NamedInstance import nameID [as 别名]
def AddFontVariations(font):
assert "fvar" not in font
fvar = font["fvar"] = table__f_v_a_r()
weight = Axis()
weight.axisTag = "wght"
weight.nameID = AddName(font, "Weight").nameID
weight.minValue, weight.defaultValue, weight.maxValue = (100, 400, 900)
fvar.axes.append(weight)
# https://www.microsoft.com/typography/otspec/os2.htm#wtc
for name, wght in (
("Thin", 100),
("Light", 300),
("Regular", 400),
("Bold", 700),
("Black", 900)):
inst = NamedInstance()
inst.nameID = AddName(font, name).nameID
inst.coordinates = {"wght": wght}
fvar.instances.append(inst)
示例5: test_compile
# 需要导入模块: from fontTools.ttLib.tables._f_v_a_r import NamedInstance [as 别名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.NamedInstance import nameID [as 别名]
def test_compile(self):
inst = NamedInstance()
inst.nameID = 345
inst.coordinates = {"wght": 0.7, "wdth": 0.5}
self.assertEqual(FVAR_INSTANCE_DATA, inst.compile(["wght", "wdth"]))