def apply_instance_data(designspace, include_filenames=None, Font=defcon.Font):
from fontTools.designspaceLib import DesignSpaceDocument<EOL>from os.path import normcase, normpath<EOL>if hasattr(designspace, "<STR_LIT>"):<EOL><INDENT>designspace = designspace.__fspath__()<EOL><DEDENT>if isinstance(designspace, basestring):<EOL><INDENT>designspace = DesignSpaceDocument.fromfile(designspace)<EOL><DEDENT>basedir = os.path.dirname(designspace.path)<EOL>instance_ufos = []<EOL>if include_filenames is not None:<EOL><INDENT>include_filenames = {normcase(normpath(p)) for p in include_filenames}<EOL><DEDENT>for designspace_instance in designspace.instances:<EOL><INDENT>fname = designspace_instance.filename<EOL>assert fname is not None, "<STR_LIT>" % getattr(<EOL>designspace_instance, "<STR_LIT:name>", designspace_instance<EOL>)<EOL>if include_filenames is not None:<EOL><INDENT>fname = normcase(normpath(fname))<EOL>if fname not in include_filenames:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>logger.debug("<STR_LIT>", fname)<EOL>ufo = Font(normpath(os.path.join(basedir, fname)))<EOL>set_weight_class(ufo, designspace, designspace_instance)<EOL>set_width_class(ufo, designspace, designspace_instance)<EOL>glyphs_instance = InstanceDescriptorAsGSInstance(designspace_instance)<EOL>to_ufo_custom_params(None, ufo, glyphs_instance)<EOL>ufo.save()<EOL>instance_ufos.append(ufo)<EOL><DEDENT>return instance_ufos<EOL>
Open UFO instances referenced by designspace, apply Glyphs instance
    data if present, re-save UFOs and return updated UFO Font objects.

    Args:
        designspace: DesignSpaceDocument object or path (str or PathLike) to
            a designspace file.
        include_filenames: optional set of instance filenames (relative to
            the designspace path) to be included. By default all instaces are
            processed.
        Font: the class used to load the UFO (default: defcon.Font).
    Returns:
        List of opened and updated instance UFOs.