def read(cls, name: str, glyphSet: GlyphSet, lazy: bool = True, default: bool = False) -> Layer: """Instantiates a Layer object from a :class:`fontTools.ufoLib.glifLib.GlyphSet`. Args: name: The name of the layer. glyphSet: The GlyphSet object to read from. lazy: If True, load glyphs as they are accessed. If False, load everything up front. """ glyphNames = glyphSet.keys() glyphs: dict[str, Glyph] if lazy: glyphs = {gn: _GLYPH_NOT_LOADED for gn in glyphNames} else: glyphs = {} for glyphName in glyphNames: glyph = Glyph(glyphName) glyphSet.readGlyph(glyphName, glyph, glyph.getPointPen()) glyphs[glyphName] = glyph self = cls(name, glyphs, default=default) if lazy: self._glyphSet = glyphSet glyphSet.readLayerInfo(self) return self
def run_ufolib_import_validation(self): """ ufoLib GlyphSet.readLayerInfo method performs validations of layerinfo.plist file(s) :return: (list) list of test failure Result objects """ ss = StdStreamer(self.ufopath) for glyphs_dir in self.ufoobj.glyphsdir_list: res = Result(glyphs_dir[1]) rel_dir_path = os.path.join(self.ufopath, glyphs_dir[1]) try: gs = GlyphSet( rel_dir_path, ufoFormatVersion=self.ufoversion, validateRead=True ) gs.readLayerInfo(self.layerinfo_obj) res.test_failed = False ss.stream_result(res) except Exception as e: res.test_failed = True res.test_long_stdstream_string = ( "layerinfo.plist in " + rel_dir_path + " failed ufoLib import test with error: " + str(e) ) self.test_fail_list.append(res) ss.stream_result(res) return self.test_fail_list