當前位置: 首頁>>代碼示例>>Python>>正文


Python Axis.nameID方法代碼示例

本文整理匯總了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)
開發者ID:n8willis,項目名稱:fonttools,代碼行數:18,代碼來源:__init__.py

示例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
開發者ID:quminzi,項目名稱:fonttools,代碼行數:20,代碼來源:_f_v_a_r_test.py

示例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))
開發者ID:quminzi,項目名稱:fonttools,代碼行數:21,代碼來源:_f_v_a_r_test.py

示例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)
開發者ID:Moscarda,項目名稱:fonttools,代碼行數:23,代碼來源:interpolate.py

示例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),
     )
開發者ID:andyvand,項目名稱:fonttools,代碼行數:25,代碼來源:_f_v_a_r_test.py


注:本文中的fontTools.ttLib.tables._f_v_a_r.Axis.nameID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。