diff --git a/misc/pylib/fontbuild/Build.pyx b/misc/pylib/fontbuild/Build.pyx index 2832aa28e..d2629b337 100644 --- a/misc/pylib/fontbuild/Build.pyx +++ b/misc/pylib/fontbuild/Build.pyx @@ -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) diff --git a/misc/pylib/fontbuild/instanceNames.py b/misc/pylib/fontbuild/instanceNames.py index b93f3a9f0..239af3f78 100644 --- a/misc/pylib/fontbuild/instanceNames.py +++ b/misc/pylib/fontbuild/instanceNames.py @@ -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) diff --git a/misc/ufocompile b/misc/ufocompile index c140315a6..f56ae5519 100755 --- a/misc/ufocompile +++ b/misc/ufocompile @@ -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: diff --git a/src/Inter-UI-Black.ufo/fontinfo.plist b/src/Inter-UI-Black.ufo/fontinfo.plist index 9550488c0..64581099e 100644 --- a/src/Inter-UI-Black.ufo/fontinfo.plist +++ b/src/Inter-UI-Black.ufo/fontinfo.plist @@ -64,10 +64,10 @@ Glyphs from Roboto: Copyright 2011 Google Inc. All Rights Reserved. openTypeOS2Panose + 2 + 11 0 - 0 - 0 - 0 + 2 0 0 0 diff --git a/src/Inter-UI-Regular.ufo/fontinfo.plist b/src/Inter-UI-Regular.ufo/fontinfo.plist index 9206430a1..dc857f4aa 100644 --- a/src/Inter-UI-Regular.ufo/fontinfo.plist +++ b/src/Inter-UI-Regular.ufo/fontinfo.plist @@ -65,9 +65,9 @@ Glyphs from Roboto: Copyright 2011 Google Inc. All Rights Reserved. openTypeOS2Panose 2 + 11 0 - 0 - 0 + 2 0 0 0