adds --cufo flag to ufocompile for compiling UFO files instead of OTF and TTF files
This commit is contained in:
parent
50ca3807f7
commit
8c1a4c181e
2 changed files with 36 additions and 22 deletions
|
|
@ -72,6 +72,7 @@ class FontProject:
|
||||||
self.buildOTF = False
|
self.buildOTF = False
|
||||||
self.compatible = False
|
self.compatible = False
|
||||||
self.generatedFonts = []
|
self.generatedFonts = []
|
||||||
|
self.justCompileUFO = False
|
||||||
|
|
||||||
def openResource(self, name):
|
def openResource(self, name):
|
||||||
with open(os.path.join(
|
with open(os.path.join(
|
||||||
|
|
@ -98,7 +99,8 @@ class FontProject:
|
||||||
f = mix.generateFont(self.basefont, self.deleteList)
|
f = mix.generateFont(self.basefont, self.deleteList)
|
||||||
else:
|
else:
|
||||||
f = mix.copy()
|
f = mix.copy()
|
||||||
deleteGlyphs(f, self.deleteList)
|
if not self.justCompileUFO:
|
||||||
|
deleteGlyphs(f, self.deleteList)
|
||||||
|
|
||||||
if italic == True:
|
if italic == True:
|
||||||
log(">> Italicizing")
|
log(">> Italicizing")
|
||||||
|
|
@ -137,12 +139,13 @@ class FontProject:
|
||||||
if len(g.components) > 0:
|
if len(g.components) > 0:
|
||||||
self.predecompose.add(g.name)
|
self.predecompose.add(g.name)
|
||||||
|
|
||||||
for gname in self.predecompose:
|
if not self.justCompileUFO:
|
||||||
if f.has_key(gname):
|
for gname in self.predecompose:
|
||||||
decomposeGlyph(f, f[gname])
|
if f.has_key(gname):
|
||||||
|
decomposeGlyph(f, f[gname])
|
||||||
|
|
||||||
log(">> Generating glyphs")
|
log(">> Generating glyphs")
|
||||||
generateGlyphs(f, self.diacriticList, self.adobeGlyphList)
|
self.generateGlyphs(f, self.diacriticList, self.adobeGlyphList)
|
||||||
# log(">> Reading features")
|
# log(">> Reading features")
|
||||||
# readFeatureFile(f, f.features.text)
|
# readFeatureFile(f, f.features.text)
|
||||||
|
|
||||||
|
|
@ -163,13 +166,14 @@ class FontProject:
|
||||||
g.leftMargin = newLeftMargin
|
g.leftMargin = newLeftMargin
|
||||||
g.rightMargin = newRightMargin
|
g.rightMargin = newRightMargin
|
||||||
|
|
||||||
log(">> Decomposing")
|
if not self.justCompileUFO:
|
||||||
# for g in f:
|
log(">> Decomposing")
|
||||||
# if len(g.components) > 0:
|
# for g in f:
|
||||||
# decomposeGlyph(f, g)
|
# if len(g.components) > 0:
|
||||||
for gname in self.decompose:
|
# decomposeGlyph(f, g)
|
||||||
if f.has_key(gname):
|
for gname in self.decompose:
|
||||||
decomposeGlyph(f, f[gname])
|
if f.has_key(gname):
|
||||||
|
decomposeGlyph(f, f[gname])
|
||||||
|
|
||||||
copyrightHolderName = ''
|
copyrightHolderName = ''
|
||||||
if self.config.has_option('main', 'copyrightHolderName'):
|
if self.config.has_option('main', 'copyrightHolderName'):
|
||||||
|
|
@ -193,7 +197,8 @@ class FontProject:
|
||||||
'italicAngle': float(getcfg('italicAngle', '-12')),
|
'italicAngle': float(getcfg('italicAngle', '-12')),
|
||||||
}, panose)
|
}, panose)
|
||||||
|
|
||||||
if not self.compatible:
|
if not self.compatible and not self.justCompileUFO:
|
||||||
|
# Remove overlaps etc
|
||||||
cleanCurves(f)
|
cleanCurves(f)
|
||||||
# deleteGlyphs(f, self.deleteList)
|
# deleteGlyphs(f, self.deleteList)
|
||||||
|
|
||||||
|
|
@ -202,6 +207,10 @@ class FontProject:
|
||||||
f.save(ufoName)
|
f.save(ufoName)
|
||||||
self.generatedFonts.append(ufoName)
|
self.generatedFonts.append(ufoName)
|
||||||
|
|
||||||
|
if self.justCompileUFO:
|
||||||
|
print("wrote %s" % ufoName)
|
||||||
|
return
|
||||||
|
|
||||||
# filter glyphorder -- only include glyphs that exists in font
|
# filter glyphorder -- only include glyphs that exists in font
|
||||||
glyphOrder = []
|
glyphOrder = []
|
||||||
seenGlyphNames = set()
|
seenGlyphNames = set()
|
||||||
|
|
@ -242,6 +251,12 @@ class FontProject:
|
||||||
glyphOrder = [n for n in self.glyphOrder if n in font]
|
glyphOrder = [n for n in self.glyphOrder if n in font]
|
||||||
saveOTF(font, ttfName, glyphOrder, truetype=True)
|
saveOTF(font, ttfName, glyphOrder, truetype=True)
|
||||||
|
|
||||||
|
def generateGlyphs(self, f, glyphNames, glyphList={}):
|
||||||
|
log(">> Generating diacritics")
|
||||||
|
glyphnames = [gname for gname in glyphNames if not gname.startswith("#") and gname != ""]
|
||||||
|
for glyphName in glyphNames:
|
||||||
|
generateGlyph(f, glyphName, glyphList)
|
||||||
|
|
||||||
|
|
||||||
# def transformGlyphMembers(g, m):
|
# def transformGlyphMembers(g, m):
|
||||||
# g.width = int(g.width * m.a)
|
# g.width = int(g.width * m.a)
|
||||||
|
|
@ -290,14 +305,6 @@ def log(msg):
|
||||||
print msg
|
print msg
|
||||||
|
|
||||||
|
|
||||||
def generateGlyphs(f, glyphNames, glyphList={}):
|
|
||||||
log(">> Generating diacritics")
|
|
||||||
glyphnames = [gname for gname in glyphNames if not gname.startswith("#") and gname != ""]
|
|
||||||
|
|
||||||
for glyphName in glyphNames:
|
|
||||||
generateGlyph(f, glyphName, glyphList)
|
|
||||||
|
|
||||||
|
|
||||||
def deleteGlyphs(f, deleteList):
|
def deleteGlyphs(f, deleteList):
|
||||||
for name in deleteList:
|
for name in deleteList:
|
||||||
if f.has_key(name):
|
if f.has_key(name):
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,10 @@ def main():
|
||||||
'--no-ttf', dest='no_ttf', action='store_const',
|
'--no-ttf', dest='no_ttf', action='store_const',
|
||||||
const=True, default=False, help='Do not build TTF files')
|
const=True, default=False, help='Do not build TTF files')
|
||||||
|
|
||||||
|
argparser.add_argument(
|
||||||
|
'--cufo', dest='cufo', action='store_const',
|
||||||
|
const=True, default=False, help='Only compile composite UFO')
|
||||||
|
|
||||||
argparser.add_argument(
|
argparser.add_argument(
|
||||||
'--out', dest='out', metavar='<dir>', type=str, default=default_out_dir,
|
'--out', dest='out', metavar='<dir>', type=str, default=default_out_dir,
|
||||||
help='Write output to <dir> instead of the default (%r)' % default_out_dir)
|
help='Write output to <dir> instead of the default (%r)' % default_out_dir)
|
||||||
|
|
@ -137,6 +141,9 @@ def main():
|
||||||
rg.font, BASEDIR, os.path.join(srcDir,'fontbuild.cfg'), buildTag=buildTag)
|
rg.font, BASEDIR, os.path.join(srcDir,'fontbuild.cfg'), buildTag=buildTag)
|
||||||
proj.builddir = args.out
|
proj.builddir = args.out
|
||||||
|
|
||||||
|
if args.cufo:
|
||||||
|
proj.justCompileUFO = True
|
||||||
|
|
||||||
# panose for entire family
|
# panose for entire family
|
||||||
panose = {
|
panose = {
|
||||||
'bFamilyType': 2, # Latin Text
|
'bFamilyType': 2, # Latin Text
|
||||||
|
|
@ -225,7 +232,7 @@ def main():
|
||||||
panose=mkpanose(9))
|
panose=mkpanose(9))
|
||||||
|
|
||||||
# generate TTFs
|
# generate TTFs
|
||||||
if args.no_ttf == False:
|
if args.no_ttf == False and args.cufo == False:
|
||||||
proj.generateTTFs()
|
proj.generateTTFs()
|
||||||
|
|
||||||
if not ALL:
|
if not ALL:
|
||||||
|
|
|
||||||
Reference in a new issue