How to use the ufo2ft.compileOTF function in ufo2ft

To help you get started, we’ve selected a few ufo2ft examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googlefonts / fontmake / Lib / fontmake / font_project.py View on Github external
def _iter_compile(self, ufos, ttf=False, debugFeatureFile=None, **kwargs):
        # generator function that calls ufo2ft compiler for each ufo and
        # yields ttFont instances
        options = dict(kwargs)
        if ttf:
            for key in ("optimizeCFF", "roundTolerance"):
                options.pop(key, None)
            compile_func, fmt = ufo2ft.compileTTF, "TTF"
        else:
            for key in ("cubicConversionError", "reverseDirection"):
                options.pop(key, None)
            compile_func, fmt = ufo2ft.compileOTF, "OTF"

        writeFontName = len(ufos) > 1
        for ufo in ufos:
            name = self._font_name(ufo)
            logger.info(f"Building {fmt} for {name}")

            if debugFeatureFile and writeFontName:
                debugFeatureFile.write(f"\n### {name} ###\n")

            yield compile_func(ufo, debugFeatureFile=debugFeatureFile, **options)
github irori / wapuro-mincho / converter / convert.py View on Github external
def compile(ufo, out_filename):
    ext = os.path.splitext(out_filename)[1]
    if ext == '.ufo':
        return ufo

    otf = None
    if ext == '.ttf':
        otf = compileTTF(ufo)
    elif ext == '.otf':
        otf = compileOTF(ufo)
    elif ext == '.woff':
        otf = compileOTF(ufo, optimizeCFF=False)
        otf.flavor = 'woff'
    elif ext == '.woff2':
        otf = compileOTF(ufo, optimizeCFF=False)
        otf.flavor = 'woff2'
    else:
        raise RuntimeError('Unknown output file type: %s' % ext)

    return otf
github irori / wapuro-mincho / converter / convert.py View on Github external
def compile(ufo, out_filename):
    ext = os.path.splitext(out_filename)[1]
    if ext == '.ufo':
        return ufo

    otf = None
    if ext == '.ttf':
        otf = compileTTF(ufo)
    elif ext == '.otf':
        otf = compileOTF(ufo)
    elif ext == '.woff':
        otf = compileOTF(ufo, optimizeCFF=False)
        otf.flavor = 'woff'
    elif ext == '.woff2':
        otf = compileOTF(ufo, optimizeCFF=False)
        otf.flavor = 'woff2'
    else:
        raise RuntimeError('Unknown output file type: %s' % ext)

    return otf
github google / roboto / scripts / lib / fontbuild / Build.py View on Github external
def saveOTF(font, destFile, glyphOrder, truetype=False):
    """Save a RoboFab font as an OTF binary using ufo2fdk."""

    if truetype:
        otf = compileTTF(font, featureCompilerClass=RobotoFeatureCompiler,
                   kernWriter=RobotoKernWriter, glyphOrder=glyphOrder,
                   convertCubics=False,
                   useProductionNames=False)
    else:
        otf = compileOTF(font, featureCompilerClass=RobotoFeatureCompiler,
                   kernWriter=RobotoKernWriter, glyphOrder=glyphOrder,
                   useProductionNames=False)
    otf.save(destFile)
github fadox / fontamental / Lib / fontamental / maxify.py View on Github external
config = "./config.ini"
    output = "./build_font.otf"
    parser = argparse.ArgumentParser(prog='maxify')
    parser.add_argument('source', metavar='"Source Font"', type=str,  help='Source File, only UFO format supported')
    parser.add_argument('-c', nargs='?', help='user configuration file path')
    parser.add_argument('-o', nargs='?', help='output file')
    args = parser.parse_args()
    if args.o is not None:
        output = args.o
    source_file = args.source
    if args.c is not None:
        config = args.c
    maxi = MaxifyUFO(source_file, config)
    ufo = maxi.build()
    if ufo is not None:
        otf = compileOTF(ufo, useProductionNames=False)
        if otf is not None:
            # save generated font to file
            otf.save(output)
            print("The Font (" + output + ") created successfully !")
github sugarlabs / edit-fonts-activity / editfonts / core / basefont.py View on Github external
def export_binary(self, path):
        """Export the font as a .otf file."""
        # converting the font to a OTF
        # The current implementation fails if optimizeCff is set to True
        # FIXME: Find a better solution for exporting the font
        # probably use fontmake to validate the data being saved
        from ufo2ft import compileOTF
        otf = compileOTF(self, optimizeCff=False)

        # save the otf
        otf.save(path)
github irori / wapuro-mincho / converter / convert.py View on Github external
def compile(ufo, out_filename):
    ext = os.path.splitext(out_filename)[1]
    if ext == '.ufo':
        return ufo

    otf = None
    if ext == '.ttf':
        otf = compileTTF(ufo)
    elif ext == '.otf':
        otf = compileOTF(ufo)
    elif ext == '.woff':
        otf = compileOTF(ufo, optimizeCFF=False)
        otf.flavor = 'woff'
    elif ext == '.woff2':
        otf = compileOTF(ufo, optimizeCFF=False)
        otf.flavor = 'woff2'
    else:
        raise RuntimeError('Unknown output file type: %s' % ext)

    return otf
github alif-type / libertinus / tools / build.py View on Github external
def generate(self, output):
        self._update_metadata()
        self._make_over_under_line()
        otf = ufo2ft.compileOTF(self._font, inplace=True, optimizeCFF=0,
            removeOverlaps=True, overlapsBackend="pathops", featureWriters=[])
        self._post_process(otf)
        self._prune(otf)
        otf.save(output)