def build_designspace(masters, master_dir, out_dir, instance_data): """Just create MutatorMath designspace without generating instances. Returns the path of the resulting designspace document and a list of (instance_path, instance_data) tuples which map instance UFO filenames to Glyphs data for that instance. """ from mutatorMath.ufo.document import DesignSpaceDocumentWriter for font in masters: write_ufo(font, master_dir) # needed so that added masters and instances have correct relative paths tmp_path = os.path.join(master_dir, 'tmp.designspace') writer = DesignSpaceDocumentWriter(tmp_path) base_family, base_style = add_masters_to_writer(writer, masters) instance_files = add_instances_to_writer(writer, base_family, instance_data, out_dir) basename = '%s%s.designspace' % (base_family, ('-' + base_style) if base_style else '') writer.path = os.path.join(master_dir, basename.replace(' ', '')) writer.save() return writer.path, instance_files
def build_masters(filename, master_dir, designspace_instance_dir=None, family_name=None): """Write and return UFOs from the masters defined in a .glyphs file. Args: master_dir: Directory where masters are written. designspace_instance_dir: If provided, a designspace document will be written alongside the master UFOs though no instances will be built. family_name: If provided, the master UFOs will be given this name and only instances with this name will be included in the designspace. Returns: A list of master UFOs, and if designspace_instance_dir is provided, a path to a designspace and a list of (path, data) tuples with instance paths from the designspace and respective data from the Glyphs source. """ ufos, instance_data = load_to_ufos( filename, include_instances=True, family_name=family_name) if designspace_instance_dir is not None: designspace_path, instance_data = build_designspace( ufos, master_dir, designspace_instance_dir, instance_data) return ufos, designspace_path, instance_data else: for ufo in ufos: write_ufo(ufo, master_dir) return ufos
def build_masters(filename, master_dir, designspace_instance_dir=None, family_name=None): """Write and return UFOs from the masters defined in a .glyphs file. Args: master_dir: Directory where masters are written. designspace_instance_dir: If provided, a designspace document will be written alongside the master UFOs though no instances will be built. family_name: If provided, the master UFOs will be given this name and only instances with this name will be included in the designspace. Returns: A list of master UFOs, and if designspace_instance_dir is provided, a path to a designspace and a list of (path, data) tuples with instance paths from the designspace and respective data from the Glyphs source. """ ufos, instance_data = load_to_ufos(filename, include_instances=True, family_name=family_name) if designspace_instance_dir is not None: designspace_path, instance_data = build_designspace( ufos, master_dir, designspace_instance_dir, instance_data) return ufos, designspace_path, instance_data else: for ufo in ufos: write_ufo(ufo, master_dir) return ufos
def build_designspace(masters, master_dir, out_dir, instance_data): """Just create MutatorMath designspace without generating instances. Returns the path of the resulting designspace document and a list of (instance_path, instance_data) tuples which map instance UFO filenames to Glyphs data for that instance. """ from mutatorMath.ufo.document import DesignSpaceDocumentWriter for font in masters: write_ufo(font, master_dir) # needed so that added masters and instances have correct relative paths tmp_path = os.path.join(master_dir, 'tmp.designspace') writer = DesignSpaceDocumentWriter(tmp_path) base_family, base_style = add_masters_to_writer(writer, masters) instance_files = add_instances_to_writer( writer, base_family, instance_data, out_dir) basename = '%s%s.designspace' % ( base_family, ('-' + base_style) if base_style else '') writer.path = os.path.join(master_dir, basename.replace(' ', '')) writer.save() return writer.path, instance_files
def build_masters(filename, master_dir, designspace_instance_dir=None): """Write and return UFOs from the masters defined in a .glyphs file. If `designspace_instance_dir` is provided, a designspace document will be written alongside the master UFOs, though no instances will be built. """ ufos, instance_data = load_to_ufos(filename, include_instances=True) if designspace_instance_dir is not None: build_designspace(ufos, master_dir, designspace_instance_dir, instance_data) else: for ufo in ufos: write_ufo(ufo, master_dir) return ufos