def compileVariableTTF( designSpaceDoc, preProcessorClass=TTFInterpolatablePreProcessor, outlineCompilerClass=OutlineTTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, cubicConversionError=None, reverseDirection=True, excludeVariationTables=(), optimizeGvar=True, flattenComponents=False, inplace=False, debugFeatureFile=None, notdefGlyph=None, ): """Create FontTools TrueType variable font from the DesignSpaceDocument UFO sources with interpolatable outlines, using fontTools.varLib.build. *optimizeGvar*, if set to False, will not perform IUP optimization on the generated 'gvar' table. *excludeVariationTables* is a list of sfnt table tags (str) that is passed on to fontTools.varLib.build, to skip building some variation tables. The rest of the arguments works the same as in the other compile functions. Returns a new variable TTFont object. """ baseUfo = getDefaultMasterFont(designSpaceDoc) ttfDesignSpace = compileInterpolatableTTFsFromDS( designSpaceDoc, preProcessorClass=preProcessorClass, outlineCompilerClass=outlineCompilerClass, featureCompilerClass=featureCompilerClass, featureWriters=featureWriters, glyphOrder=glyphOrder, useProductionNames=False, # will rename glyphs after varfont is built cubicConversionError=cubicConversionError, reverseDirection=reverseDirection, flattenComponents=flattenComponents, inplace=inplace, debugFeatureFile=debugFeatureFile, notdefGlyph=notdefGlyph, ) logger.info("Building variable TTF font") varfont = varLib.build(ttfDesignSpace, exclude=excludeVariationTables, optimize=optimizeGvar)[0] postProcessor = PostProcessor(varfont, baseUfo) varfont = postProcessor.process(useProductionNames) return varfont
def compileVariableCFF2( designSpaceDoc, preProcessorClass=OTFPreProcessor, outlineCompilerClass=OutlineOTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, roundTolerance=None, excludeVariationTables=(), inplace=False, debugFeatureFile=None, ): """Create FontTools CFF2 variable font from the DesignSpaceDocument UFO sources with interpolatable outlines, using fontTools.varLib.build. *excludeVariationTables* is a list of sfnt table tags (str) that is passed on to fontTools.varLib.build, to skip building some variation tables. The rest of the arguments works the same as in the other compile functions. Returns a new variable TTFont object. """ baseUfo = getDefaultMasterFont(designSpaceDoc) otfDesignSpace = compileInterpolatableOTFsFromDS( designSpaceDoc, preProcessorClass=preProcessorClass, outlineCompilerClass=outlineCompilerClass, featureCompilerClass=featureCompilerClass, featureWriters=featureWriters, glyphOrder=glyphOrder, useProductionNames=False, # will rename glyphs after varfont is built roundTolerance=roundTolerance, inplace=inplace, debugFeatureFile=debugFeatureFile, ) logger.info("Building variable CFF2 font") varfont = varLib.build(otfDesignSpace, exclude=excludeVariationTables)[0] postProcessor = PostProcessor(varfont, baseUfo) varfont = postProcessor.process(useProductionNames) return varfont
def compileVariableCFF2( designSpaceDoc, preProcessorClass=OTFPreProcessor, outlineCompilerClass=OutlineOTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, roundTolerance=None, excludeVariationTables=(), inplace=False, debugFeatureFile=None, optimizeCFF=CFFOptimization.SPECIALIZE, notdefGlyph=None, ): """Create FontTools CFF2 variable font from the DesignSpaceDocument UFO sources with interpolatable outlines, using fontTools.varLib.build. *excludeVariationTables* is a list of sfnt table tags (str) that is passed on to fontTools.varLib.build, to skip building some variation tables. *optimizeCFF* (int) defines whether the CFF charstrings should be specialized and subroutinized. 1 (default) only enables the specialization; 2 (default) does both specialization and subroutinization. The value 0 is supposed to disable both optimizations, however it's currently unused, because fontTools has some issues generating a VF with non-specialized CFF2 charstrings: fonttools/fonttools#1979. NOTE: Subroutinization of variable CFF2 requires the "cffsubr" extra requirement. The rest of the arguments works the same as in the other compile functions. Returns a new variable TTFont object. """ baseUfo = getDefaultMasterFont(designSpaceDoc) otfDesignSpace = compileInterpolatableOTFsFromDS( designSpaceDoc, preProcessorClass=preProcessorClass, outlineCompilerClass=outlineCompilerClass, featureCompilerClass=featureCompilerClass, featureWriters=featureWriters, glyphOrder=glyphOrder, useProductionNames=False, # will rename glyphs after varfont is built roundTolerance=roundTolerance, inplace=inplace, debugFeatureFile=debugFeatureFile, notdefGlyph=notdefGlyph, ) logger.info("Building variable CFF2 font") optimizeCFF = CFFOptimization(optimizeCFF) varfont = varLib.build( otfDesignSpace, exclude=excludeVariationTables, # NOTE optimize=False won't change anything until this PR is merged # https://github.com/fonttools/fonttools/pull/1979 optimize=optimizeCFF >= CFFOptimization.SPECIALIZE, )[0] postProcessor = PostProcessor(varfont, baseUfo) varfont = postProcessor.process( useProductionNames, optimizeCFF=optimizeCFF >= CFFOptimization.SUBROUTINIZE, ) return varfont