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


Python Font.keys方法代码示例

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


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

示例1: test_insertGlyph

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import keys [as 别名]
 def test_insertGlyph(self):
     font = Font(getTestFontPath())
     glyph = Glyph()
     glyph.name = "NewGlyphTest"
     self.assertEqual(sorted(font.keys()), ["A", "B", "C"])
     font.insertGlyph(glyph)
     self.assertEqual(sorted(font.keys()), ["A", "B", "C", "NewGlyphTest"])
开发者ID:anthrotype,项目名称:defcon,代码行数:9,代码来源:test_font.py

示例2: test_keys

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import keys [as 别名]
 def test_keys(self):
     font = Font(getTestFontPath())
     self.assertEqual(sorted(font.keys()), ["A", "B", "C"])
     del font["A"]
     self.assertEqual(sorted(font.keys()), ["B", "C"])
     font.newGlyph("A")
     self.assertEqual(sorted(font.keys()), ["A", "B", "C"])
     font = Font()
     self.assertEqual(font.keys(), set())
     font.newGlyph("A")
     self.assertEqual(sorted(font.keys()), ["A"])
开发者ID:anthrotype,项目名称:defcon,代码行数:13,代码来源:test_font.py

示例3: test_newGlyph

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import keys [as 别名]
 def test_newGlyph(self):
     font = Font(getTestFontPath())
     glyph = font.newGlyph("NewGlyphTest")
     self.assertEqual(glyph.name, "NewGlyphTest")
     self.assertTrue(glyph.dirty)
     self.assertTrue(font.dirty)
     self.assertEqual(sorted(font.keys()), ["A", "B", "C", "NewGlyphTest"])
开发者ID:anthrotype,项目名称:defcon,代码行数:9,代码来源:test_font.py

示例4: test_updateGlyphOrder_rename

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import keys [as 别名]
 def test_updateGlyphOrder_rename(self):
     font = Font(getTestFontPath())
     self.assertEqual(font.glyphOrder, [])
     font.glyphOrder = sorted(font.keys())
     self.assertEqual(font.glyphOrder, ["A", "B", "C"])
     font.updateGlyphOrder(addedGlyph="new", removedGlyph="B")
     self.assertEqual(font.glyphOrder, ["A", "new", "C"])
开发者ID:anthrotype,项目名称:defcon,代码行数:9,代码来源:test_font.py

示例5: test_name_set

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import keys [as 别名]
    def test_name_set(self):
        font = Font(getTestFontPath())
        glyph = font["A"]
        glyph.name = "RenamedGlyph"
        self.assertEqual(glyph.name, "RenamedGlyph")
        self.assertEqual(sorted(font.keys()), ["B", "C", "RenamedGlyph"])

        font = Font(getTestFontPath())
        glyph = font["A"]
        glyph.name = "A"
        self.assertFalse(glyph.dirty)
开发者ID:anthrotype,项目名称:defcon,代码行数:13,代码来源:test_glyph.py

示例6: test_glyphOrder

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import keys [as 别名]
 def test_glyphOrder(self):
     font = Font(getTestFontPath())
     self.assertEqual(font.glyphOrder, [])
     font.glyphOrder = sorted(font.keys())
     self.assertEqual(font.glyphOrder, ["A", "B", "C"])
     layer = font.layers.defaultLayer
     layer.newGlyph("X")
     self.assertEqual(sorted(layer.keys()), ["A", "B", "C", "X"])
     self.assertEqual(font.glyphOrder, ["A", "B", "C", "X"])
     del layer["A"]
     self.assertEqual(font.glyphOrder, ["A", "B", "C", "X"])
     del layer["X"]
     self.assertEqual(font.glyphOrder, ["A", "B", "C"])
     layer["B"].name = "Y"
     self.assertEqual(font.glyphOrder, ["A", "Y", "C"])
开发者ID:anthrotype,项目名称:defcon,代码行数:17,代码来源:test_font.py

示例7: test_delitem

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import keys [as 别名]
 def test_delitem(self):
     path = makeTestFontCopy()
     font = Font(path)
     del font["A"]
     self.assertTrue(font.dirty)
     font.newGlyph("NewGlyphTest")
     del font["NewGlyphTest"]
     self.assertEqual(sorted(font.keys()), ["B", "C"])
     self.assertEqual(len(font), 2)
     self.assertFalse("A" in font)
     font.save()
     fileNames = glob.glob(os.path.join(path, 'glyphs', '*.glif'))
     fileNames = [os.path.basename(fileName) for fileName in fileNames]
     self.assertEqual(sorted(fileNames), ["B_.glif", "C_.glif"])
     with self.assertRaises(KeyError):
         del font["NotInFont"]
开发者ID:typesupply,项目名称:defcon,代码行数:18,代码来源:test_font.py

示例8: len

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import keys [as 别名]
except ImportError:
    # on command line
    fontPaths = sys.argv[1:]
    platform = 'CL'


if len(fontPaths):

    for fontPath in fontPaths:
        f = Font(fontPath)
        if not enc:
            # only necessary once for multiple UFOs
            enc = makeEnc(f, platform)

        remainingGlyphs = sorted(list(set(f.keys()) - set(enc)))

        f.lib['com.typemytype.robofont.sort'] = {
            'ascending': enc+remainingGlyphs,
            'type': 'glyphList'}
        f.lib['public.glyphOrder'] = enc+remainingGlyphs

        grey = [0.5, 0.5, 0.5, 0.5]
        for gName in remainingGlyphs:
            if gName in f:
                f[gName].lib['com.typemytype.robofont.mark'] = grey

        if platform == 'CL':
            f.save()
            print 'sorted', f.path
开发者ID:,项目名称:,代码行数:31,代码来源:

示例9: test_glyph_name_change

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import keys [as 别名]
 def test_glyph_name_change(self):
     font = Font(getTestFontPath())
     glyph = font["A"]
     glyph.name = "NameChangeTest"
     self.assertEqual(sorted(font.keys()), ["B", "C", "NameChangeTest"])
     self.assertTrue(font.dirty)
开发者ID:anthrotype,项目名称:defcon,代码行数:8,代码来源:test_font.py

示例10: OrderedDict

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import keys [as 别名]
            lang = lang.strip(';')
            if script not in scripts:
                scripts[script] = []
            if lang not in scripts[script]:
                scripts[script].append(lang)
    return OrderedDict((script, tuple(langs)) for script,langs in scripts.items())


if __name__ == '__main__':
    from defcon import Font

    font = Font(path=sys.argv[2])
    for mergePath in sys.argv[3:]:
        merge = Font(path=mergePath)
        # merge glyphs
        for name in merge.keys():
            glyph = merge[name]
            # had an error related to anchors, but I don't need anchors here
            glyph.anchors = []
            font.insertGlyph(glyph, name=name)
        # merge groups
        font.groups.update(merge.groups)
        # merge kerning
        font.kerning.update(merge.kerning)



    # scripts = {'arab': ('dflt', 'ARA ', 'URD ', 'FAR '), 'latn': ('dflt', 'TRK ')}
    # scripts = scriptsFromFea(sys.argv[1])
    # scripts = {'arab': ('dflt', ), 'latn': ('dflt', )}
    scripts = {
开发者ID:Tarobish,项目名称:Mirza,代码行数:33,代码来源:kernFeatureWriter.py

示例11: ufoGlyphOrderSetter

# 需要导入模块: from defcon import Font [as 别名]
# 或者: from defcon.Font import keys [as 别名]
import sys, os
def ufoGlyphOrderSetter(existingOrder, newOrder):
    outOrder=[]
    for glyphName in newOrder:
        if glyphName not in existingOrder:
            outOrder.append(glyphName)
    return outOrder

arguments=sys.argv
fontList=arguments[2:]

print "Merging fonts..."
print os.getcwd()
new_ufo = Font()
new_ufo = Font(fontList[0])

for font in fontList[1:]:
    source= Font(font)
    if source.kerning._dataOnDisk is not None:
        pair_list=source.kerning.keys()
        for pair in pair_list:
            new_ufo.kerning[pair]=source.kerning[pair]
    glyph_name_list=ufoGlyphOrderSetter(new_ufo.keys(), source.keys())
    for glyph_name in glyph_name_list:
        glyph = source[glyph_name]
        print glyph_name,
        new_ufo._glyphSet._insertGlyph(glyph)

new_ufo.save(arguments[1])
print "\nMerge complete!"
开发者ID:solmatas,项目名称:gemunu-libre-font,代码行数:32,代码来源:merger.py


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