本文整理汇总了Python中fontTools.ttLib.tables.TupleVariation.TupleVariation.fromXML方法的典型用法代码示例。如果您正苦于以下问题:Python TupleVariation.fromXML方法的具体用法?Python TupleVariation.fromXML怎么用?Python TupleVariation.fromXML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fontTools.ttLib.tables.TupleVariation.TupleVariation
的用法示例。
在下文中一共展示了TupleVariation.fromXML方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fromXML_badDeltaFormat
# 需要导入模块: from fontTools.ttLib.tables.TupleVariation import TupleVariation [as 别名]
# 或者: from fontTools.ttLib.tables.TupleVariation.TupleVariation import fromXML [as 别名]
def test_fromXML_badDeltaFormat(self):
g = TupleVariation({}, [])
with CapturingLogHandler(log, "WARNING") as captor:
for name, attrs, content in parseXML('<delta a="1" b="2"/>'):
g.fromXML(name, attrs, content)
self.assertIn("bad delta format: a, b",
[r.msg for r in captor.records])
示例2: test_fromXML_points
# 需要导入模块: from fontTools.ttLib.tables.TupleVariation import TupleVariation [as 别名]
# 或者: from fontTools.ttLib.tables.TupleVariation.TupleVariation import fromXML [as 别名]
def test_fromXML_points(self):
g = TupleVariation({}, [None] * 4)
for name, attrs, content in parseXML(
'<coord axis="wdth" min="0.3" value="0.4" max="0.5"/>'
'<coord axis="wght" value="1.0"/>'
'<coord axis="opsz" value="-0.7"/>'
'<delta pt="1" x="33" y="44"/>'
'<delta pt="2" x="-2" y="170"/>'):
g.fromXML(name, attrs, content)
self.assertEqual(AXES, g.axes)
self.assertEqual([None, (33, 44), (-2, 170), None], g.coordinates)
示例3: test_fromXML_constants
# 需要导入模块: from fontTools.ttLib.tables.TupleVariation import TupleVariation [as 别名]
# 或者: from fontTools.ttLib.tables.TupleVariation.TupleVariation import fromXML [as 别名]
def test_fromXML_constants(self):
g = TupleVariation({}, [None] * 4)
for name, attrs, content in parseXML(
'<coord axis="wdth" min="0.3" value="0.4" max="0.5"/>'
'<coord axis="wght" value="1.0"/>'
'<coord axis="opsz" value="-0.7"/>'
'<delta cvt="1" value="42"/>'
'<delta cvt="2" value="-23"/>'):
g.fromXML(name, attrs, content)
self.assertEqual(AXES, g.axes)
self.assertEqual([None, 42, -23, None], g.coordinates)
示例4: fromXML
# 需要导入模块: from fontTools.ttLib.tables.TupleVariation import TupleVariation [as 别名]
# 或者: from fontTools.ttLib.tables.TupleVariation.TupleVariation import fromXML [as 别名]
def fromXML(self, name, attrs, content, ttFont):
if name == "version":
self.majorVersion = int(attrs.get("major", "1"))
self.minorVersion = int(attrs.get("minor", "0"))
elif name == "tuple":
valueCount = len(ttFont["cvt "].values)
var = TupleVariation({}, [None] * valueCount)
self.variations.append(var)
for tupleElement in content:
if isinstance(tupleElement, tuple):
tupleName, tupleAttrs, tupleContent = tupleElement
var.fromXML(tupleName, tupleAttrs, tupleContent)