summaryrefslogtreecommitdiff
path: root/misc/fontbuild
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@figma.com>2019-03-27 21:08:49 +0300
committerRasmus Andersson <rasmus@figma.com>2019-03-27 21:08:49 +0300
commit35a23627a5222684119a11b3b0c8dc5cb1ea04a2 (patch)
tree88ff6c653227615efa290ce9b1d02171ef8f4203 /misc/fontbuild
parent20aaab681df22c8251fbc1bb68fbd38a1b858b32 (diff)
downloadinter-35a23627a5222684119a11b3b0c8dc5cb1ea04a2.tar.xz
Adds --name option to "fontbuild compile-var" for customizing family name, useful for producing variable font files with a different name than the constant files so they can be installed alongside each other. Closes #144
Diffstat (limited to 'misc/fontbuild')
-rwxr-xr-xmisc/fontbuild33
1 files changed, 25 insertions, 8 deletions
diff --git a/misc/fontbuild b/misc/fontbuild
index bf88e95b0..e7c86a67c 100755
--- a/misc/fontbuild
+++ b/misc/fontbuild
@@ -114,6 +114,10 @@ def findGlyphDirectives(g): # -> set<string> | None
class VarFontProject(FontProject):
+ def __init__(self, familyName=None, *args, **kwargs):
+ super(VarFontProject, self).__init__(*args, **kwargs)
+ self.familyName = familyName
+
def decompose_glyphs(self, designspace, glyph_filter=lambda g: True):
"""Move components of UFOs' glyphs to their outlines."""
for ufo in designspace:
@@ -162,13 +166,17 @@ class VarFontProject(FontProject):
masters = [s.font for s in designspace.sources]
for ufo in masters:
- ufo.info.familyName = "Inter Variable"
- ufo.info.styleMapFamilyName = "Inter Variable"
- ufo.info.postscriptFontName = "InterVariable"
- ufo.info.macintoshFONDName =\
- ufo.info.macintoshFONDName.replace('Inter', 'Inter Variable')
- ufo.info.openTypeNamePreferredFamilyName =\
- ufo.info.openTypeNamePreferredFamilyName.replace('Inter', 'Inter Variable')
+ if self.familyName is not None:
+ ufo.info.familyName =\
+ ufo.info.familyName.replace('Inter', self.familyName)
+ ufo.info.styleMapFamilyName =\
+ ufo.info.styleMapFamilyName.replace('Inter', self.familyName)
+ ufo.info.postscriptFontName =\
+ ufo.info.postscriptFontName.replace('Inter', self.familyName.replace(' ', ''))
+ ufo.info.macintoshFONDName =\
+ ufo.info.macintoshFONDName.replace('Inter', self.familyName)
+ ufo.info.openTypeNamePreferredFamilyName =\
+ ufo.info.openTypeNamePreferredFamilyName.replace('Inter', self.familyName)
updateFontVersion(ufo)
isItalic = ufo.info.italicAngle != 0
ufoname = basename(ufo.path)
@@ -405,6 +413,9 @@ class Main(object):
argparser.add_argument('-o', '--output', metavar='<fontfile>',
help='Output font file')
+ argparser.add_argument('--name', metavar='<family-name>',
+ help='Override family name, replacing "Inter"')
+
args = argparser.parse_args(argv)
# decide output filename (or check user-provided name)
@@ -419,7 +430,12 @@ class Main(object):
mkdirs(dirname(outfilename))
- project = VarFontProject(verbose=self.logLevelName)
+ # override family name?
+ familyName = None
+ if args.name is not None and len(args.name) > 0:
+ familyName = args.name
+
+ project = VarFontProject(verbose=self.logLevelName, familyName=familyName)
project.run_from_designspace(
args.srcfile,
interpolate=False,
@@ -430,6 +446,7 @@ class Main(object):
output=['variable'],
overlaps_backend='pathops', # use Skia's pathops
)
+
self.log("write %s" % outfilename)
# Note: we can't run ots-sanitize on the generated file as OTS