コード例 #1
0
def run_all_glif_validations(ufoobj):
    glyphsdir_path_list = ufoobj.get_glyphsdir_path_list()
    ufoversion = ufoobj.get_ufo_version()
    ss = StdStreamer(ufoobj.ufopath)
    test_error_list = []
    for (
        glyphsdir
    ) in glyphsdir_path_list:  # for each directory that containts .glif files
        print(" ")
        sys.stdout.write(" - " + glyphsdir + "  ")
        sys.stdout.flush()
        res = Result(glyphsdir)
        try:
            gs = GlyphSet(
                glyphsdir, ufoFormatVersion=ufoversion, validateRead=True
            )  # create a ufoLib GlyphSet
            # do not report success for this, previous testing has passed this
        except Exception as e:
            res.test_failed = True
            res.test_long_stdstream_string = (
                " Failed to read glif file paths from "
                + glyphsdir
                + ". Error: "
                + str(e)
            )
            ss.stream_result(res)
            test_error_list.append(res)
            break  # break out loop as it was not possible to read the GlyphSet for this directory, gs not instantiated

        glif_count = 0  # reset glyphs directory .glif file counter
        for (
            glyphname
        ) in (
            gs.contents.keys()
        ):  # for each .glif file (read from glyph name in glyph set contents dict)
            res = Result(gs.contents[glyphname])
            try:
                go = GlifObj()
                gs.readGlyph(
                    glyphname, glyphObject=go
                )  # read the glif file and perform ufoLib validations, requires the glyphObject for validations
                res.test_failed = False
                ss.stream_result(res)
                glif_count += 1
            except Exception as e:
                res.test_failed = True
                filename = os.path.join(glyphsdir, glyphNameToFileName(glyphname, None))
                res.test_long_stdstream_string = '{} (glyph "{}"): Test failed with error: {}'.format(
                    filename, glyphname, e
                )
                ss.stream_result(res)
                test_error_list.append(res)
                glif_count += 1
        print("   " + str(glif_count) + " .glif tests completed")
    return test_error_list
コード例 #2
0
ファイル: glifLib_test.py プロジェクト: verbosus/fonttools
 def test_default_file_name_scheme(self):
     assert glyphNameToFileName("a", None) == "a.glif"
     assert glyphNameToFileName("A", None) == "A_.glif"
     assert glyphNameToFileName("Aring", None) == "A_ring.glif"
     assert glyphNameToFileName("F_A_B", None) == "F__A__B_.glif"
     assert glyphNameToFileName("A.alt", None) == "A_.alt.glif"
     assert glyphNameToFileName("A.Alt", None) == "A_.A_lt.glif"
     assert glyphNameToFileName(".notdef", None) == "_notdef.glif"
     assert glyphNameToFileName("T_H", None) == "T__H_.glif"
     assert glyphNameToFileName("T_h", None) == "T__h.glif"
     assert glyphNameToFileName("t_h", None) == "t_h.glif"
     assert glyphNameToFileName("F_F_I", None) == "F__F__I_.glif"
     assert glyphNameToFileName("f_f_i", None) == "f_f_i.glif"
     assert glyphNameToFileName("AE", None) == "A_E_.glif"
     assert glyphNameToFileName("Ae", None) == "A_e.glif"
     assert glyphNameToFileName("ae", None) == "ae.glif"
     assert glyphNameToFileName("aE", None) == "aE_.glif"
     assert glyphNameToFileName("a.alt", None) == "a.alt.glif"
     assert glyphNameToFileName("A.aLt", None) == "A_.aL_t.glif"
     assert glyphNameToFileName("A.alT", None) == "A_.alT_.glif"
     assert glyphNameToFileName("Aacute_V.swash",
                                None) == "A_acute_V_.swash.glif"
     assert glyphNameToFileName(".notdef", None) == "_notdef.glif"
     assert glyphNameToFileName("con", None) == "_con.glif"
     assert glyphNameToFileName("CON", None) == "C_O_N_.glif"
     assert glyphNameToFileName("con.alt", None) == "_con.alt.glif"
     assert glyphNameToFileName("alt.con", None) == "alt._con.glif"
コード例 #3
0
ファイル: glifLib_test.py プロジェクト: verbosus/fonttools
 def myGlyphNameToFileName(glyphName, glyphSet):
     return "prefix" + glyphNameToFileName(glyphName, glyphSet)
コード例 #4
0
ファイル: glifLib_test.py プロジェクト: typoman/fonttools
 def testDefaultFileNameScheme(self):
     self.assertEqual(glyphNameToFileName("a", None), "a.glif")
     self.assertEqual(glyphNameToFileName("A", None), "A_.glif")
     self.assertEqual(glyphNameToFileName("Aring", None), "A_ring.glif")
     self.assertEqual(glyphNameToFileName("F_A_B", None), "F__A__B_.glif")
     self.assertEqual(glyphNameToFileName("A.alt", None), "A_.alt.glif")
     self.assertEqual(glyphNameToFileName("A.Alt", None), "A_.A_lt.glif")
     self.assertEqual(glyphNameToFileName(".notdef", None), "_notdef.glif")
     self.assertEqual(glyphNameToFileName("T_H", None), "T__H_.glif")
     self.assertEqual(glyphNameToFileName("T_h", None), "T__h.glif")
     self.assertEqual(glyphNameToFileName("t_h", None), "t_h.glif")
     self.assertEqual(glyphNameToFileName("F_F_I", None), "F__F__I_.glif")
     self.assertEqual(glyphNameToFileName("f_f_i", None), "f_f_i.glif")
     self.assertEqual(glyphNameToFileName("AE", None), "A_E_.glif")
     self.assertEqual(glyphNameToFileName("Ae", None), "A_e.glif")
     self.assertEqual(glyphNameToFileName("ae", None), "ae.glif")
     self.assertEqual(glyphNameToFileName("aE", None), "aE_.glif")
     self.assertEqual(glyphNameToFileName("a.alt", None), "a.alt.glif")
     self.assertEqual(glyphNameToFileName("A.aLt", None), "A_.aL_t.glif")
     self.assertEqual(glyphNameToFileName("A.alT", None), "A_.alT_.glif")
     self.assertEqual(glyphNameToFileName("Aacute_V.swash", None),
                      "A_acute_V_.swash.glif")
     self.assertEqual(glyphNameToFileName(".notdef", None), "_notdef.glif")
     self.assertEqual(glyphNameToFileName("con", None), "_con.glif")
     self.assertEqual(glyphNameToFileName("CON", None), "C_O_N_.glif")
     self.assertEqual(glyphNameToFileName("con.alt", None), "_con.alt.glif")
     self.assertEqual(glyphNameToFileName("alt.con", None), "alt._con.glif")