本文整理汇总了Python中defcon.Font.newLayer方法的典型用法代码示例。如果您正苦于以下问题:Python Font.newLayer方法的具体用法?Python Font.newLayer怎么用?Python Font.newLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类defcon.Font
的用法示例。
在下文中一共展示了Font.newLayer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delitem
# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import newLayer [as 别名]
def test_delitem(self):
font = Font(makeTestFontCopy())
path = os.path.join(font.path, "glyphs.public.background")
self.assertTrue(os.path.exists(path))
layers = font.layers
del layers["public.background"]
layers.dirty = True
self.assertEqual(layers.layerOrder, ["public.default", "Layer 1"])
self.assertNotIn("public.background", layers)
self.assertEqual(len(layers), 2)
with self.assertRaisesRegex(KeyError, "public.background"):
layers["public.background"]
font.save()
path = os.path.join(font.path, "glyphs.public.background")
self.assertFalse(os.path.exists(path))
tearDownTestFontCopy()
font = Font(makeTestFontCopy())
path = os.path.join(font.path, "glyphs.public.background")
del font.layers["public.background"]
layer = font.newLayer("public.background")
layer.newGlyph("B")
font.save()
self.assertFalse(os.path.exists(os.path.join(path, "A_.glif")))
self.assertTrue(os.path.exists(os.path.join(path, "B_.glif")))
示例2: test_newLayer
# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import newLayer [as 别名]
def test_newLayer(self):
font = Font(getTestFontPath())
layers = font.layers
layer = font.newLayer("Test")
self.assertTrue(layer.dirty)
self.assertTrue(layers.dirty)
self.assertTrue(font.dirty)
self.assertEqual(
layers.layerOrder,
["public.default", "public.background", "Layer 1", "Test"])