Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def generateTTFs(self):
"""Build TTF for each font generated since last call to generateTTFs."""
fonts = [OpenFont(ufo) for ufo in self.generatedFonts]
self.generatedFonts = []
log(">> Converting curves to quadratic")
# using a slightly higher max error (e.g. 0.0025 em), dots will have
# fewer control points and look noticeably different
max_err = 0.002
if self.compatible:
fonts_to_quadratic(fonts, max_err_em=max_err, dump_stats=True, reverse_direction=True)
else:
for font in fonts:
fonts_to_quadratic([font], max_err_em=max_err, dump_stats=True, reverse_direction=True)
log(">> Generating TTF files")
for font in fonts:
ttfName = self.generateOutputPath(font, "ttf")
log(os.path.basename(ttfName))
saveOTF(
font, ttfName,
self.thinGlyphOrder if "Thin" in ttfName else self.glyphOrder,
truetype=True)
def generateTTFs(self):
"""Build TTF for each font generated since last call to generateTTFs."""
fonts = [OpenFont(ufo) for ufo in self.generatedFonts]
self.generatedFonts = []
log(">> Converting curves to quadratic")
# using a slightly higher max error (e.g. 0.0025 em), dots will have
# fewer control points and look noticeably different
max_err = 0.002
if self.compatible:
fonts_to_quadratic(fonts, max_err_em=max_err, dump_stats=True, reverse_direction=True)
else:
for font in fonts:
fonts_to_quadratic([font], max_err_em=max_err, dump_stats=True, reverse_direction=True)
log(">> Generating TTF files")
for font in fonts:
ttfName = self.generateOutputPath(font, "ttf")
log(os.path.basename(ttfName))
saveOTF(
font, ttfName,
self.thinGlyphOrder if "Thin" in ttfName else self.glyphOrder,
truetype=True)
def process(self):
from cu2qu.ufo import fonts_to_quadratic
# first apply all custom pre-filters
for funcs, ufo, glyphSet in zip(self.preFilters, self.ufos, self.glyphSets):
for func in funcs:
func(ufo, glyphSet)
fonts_to_quadratic(
self.glyphSets,
max_err=self._conversionErrors,
reverse_direction=self._reverseDirection,
dump_stats=True,
remember_curve_type=self._rememberCurveType and self.inplace,
)
decompose = DecomposeComponentsFilter(include=lambda g: len(g))
for ufo, glyphSet in zip(self.ufos, self.glyphSets):
decompose(ufo, glyphSet)
# finally apply all custom post-filters
for funcs, ufo, glyphSet in zip(self.postFilters, self.ufos, self.glyphSets):
for func in funcs:
func(ufo, glyphSet)