Ejemplo n.º 1
0
def interpolate(ufos, master_dir, out_dir, instance_data, debug=False):
    """Create MutatorMath designspace and generate instances.
    Returns instance UFOs, or unused instance data if debug is True.
    """
    from defcon import Font
    from mutatorMath.ufo import build

    designspace_path, instance_files = build_designspace(
        ufos, master_dir, out_dir, instance_data)

    print('>>> Building instances')
    for path, _ in instance_files:
        clean_ufo(path)
    build(designspace_path, outputUFOFormatVersion=3)

    instance_ufos = []
    for path, data in instance_files:
        ufo = Font(path)
        set_custom_params(ufo, data=data)
        set_redundant_data(ufo)
        ufo.save()
        instance_ufos.append(ufo)

    if debug:
        return clear_data(instance_data)
    return instance_ufos
Ejemplo n.º 2
0
def interpolate(rfonts, master_dir, out_dir, designspace_path,
                    instance_data, italic=False, debug=False):
    """Create MutatorMath designspace and generate instances.
    Returns instance UFOs, or unused instance data if debug is True.
    """

    print('>>> Writing masters')
    for font in rfonts:
        font.save(os.path.join(
            master_dir, font.info.postscriptFullName + '.ufo'))

    writer = DesignSpaceDocumentWriter(designspace_path)
    base_family = add_masters_to_writer(writer, rfonts)
    instance_files = add_instances_to_writer(
        writer, base_family, instance_data, italic, out_dir)
    writer.save()

    print('>>> Building instances')
    build(designspace_path)

    instance_ufos = []
    for path, data in instance_files:
        ufo = OpenFont(path)
        for attr in data:
            if attr.pop('name') == 'panose':
                ufo.info.openTypeOS2Panose = map(int, attr.pop('value'))
        set_redundant_data(ufo)
        instance_ufos.append(ufo)

    if debug:
        return clear_data(instance_data)
    return instance_ufos
Ejemplo n.º 3
0
def interpolate(ufos, master_dir, out_dir, instance_data, debug=False):
    """Create MutatorMath designspace and generate instances.
    Returns instance UFOs, or unused instance data if debug is True.
    """
    from defcon import Font
    from mutatorMath.ufo import build

    designspace_path, instance_files = build_designspace(
        ufos, master_dir, out_dir, instance_data)

    print('>>> Building instances')
    for path, _ in instance_files:
        clean_ufo(path)
    build(designspace_path, outputUFOFormatVersion=3)

    instance_ufos = []
    for path, data in instance_files:
        ufo = Font(path)
        set_custom_params(ufo, data=data)
        set_redundant_data(ufo)
        ufo.save()
        instance_ufos.append(ufo)

    if debug:
        return clear_data(instance_data)
    return instance_ufos
Ejemplo n.º 4
0
def interpolate(rfonts, master_dir, out_dir, designspace_path,
                instance_data, italic=False, debug=False):
    """Create MutatorMath designspace and generate instances.
    Returns instance UFOs, or unused instance data if debug is True.
    """

    print('>>> Writing masters')
    for font in rfonts:
        font.save(os.path.join(
            master_dir, build_postscript_name(
                font.info.familyName, font.info.styleName) + '.ufo'))

    writer = DesignSpaceDocumentWriter(designspace_path)
    base_family = add_masters_to_writer(writer, rfonts)
    instance_files = add_instances_to_writer(
        writer, base_family, instance_data, italic, out_dir)
    writer.save()

    print('>>> Building instances')
    build(designspace_path)

    instance_ufos = []
    for path, data in instance_files:
        ufo = OpenFont(path)
        set_custom_params(ufo, data=data)
        set_redundant_data(ufo)
        ufo.save()
        instance_ufos.append(ufo)

    if debug:
        return clear_data(instance_data)
    return instance_ufos
Ejemplo n.º 5
0
def interpolate(ufos, master_dir, out_dir, instance_data, debug=False):
    """Create MutatorMath designspace and generate instances.
    Returns instance UFOs, or unused instance data if debug is True.
    """
    from mutatorMath.ufo import build

    designspace_path, instance_files = build_designspace(
        ufos, master_dir, out_dir, instance_data)

    print('>>> Building instances')
    for path, _ in instance_files:
        clean_ufo(path)
    build(designspace_path, outputUFOFormatVersion=3)

    instance_ufos = apply_instance_data(instance_files)
    if debug:
        return clear_data(instance_data)
    return instance_ufos
Ejemplo n.º 6
0
def interpolate(ufos, master_dir, out_dir, instance_data, debug=False):
    """Create MutatorMath designspace and generate instances.
    Returns instance UFOs, or unused instance data if debug is True.
    """
    from mutatorMath.ufo import build

    designspace_path, instance_files = build_designspace(
        ufos, master_dir, out_dir, instance_data)

    logger.info('Building instances')
    for path, _ in instance_files:
        clean_ufo(path)
    build(designspace_path, outputUFOFormatVersion=3)

    instance_ufos = apply_instance_data(instance_files)
    if debug:
        return clear_data(instance_data)
    return instance_ufos
Ejemplo n.º 7
0
def interpolate(ufos, master_dir, out_dir, instance_data, round_geometry=True):
    """Create MutatorMath designspace and generate instances.
    Returns instance UFOs.
    """
    from mutatorMath.ufo import build

    designspace_path, instance_files = build_designspace(
        ufos, master_dir, out_dir, instance_data)

    logger.info('Building instances')
    for path, _ in instance_files:
        clean_ufo(path)
    build(designspace_path,
          outputUFOFormatVersion=3,
          roundGeometry=round_geometry)

    instance_ufos = apply_instance_data(instance_files)
    return instance_ufos
Ejemplo n.º 8
0
def main():
    parser = argparse.ArgumentParser(description="Build Reem Kufi fonts.")
    parser.add_argument("file", metavar="FILE", help="input font to process")
    parser.add_argument("--out-file",
                        metavar="FILE",
                        help="output font to write",
                        required=True)

    args = parser.parse_args()

    with TemporaryDirectory() as tempdir:
        ufos, designspace = build_masters(args.file, tempdir, tempdir)

        doc = DesignSpaceDocument()
        doc.read(designspace)
        doc.instances = [i for i in doc.instances if i.styleName == "Regular"]
        assert len(doc.instances) == 1
        instance = doc.instances[0]
        instance.location = dict(Weight=108)
        instance.path = args.out_file
        doc.write(designspace)

        build(designspace, outputUFOFormatVersion=3)
Ejemplo n.º 9
0
# -*- coding: utf-8 -*-

""" 

	Example of a build script for a specific mutatorMath project.
	A script like this could live near the designspace description.
	It could be called to build a bunch of instances without opening any application. 

"""
from mutatorMath.ufo import build
import os
here = os.path.join(os.getcwd(), 'data')
build(here, outputUFOFormatVersion=2)
print('done')
  
Ejemplo n.º 10
0
# -*- coding: utf-8 -*-
""" 

	Example of a build script for a specific mutatorMath project.
	A script like this could live near the designspace description.
	It could be called to build a bunch of instances without opening any application. 

"""
from mutatorMath.ufo import build
import os
here = os.path.join(os.getcwd(), 'data')
build(here, outputUFOFormatVersion=2)
print('done')