1
1
mirror of https://github.com/rsms/inter.git synced 2024-11-23 11:43:47 +03:00

Fixes to font metadata, including addition of some OS/2 panose information

This commit is contained in:
Rasmus Andersson 2018-01-08 10:26:09 -08:00
parent 96fb366982
commit 76f983adae
5 changed files with 69 additions and 28 deletions

View File

@ -85,10 +85,10 @@ class FontProject:
return os.path.join(path, "%s-%s.%s" % (family, style, ext))
def generateFont(self, mix, names, italic=False, swapSuffixes=None, stemWidth=185,
italicMeanYCenter=-825, italicNarrowAmount=1):
italicMeanYCenter=-825, italicNarrowAmount=1, panose=[]):
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):
log(">> Mixing masters")
@ -164,7 +164,7 @@ class FontProject:
'license': getcfg('license'),
'licenseURL': getcfg('licenseURL'),
'italicAngle': float(getcfg('italicAngle', '-12')),
})
}, panose)
if not self.compatible:
cleanCurves(f)
@ -187,9 +187,9 @@ class FontProject:
glyphOrder.append(glyphName)
if self.buildOTF:
log(">> Generating OTF file")
newFont = OpenFont(ufoName)
otfName = self.generateOutputPath(f, "otf")
log(">> Generating OTF file %s" % otfName)
saveOTF(newFont, otfName, glyphOrder)
def generateTTFs(self):
@ -208,9 +208,9 @@ class FontProject:
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(">> Generating TTF file %s" % ttfName)
log(os.path.basename(ttfName))
glyphOrder = [n for n in self.glyphOrder if n in font]
saveOTF(font, ttfName, glyphOrder, truetype=True)

View File

@ -53,7 +53,7 @@ class InstanceNames:
else:
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.styleName = self.longstyle
f.info.styleMapFamilyName = self.shortfamily
@ -64,7 +64,7 @@ class InstanceNames:
if len(self.copyrightHolderName) > 0:
f.info.copyright = "Copyright %s %s" % (self.year, self.copyrightHolderName)
f.info.trademark = "%s is a trademark of %s." %(self.longfamily, self.foundry.rstrip('.'))
if len(self.designer) > 0:
f.info.openTypeNameDesigner = self.designer
if len(self.designerURL) > 0:
@ -84,14 +84,28 @@ class InstanceNames:
# f.info.openTypeNameCompatibleFullName = ""
# f.info.openTypeNameSampleText = ""
if (self.subfamilyAbbrev != "Rg"):
f.info.openTypeNamePreferredFamilyName = self.longfamily
f.info.openTypeNamePreferredSubfamilyName = self.longstyle
f.info.openTypeNamePreferredFamilyName = self.longfamily
f.info.openTypeNamePreferredSubfamilyName = self.longstyle
f.info.openTypeOS2WeightClass = self._getWeightCode(self.weight)
f.info.macintoshFONDName = re.sub(' ','',self.longfamily) + " " + re.sub(' ','',self.longstyle)
f.info.postscriptFontName = f.info.macintoshFONDName.replace(" ", "-")
if self.italic:
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):
@ -220,7 +234,7 @@ def setNames(f,names,foundry="",version="1.0",build=""):
i.setFLNames(f)
def setInfoRF(f, names, attrs={}):
def setInfoRF(f, names, attrs={}, panose={}):
i = InstanceNames(names)
version, versionMinor = (1, 0)
for k,v in attrs.iteritems():
@ -230,4 +244,4 @@ def setInfoRF(f, names, attrs={}):
else:
version = int(v)
setattr(i, k, v)
i.setRFNames(f, version=version, versionMinor=versionMinor)
i.setRFNames(f, version=version, versionMinor=versionMinor, panose=panose)

View File

@ -133,61 +133,88 @@ def main():
proj = FontProject(rg.font, BASEDIR, os.path.join(srcDir,'fontbuild.cfg'), buildTag=buildTag)
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:
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.
# italicMeanYCenter controls how far on the x axis the glyph should slide
# to compensate for the slant.
if ALL or 'regular' in styles:
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:
handledStyles.append('italic')
proj.generateFont(rg.font, "%s/Italic/Italic/Rg" % FAMILYNAME,
italic=True, stemWidth=232, italicMeanYCenter=-825, italicNarrowAmount=1)
proj.generateFont(
rg.font, "%s/Italic/Italic/Rg" % FAMILYNAME,
italic=True, stemWidth=232, italicMeanYCenter=-825, italicNarrowAmount=1,
panose=mkpanose(5))
if ALL or 'medium' in styles:
handledStyles.append('medium')
proj.generateFont(
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:
handledStyles.append('mediumitalic')
proj.generateFont(
Mix2([rg, bl], 0.35, glyphSpecializations.get('medium', {})),
"%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:
handledStyles.append('bold')
proj.generateFont(
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:
handledStyles.append('bolditalic')
proj.generateFont(
Mix2([rg, bl], 0.65, glyphSpecializations.get('bold', {})),
"%s/Bold Italic/Bold Italic/Bd" % FAMILYNAME,
italic=True, stemWidth=350, italicMeanYCenter=-825, italicNarrowAmount=1)
"%s/Bold Italic/Bold Italic/Rg" % FAMILYNAME,
italic=True, stemWidth=350, italicMeanYCenter=-825, italicNarrowAmount=1,
panose=mkpanose(8))
if ALL or 'black' in styles:
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:
handledStyles.append('blackitalic')
proj.generateFont(bl.font, "%s/Black Italic/Italic/Bl" % FAMILYNAME,
italic=True, stemWidth=400, italicMeanYCenter=-825, italicNarrowAmount=1)
proj.generateFont(
bl.font, "%s/Black Italic/Italic/Bl" % FAMILYNAME,
italic=True, stemWidth=400, italicMeanYCenter=-825, italicNarrowAmount=1,
panose=mkpanose(9))
# generate TTFs
if args.no_ttf == False:

View File

@ -64,10 +64,10 @@ Glyphs from Roboto: Copyright 2011 Google Inc. All Rights Reserved.</string>
</array>
<key>openTypeOS2Panose</key>
<array>
<integer>2</integer>
<integer>11</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>2</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>

View File

@ -65,9 +65,9 @@ Glyphs from Roboto: Copyright 2011 Google Inc. All Rights Reserved.</string>
<key>openTypeOS2Panose</key>
<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>