本文整理汇总了Python中fontTools.designspaceLib.DesignSpaceDocument.fromstring方法的典型用法代码示例。如果您正苦于以下问题:Python DesignSpaceDocument.fromstring方法的具体用法?Python DesignSpaceDocument.fromstring怎么用?Python DesignSpaceDocument.fromstring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fontTools.designspaceLib.DesignSpaceDocument
的用法示例。
在下文中一共展示了DesignSpaceDocument.fromstring方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_findDefault_axis_mapping
# 需要导入模块: from fontTools.designspaceLib import DesignSpaceDocument [as 别名]
# 或者: from fontTools.designspaceLib.DesignSpaceDocument import fromstring [as 别名]
def test_findDefault_axis_mapping():
designspace_string = """\
<?xml version='1.0' encoding='UTF-8'?>
<designspace format="4.0">
<axes>
<axis tag="wght" name="Weight" minimum="100" maximum="800" default="400">
<map input="100" output="20"/>
<map input="300" output="40"/>
<map input="400" output="80"/>
<map input="700" output="126"/>
<map input="800" output="170"/>
</axis>
<axis tag="ital" name="Italic" minimum="0" maximum="1" default="1"/>
</axes>
<sources>
<source filename="Font-Light.ufo">
<location>
<dimension name="Weight" xvalue="20"/>
<dimension name="Italic" xvalue="0"/>
</location>
</source>
<source filename="Font-Regular.ufo">
<location>
<dimension name="Weight" xvalue="80"/>
<dimension name="Italic" xvalue="0"/>
</location>
</source>
<source filename="Font-Bold.ufo">
<location>
<dimension name="Weight" xvalue="170"/>
<dimension name="Italic" xvalue="0"/>
</location>
</source>
<source filename="Font-LightItalic.ufo">
<location>
<dimension name="Weight" xvalue="20"/>
<dimension name="Italic" xvalue="1"/>
</location>
</source>
<source filename="Font-Italic.ufo">
<location>
<dimension name="Weight" xvalue="80"/>
<dimension name="Italic" xvalue="1"/>
</location>
</source>
<source filename="Font-BoldItalic.ufo">
<location>
<dimension name="Weight" xvalue="170"/>
<dimension name="Italic" xvalue="1"/>
</location>
</source>
</sources>
</designspace>
"""
designspace = DesignSpaceDocument.fromstring(designspace_string)
assert designspace.findDefault().filename == "Font-Italic.ufo"
designspace.axes[1].default = 0
assert designspace.findDefault().filename == "Font-Regular.ufo"