Fixes to font metadata, including addition of some OS/2 panose information
This commit is contained in:
parent
96fb366982
commit
76f983adae
5 changed files with 69 additions and 28 deletions
|
|
@ -85,10 +85,10 @@ class FontProject:
|
||||||
return os.path.join(path, "%s-%s.%s" % (family, style, ext))
|
return os.path.join(path, "%s-%s.%s" % (family, style, ext))
|
||||||
|
|
||||||
def generateFont(self, mix, names, italic=False, swapSuffixes=None, stemWidth=185,
|
def generateFont(self, mix, names, italic=False, swapSuffixes=None, stemWidth=185,
|
||||||
italicMeanYCenter=-825, italicNarrowAmount=1):
|
italicMeanYCenter=-825, italicNarrowAmount=1, panose=[]):
|
||||||
|
|
||||||
n = names.split("/")
|
n = names.split("/")
|
||||||
log("---------------------\n%s %s\n----------------------" %(n[0],n[1]))
|
log("---------------------\n%s, %s\n----------------------" %(n[0],n[1]))
|
||||||
|
|
||||||
if isinstance( mix, Mix):
|
if isinstance( mix, Mix):
|
||||||
log(">> Mixing masters")
|
log(">> Mixing masters")
|
||||||
|
|
@ -164,7 +164,7 @@ class FontProject:
|
||||||
'license': getcfg('license'),
|
'license': getcfg('license'),
|
||||||
'licenseURL': getcfg('licenseURL'),
|
'licenseURL': getcfg('licenseURL'),
|
||||||
'italicAngle': float(getcfg('italicAngle', '-12')),
|
'italicAngle': float(getcfg('italicAngle', '-12')),
|
||||||
})
|
}, panose)
|
||||||
|
|
||||||
if not self.compatible:
|
if not self.compatible:
|
||||||
cleanCurves(f)
|
cleanCurves(f)
|
||||||
|
|
@ -187,9 +187,9 @@ class FontProject:
|
||||||
glyphOrder.append(glyphName)
|
glyphOrder.append(glyphName)
|
||||||
|
|
||||||
if self.buildOTF:
|
if self.buildOTF:
|
||||||
log(">> Generating OTF file")
|
|
||||||
newFont = OpenFont(ufoName)
|
newFont = OpenFont(ufoName)
|
||||||
otfName = self.generateOutputPath(f, "otf")
|
otfName = self.generateOutputPath(f, "otf")
|
||||||
|
log(">> Generating OTF file %s" % otfName)
|
||||||
saveOTF(newFont, otfName, glyphOrder)
|
saveOTF(newFont, otfName, glyphOrder)
|
||||||
|
|
||||||
def generateTTFs(self):
|
def generateTTFs(self):
|
||||||
|
|
@ -208,9 +208,9 @@ class FontProject:
|
||||||
for font in fonts:
|
for font in fonts:
|
||||||
fonts_to_quadratic([font], max_err_em=max_err, dump_stats=True, reverse_direction=True)
|
fonts_to_quadratic([font], max_err_em=max_err, dump_stats=True, reverse_direction=True)
|
||||||
|
|
||||||
log(">> Generating TTF files")
|
|
||||||
for font in fonts:
|
for font in fonts:
|
||||||
ttfName = self.generateOutputPath(font, "ttf")
|
ttfName = self.generateOutputPath(font, "ttf")
|
||||||
|
log(">> Generating TTF file %s" % ttfName)
|
||||||
log(os.path.basename(ttfName))
|
log(os.path.basename(ttfName))
|
||||||
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)
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class InstanceNames:
|
||||||
else:
|
else:
|
||||||
self.shortfamily = self.longfamily
|
self.shortfamily = self.longfamily
|
||||||
|
|
||||||
def setRFNames(self,f, version=1, versionMinor=0):
|
def setRFNames(self,f, version=1, versionMinor=0, panose={}):
|
||||||
f.info.familyName = self.longfamily
|
f.info.familyName = self.longfamily
|
||||||
f.info.styleName = self.longstyle
|
f.info.styleName = self.longstyle
|
||||||
f.info.styleMapFamilyName = self.shortfamily
|
f.info.styleMapFamilyName = self.shortfamily
|
||||||
|
|
@ -93,6 +93,20 @@ class InstanceNames:
|
||||||
if self.italic:
|
if self.italic:
|
||||||
f.info.italicAngle = self.italicAngle
|
f.info.italicAngle = self.italicAngle
|
||||||
|
|
||||||
|
if len(panose) > 0:
|
||||||
|
f.info.openTypeOS2Panose = [
|
||||||
|
panose.get('bFamilyType', panose.get('familyType', 0)),
|
||||||
|
panose.get('bSerifStyle', panose.get('serifStyle', 0)),
|
||||||
|
panose.get('bWeight', panose.get('weight', 0)),
|
||||||
|
panose.get('bProportion', panose.get('proportion', 0)),
|
||||||
|
panose.get('bContrast', panose.get('contrast', 0)),
|
||||||
|
panose.get('bStrokeVariation', panose.get('strokeVariation', 0)),
|
||||||
|
panose.get('bArmStyle', panose.get('armStyle', 0)),
|
||||||
|
panose.get('bLetterform', panose.get('letterform', 0)),
|
||||||
|
panose.get('bMidline', panose.get('midline', 0)),
|
||||||
|
panose.get('bXHeight', panose.get('xHeight', 0)),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def setFLNames(self,flFont):
|
def setFLNames(self,flFont):
|
||||||
|
|
||||||
|
|
@ -220,7 +234,7 @@ def setNames(f,names,foundry="",version="1.0",build=""):
|
||||||
i.setFLNames(f)
|
i.setFLNames(f)
|
||||||
|
|
||||||
|
|
||||||
def setInfoRF(f, names, attrs={}):
|
def setInfoRF(f, names, attrs={}, panose={}):
|
||||||
i = InstanceNames(names)
|
i = InstanceNames(names)
|
||||||
version, versionMinor = (1, 0)
|
version, versionMinor = (1, 0)
|
||||||
for k,v in attrs.iteritems():
|
for k,v in attrs.iteritems():
|
||||||
|
|
@ -230,4 +244,4 @@ def setInfoRF(f, names, attrs={}):
|
||||||
else:
|
else:
|
||||||
version = int(v)
|
version = int(v)
|
||||||
setattr(i, k, v)
|
setattr(i, k, v)
|
||||||
i.setRFNames(f, version=version, versionMinor=versionMinor)
|
i.setRFNames(f, version=version, versionMinor=versionMinor, panose=panose)
|
||||||
|
|
|
||||||
|
|
@ -133,61 +133,88 @@ def main():
|
||||||
proj = FontProject(rg.font, BASEDIR, os.path.join(srcDir,'fontbuild.cfg'), buildTag=buildTag)
|
proj = FontProject(rg.font, BASEDIR, os.path.join(srcDir,'fontbuild.cfg'), buildTag=buildTag)
|
||||||
proj.builddir = args.out
|
proj.builddir = args.out
|
||||||
|
|
||||||
|
# panose for entire family
|
||||||
|
panose = {
|
||||||
|
'bFamilyType': 2, # Latin Text
|
||||||
|
'bSerifStyle': 11, # Normal Sans
|
||||||
|
'bProportion': 2, # Old Style
|
||||||
|
# bWeight: see http://monotype.de/services/pan2#_Toc380547249
|
||||||
|
}
|
||||||
|
|
||||||
|
def mkpanose(weight):
|
||||||
|
return dict(panose.items() + {
|
||||||
|
'bWeight': weight
|
||||||
|
}.items())
|
||||||
|
|
||||||
|
|
||||||
if args.otf:
|
if args.otf:
|
||||||
proj.buildOTF = True
|
proj.buildOTF = True
|
||||||
|
|
||||||
# name syntax: family/longstyle/shortstyle/subfamilyAbbrev
|
# name syntax: family/styleName/styleCode/subfamilyAbbrev
|
||||||
|
#
|
||||||
|
# styleCode should be one of:
|
||||||
|
# Regular, Italic, Bold, Bold Italic
|
||||||
|
#
|
||||||
# italicNarrowAmount controls scale on the x axis. 1.0 means no scaling.
|
# italicNarrowAmount controls scale on the x axis. 1.0 means no scaling.
|
||||||
# italicMeanYCenter controls how far on the x axis the glyph should slide
|
# italicMeanYCenter controls how far on the x axis the glyph should slide
|
||||||
# to compensate for the slant.
|
# to compensate for the slant.
|
||||||
|
|
||||||
if ALL or 'regular' in styles:
|
if ALL or 'regular' in styles:
|
||||||
handledStyles.append('regular')
|
handledStyles.append('regular')
|
||||||
proj.generateFont(rg.font, "%s/Regular/Regular/Rg" % FAMILYNAME)
|
proj.generateFont(rg.font, "%s/Regular/Regular/Rg" % FAMILYNAME,
|
||||||
|
panose=mkpanose(5))
|
||||||
|
|
||||||
if ALL or 'italic' in styles:
|
if ALL or 'italic' in styles:
|
||||||
handledStyles.append('italic')
|
handledStyles.append('italic')
|
||||||
proj.generateFont(rg.font, "%s/Italic/Italic/Rg" % FAMILYNAME,
|
proj.generateFont(
|
||||||
italic=True, stemWidth=232, italicMeanYCenter=-825, italicNarrowAmount=1)
|
rg.font, "%s/Italic/Italic/Rg" % FAMILYNAME,
|
||||||
|
italic=True, stemWidth=232, italicMeanYCenter=-825, italicNarrowAmount=1,
|
||||||
|
panose=mkpanose(5))
|
||||||
|
|
||||||
|
|
||||||
if ALL or 'medium' in styles:
|
if ALL or 'medium' in styles:
|
||||||
handledStyles.append('medium')
|
handledStyles.append('medium')
|
||||||
proj.generateFont(
|
proj.generateFont(
|
||||||
Mix2([rg, bl], 0.35, glyphSpecializations.get('medium', {})),
|
Mix2([rg, bl], 0.35, glyphSpecializations.get('medium', {})),
|
||||||
"%s/Medium/Regular/Me" % FAMILYNAME)
|
"%s/Medium/Regular/Me" % FAMILYNAME,
|
||||||
|
panose=mkpanose(6))
|
||||||
|
|
||||||
if ALL or 'mediumitalic' in styles:
|
if ALL or 'mediumitalic' in styles:
|
||||||
handledStyles.append('mediumitalic')
|
handledStyles.append('mediumitalic')
|
||||||
proj.generateFont(
|
proj.generateFont(
|
||||||
Mix2([rg, bl], 0.35, glyphSpecializations.get('medium', {})),
|
Mix2([rg, bl], 0.35, glyphSpecializations.get('medium', {})),
|
||||||
"%s/Medium Italic/Italic/Me" % FAMILYNAME,
|
"%s/Medium Italic/Italic/Me" % FAMILYNAME,
|
||||||
italic=True, stemWidth=300, italicMeanYCenter=-825, italicNarrowAmount=1)
|
italic=True, stemWidth=300, italicMeanYCenter=-825, italicNarrowAmount=1,
|
||||||
|
panose=mkpanose(6))
|
||||||
|
|
||||||
|
|
||||||
if ALL or 'bold' in styles:
|
if ALL or 'bold' in styles:
|
||||||
handledStyles.append('bold')
|
handledStyles.append('bold')
|
||||||
proj.generateFont(
|
proj.generateFont(
|
||||||
Mix2([rg, bl], 0.65, glyphSpecializations.get('bold', {})),
|
Mix2([rg, bl], 0.65, glyphSpecializations.get('bold', {})),
|
||||||
"%s/Bold/Bold/Bd" % FAMILYNAME)
|
"%s/Bold/Bold/Rg" % FAMILYNAME,
|
||||||
|
panose=mkpanose(8))
|
||||||
|
|
||||||
if ALL or 'bolditalic' in styles:
|
if ALL or 'bolditalic' in styles:
|
||||||
handledStyles.append('bolditalic')
|
handledStyles.append('bolditalic')
|
||||||
proj.generateFont(
|
proj.generateFont(
|
||||||
Mix2([rg, bl], 0.65, glyphSpecializations.get('bold', {})),
|
Mix2([rg, bl], 0.65, glyphSpecializations.get('bold', {})),
|
||||||
"%s/Bold Italic/Bold Italic/Bd" % FAMILYNAME,
|
"%s/Bold Italic/Bold Italic/Rg" % FAMILYNAME,
|
||||||
italic=True, stemWidth=350, italicMeanYCenter=-825, italicNarrowAmount=1)
|
italic=True, stemWidth=350, italicMeanYCenter=-825, italicNarrowAmount=1,
|
||||||
|
panose=mkpanose(8))
|
||||||
|
|
||||||
|
|
||||||
if ALL or 'black' in styles:
|
if ALL or 'black' in styles:
|
||||||
handledStyles.append('black')
|
handledStyles.append('black')
|
||||||
proj.generateFont(bl.font, "%s/Black/Regular/Bl" % FAMILYNAME)
|
proj.generateFont(bl.font, "%s/Black/Regular/Bl" % FAMILYNAME,
|
||||||
|
panose=mkpanose(9))
|
||||||
|
|
||||||
if ALL or 'blackitalic' in styles:
|
if ALL or 'blackitalic' in styles:
|
||||||
handledStyles.append('blackitalic')
|
handledStyles.append('blackitalic')
|
||||||
proj.generateFont(bl.font, "%s/Black Italic/Italic/Bl" % FAMILYNAME,
|
proj.generateFont(
|
||||||
italic=True, stemWidth=400, italicMeanYCenter=-825, italicNarrowAmount=1)
|
bl.font, "%s/Black Italic/Italic/Bl" % FAMILYNAME,
|
||||||
|
italic=True, stemWidth=400, italicMeanYCenter=-825, italicNarrowAmount=1,
|
||||||
|
panose=mkpanose(9))
|
||||||
|
|
||||||
# generate TTFs
|
# generate TTFs
|
||||||
if args.no_ttf == False:
|
if args.no_ttf == False:
|
||||||
|
|
|
||||||
|
|
@ -64,10 +64,10 @@ Glyphs from Roboto: Copyright 2011 Google Inc. All Rights Reserved.</string>
|
||||||
</array>
|
</array>
|
||||||
<key>openTypeOS2Panose</key>
|
<key>openTypeOS2Panose</key>
|
||||||
<array>
|
<array>
|
||||||
|
<integer>2</integer>
|
||||||
|
<integer>11</integer>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<integer>0</integer>
|
<integer>2</integer>
|
||||||
<integer>0</integer>
|
|
||||||
<integer>0</integer>
|
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,9 @@ Glyphs from Roboto: Copyright 2011 Google Inc. All Rights Reserved.</string>
|
||||||
<key>openTypeOS2Panose</key>
|
<key>openTypeOS2Panose</key>
|
||||||
<array>
|
<array>
|
||||||
<integer>2</integer>
|
<integer>2</integer>
|
||||||
|
<integer>11</integer>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<integer>0</integer>
|
<integer>2</integer>
|
||||||
<integer>0</integer>
|
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
|
|
|
||||||
Reference in a new issue