本文整理匯總了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"