Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from fontTools.pens.ttGlyphPen import TTGlyphPen
pen = TTGlyphPen(None)
path.draw(pen)
ttGlyphs[name] = pen.glyph()
else:
from fontTools.pens.t2CharStringPen import T2CharStringPen
charString = charStrings[name]
pen = T2CharStringPen(None, None, CFF2=CFF2)
path.draw(pen)
charStrings[name] = pen.getCharString(charString.private)
if not CFF2:
charStrings[name].program.insert(0, charString.width)
if charStrings is not None:
from cffsubr import subroutinize
subroutinize(font, cff_version=1)
def _subroutinize_with_cffsubr(cls, otf, cffVersion):
import cffsubr
cffInputVersion = cls._get_cff_version(otf)
assert cffInputVersion is not None, "Missing required 'CFF ' or 'CFF2' table"
msg = f"Subroutinizing {cffInputVersion.name} table with cffsubr"
if cffInputVersion != cffVersion:
msg += f" (output format: {cffVersion.name})"
logger.info(msg)
return cffsubr.subroutinize(otf, cff_version=cffVersion, keep_glyph_names=False)
charStrings = font["CFF "].cff.topDictIndex[0].CharStrings
for name in names:
glyph = glyphs[name]
path = Path()
glyph.draw(path.getPen())
path.simplify(fix_winding=True, keep_starting_points=True)
if charStrings is not None:
charString = charStrings[name]
pen = T2CharStringPen(None, None, CFF2=CFF2)
path.draw(pen)
charStrings[name] = pen.getCharString(charString.private)
if not CFF2:
charStrings[name].program.insert(0, charString.width)
if charStrings is not None:
subroutinize(font, cff_version=1)
font["post"].formatType = 3.0
font.save(options.output)