コード例 #1
0
ファイル: mti_test.py プロジェクト: peterennis/fonttools
        font2 = TTFont()
        font2.setGlyphOrder(font.getGlyphOrder())
        reader = xmlReader.XMLReader(f, font2)
        reader.read(rootless=True)

        # XML from object read from XML.
        writer = XMLWriter(StringIO())
        writer.begintag(tableTag); writer.newline()
        font2[tableTag].toXML(writer, font)
        writer.endtag(tableTag); writer.newline()
        xml_fromxml = writer.file.getvalue()

        self.expect_ttx(xml_expected, xml_fromxml, fromfile=xml_expected_path, tofile='fromxml')

def generate_mti_file_test(name, tableTag=None):
    return lambda self: self.check_mti_file(os.path.join(*name.split('/')), tableTag=tableTag)


for tableTag,tests in MtiTest.TESTS.items():
    for name in tests:
        setattr(MtiTest, "test_MtiFile_%s%s" % (name, '_'+tableTag if tableTag else ''),
                generate_mti_file_test(name, tableTag=tableTag))


if __name__ == "__main__":
    if len(sys.argv) > 1:
        from fontTools.mtiLib import main
        font = MtiTest.create_font()
        sys.exit(main(sys.argv[1:], font))
    sys.exit(unittest.main())
コード例 #2
0
from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
import sys
from fontTools.mtiLib import main

if __name__ == '__main__':
	sys.exit(main())
コード例 #3
0
        font2 = TTFont()
        font2.setGlyphOrder(font.getGlyphOrder())
        reader = xmlReader.XMLReader(f, font2)
        reader.read(rootless=True)

        # XML from object read from XML.
        writer = XMLWriter(StringIO(), newlinestr='\n')
        writer.begintag(tableTag); writer.newline()
        font2[tableTag].toXML(writer, font)
        writer.endtag(tableTag); writer.newline()
        xml_fromxml = writer.file.getvalue()

        self.expect_ttx(xml_expected, xml_fromxml, fromfile=xml_expected_path, tofile='fromxml')

def generate_mti_file_test(name, tableTag=None):
    return lambda self: self.check_mti_file(os.path.join(*name.split('/')), tableTag=tableTag)


for tableTag,tests in MtiTest.TESTS.items():
    for name in tests:
        setattr(MtiTest, "test_MtiFile_%s%s" % (name, '_'+tableTag if tableTag else ''),
                generate_mti_file_test(name, tableTag=tableTag))


if __name__ == "__main__":
    if len(sys.argv) > 1:
        from fontTools.mtiLib import main
        font = MtiTest.create_font()
        sys.exit(main(sys.argv[1:], font))
    sys.exit(unittest.main())