当前位置: 首页>>代码示例>>Python>>正文


Python Font.testForExternalChanges方法代码示例

本文整理汇总了Python中defcon.Font.testForExternalChanges方法的典型用法代码示例。如果您正苦于以下问题:Python Font.testForExternalChanges方法的具体用法?Python Font.testForExternalChanges怎么用?Python Font.testForExternalChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在defcon.Font的用法示例。


在下文中一共展示了Font.testForExternalChanges方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_delitem_glyph_dirty

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import testForExternalChanges [as 别名]
 def test_delitem_glyph_dirty(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         glyph = font["A"]
         glyph.dirty = True
         fileSystem = openTestFontAsFileSystem(path)
         glyphPath = fs.path.join("glyphs", "A_.glif")
         fileSystem.remove(glyphPath)
         contentsPath = fs.path.join("glyphs", "contents.plist")
         with fileSystem.open(contentsPath, "rb") as f:
             plist = load(f)
         del plist["A"]
         with fileSystem.open(contentsPath, "wb") as f:
             dump(plist, f)
         closeTestFontAsFileSystem(fileSystem, path)
         r = font.testForExternalChanges()
         self.assertEqual(r["deletedGlyphs"], ["A"])
         del font["A"]
         font.save()
         fileSystem = openTestFontAsFileSystem(path)
         self.assertFalse(fileSystem.exists(glyphPath))
         closeTestFontAsFileSystem(fileSystem, path)
         tearDownTestFontCopy(font.path)
开发者ID:typesupply,项目名称:defcon,代码行数:27,代码来源:test_font.py

示例2: test_testForExternalChanges

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import testForExternalChanges [as 别名]
    def test_testForExternalChanges(self):
        for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
            path = getTestFontPath(ufo)
            path = makeTestFontCopy(path)
            font = Font(path)

            # load all the objects so that they get stamped
            font.info  # i = font.info
            k = font.kerning
            font.groups  # g = font.groups
            font.lib  # l = font.lib
            font["A"]  # g = font["A"]

            d = font.testForExternalChanges()
            self.assertFalse(d["info"])
            self.assertFalse(d["kerning"])
            self.assertFalse(d["groups"])
            self.assertFalse(d["lib"])

            # make a simple change to the kerning data
            fileSystem = openTestFontAsFileSystem(font.path)
            path = u"kerning.plist"
            t = fileSystem.getbytes(path)
            t += b"<!-- test -->"
            fileSystem.setbytes(path, t)
            k._dataOnDiskTimeStamp -= 1
            closeTestFontAsFileSystem(fileSystem, font.path)

            d = font.testForExternalChanges()
            self.assertTrue(d["kerning"])
            self.assertFalse(d["groups"])
            self.assertFalse(d["info"])
            self.assertFalse(d["lib"])

            # save the kerning data and test again
            font.kerning.dirty = True
            font.save()
            d = font.testForExternalChanges()
            self.assertFalse(d["kerning"])
            self.assertFalse(d["groups"])
            self.assertFalse(d["info"])
            self.assertFalse(d["lib"])

            tearDownTestFontCopy(font.path)
开发者ID:typesupply,项目名称:defcon,代码行数:46,代码来源:test_font.py

示例3: test_testForExternalChanges

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import testForExternalChanges [as 别名]
    def test_testForExternalChanges(self):
        path = getTestFontPath("TestExternalEditing.ufo")
        font = Font(path)

        # load all the objects so that they get stamped
        font.info  # i = font.info
        k = font.kerning
        font.groups  # g = font.groups
        font.lib  # l = font.lib
        font["A"]  # g = font["A"]

        d = font.testForExternalChanges()
        self.assertFalse(d["info"])
        self.assertFalse(d["kerning"])
        self.assertFalse(d["groups"])
        self.assertFalse(d["lib"])

        # make a simple change to the kerning data
        path = os.path.join(font.path, "kerning.plist")
        f = open(path, "r")
        t = f.read()
        f.close()
        t += " "
        f = open(path, "w")
        f.write(t)
        f.close()
        os.utime(path,
                 (k._dataOnDiskTimeStamp + 1, k._dataOnDiskTimeStamp + 1))

        d = font.testForExternalChanges()
        self.assertTrue(d["kerning"])
        self.assertFalse(d["groups"])
        self.assertFalse(d["info"])
        self.assertFalse(d["lib"])

        # save the kerning data and test again
        font.kerning.dirty = True
        font.save()
        d = font.testForExternalChanges()
        self.assertFalse(d["kerning"])
        self.assertFalse(d["groups"])
        self.assertFalse(d["info"])
        self.assertFalse(d["lib"])
开发者ID:anthrotype,项目名称:defcon,代码行数:45,代码来源:test_font.py

示例4: test_delitem_glyph_not_dirty

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import testForExternalChanges [as 别名]
 def test_delitem_glyph_not_dirty(self):
     path = makeTestFontCopy()
     font = Font(path)
     font["A"]  # glyph = font["A"]
     glyphPath = os.path.join(path, "glyphs", "A_.glif")
     os.remove(glyphPath)
     contentsPath = os.path.join(path, "glyphs", "contents.plist")
     with open(contentsPath, "rb") as f:
         plist = load(f)
     del plist["A"]
     with open(contentsPath, "wb") as f:
         dump(plist, f)
     r = font.testForExternalChanges()
     self.assertEqual(r["deletedGlyphs"], ["A"])
     del font["A"]
     font.save()
     self.assertFalse(os.path.exists(glyphPath))
开发者ID:moyogo,项目名称:defcon,代码行数:19,代码来源:test_font.py

示例5: test_delitem_glyph_dirty

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import testForExternalChanges [as 别名]
 def test_delitem_glyph_dirty(self):
     path = self.path
     font = Font(path)
     layer = font.layers["public.default"]
     glyph = layer["A"]
     glyph.dirty = True
     glyphPath = os.path.join(path, "glyphs", "A_.glif")
     os.remove(glyphPath)
     contentsPath = os.path.join(path, "glyphs", "contents.plist")
     with open(contentsPath, "rb") as f:
         plist = load(f)
     del plist["A"]
     with open(contentsPath, "wb") as f:
         dump(plist, f)
     r = font.testForExternalChanges()
     self.assertEqual(r["deletedGlyphs"], ["A"])
     del layer["A"]
     font.save()
     self.assertFalse(os.path.exists(glyphPath))
开发者ID:anthrotype,项目名称:defcon,代码行数:21,代码来源:test_layer.py


注:本文中的defcon.Font.testForExternalChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。