本文整理匯總了Python中fontTools.ttLib.tables._f_v_a_r.Axis.nameID方法的典型用法代碼示例。如果您正苦於以下問題:Python Axis.nameID方法的具體用法?Python Axis.nameID怎麽用?Python Axis.nameID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fontTools.ttLib.tables._f_v_a_r.Axis
的用法示例。
在下文中一共展示了Axis.nameID方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _add_fvar
# 需要導入模塊: from fontTools.ttLib.tables._f_v_a_r import Axis [as 別名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.Axis 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)
示例2: MakeFont
# 需要導入模塊: from fontTools.ttLib.tables._f_v_a_r import Axis [as 別名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.Axis 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
示例3: test_toXML
# 需要導入模塊: from fontTools.ttLib.tables._f_v_a_r import Axis [as 別名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.Axis import nameID [as 別名]
def test_toXML(self):
font = MakeFont()
axis = Axis()
axis.decompile(FVAR_AXIS_DATA)
AddName(font, "Optical Size").nameID = 256
axis.nameID = 256
writer = XMLWriter(StringIO())
axis.toXML(writer, font)
self.assertEqual([
'',
'<!-- Optical Size -->',
'<Axis>',
'<AxisTag>opsz</AxisTag>',
'<MinValue>-0.5</MinValue>',
'<DefaultValue>1.3</DefaultValue>',
'<MaxValue>1.5</MaxValue>',
'<NameID>256</NameID>',
'</Axis>'
], xml_lines(writer))
示例4: AddFontVariations
# 需要導入模塊: from fontTools.ttLib.tables._f_v_a_r import Axis [as 別名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.Axis 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_toXML
# 需要導入模塊: from fontTools.ttLib.tables._f_v_a_r import Axis [as 別名]
# 或者: from fontTools.ttLib.tables._f_v_a_r.Axis import nameID [as 別名]
def test_toXML(self):
font = MakeFont()
axis = Axis()
axis.decompile(FVAR_AXIS_DATA)
AddName(font, "Optical Size").nameID = 256
axis.nameID = 256
writer = XMLWriter(StringIO())
axis.toXML(writer, font)
self.assertEqual(
[
"",
"<!-- Optical Size -->",
"<Axis>",
"<AxisTag>opsz</AxisTag>",
"<MinValue>-0.5</MinValue>",
"<DefaultValue>1.3</DefaultValue>",
"<MaxValue>1.5</MaxValue>",
"<Flags>10011000 01110110</Flags>",
"<NameID>256</NameID>",
"</Axis>",
],
xml_lines(writer),
)