How to use the ufo2ft.compileTTF 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 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 trufont / trufont / Lib / trufont / objects / defcon.py View on Github external
def export(self, path, format="otf", compression=None, **kwargs):
        if format == "otf":
            func = compileOTF
        elif format == "ttf":
            func = compileTTF
        else:
            raise ValueError("unknown format: %s" % format)
        if compression is not None:
            invalid = compression - {"none", "woff", "woff2"}
            if invalid:
                raise ValueError(f"unknown compression format: {invalid}")
        # info attrs
        missingAttrs = []
        for attr in (
            "familyName",
            "styleName",
            "unitsPerEm",
            "ascender",
            "descender",
            "xHeight",
            "capHeight",
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 trufont / trufont / Lib / trufont / representationFactories / openTypeFactory.py View on Github external
def QuadraticTTFontFactory(font, useProductionNames=False):
    ttf = compileTTF(font, useProductionNames=useProductionNames)
    return ttf
github silnrsi / pysilfont / lib / silfont / ipython.py View on Github external
def loadFont(fname):
    if fname.lower().endswith(".ufo"):
        ufo = Font(fname)
        f = compileTTF(ufo)
    else:
        f = ttLib.TTFont(fname)
    return f