summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2018-10-01 04:56:58 +0300
committerRasmus Andersson <rasmus@notion.se>2018-10-11 09:38:26 +0300
commit5aa42117e9fbea07b25e9c4995aecca747bf6db9 (patch)
tree9f56ed40c9f4bb166fa1620fdca09d60cf647531 /misc
parentd05834a1cd48a4c4d428db64afb4e67cdfced7f2 (diff)
downloadinter-5aa42117e9fbea07b25e9c4995aecca747bf6db9.tar.xz
fontbuild: automatically patch version and timestamps when compiling. Helps avoid lock-step annoyance with git checkins and builds
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/fontbuild42
1 files changed, 25 insertions, 17 deletions
diff --git a/misc/fontbuild b/misc/fontbuild
index 2daadbee8..50f2e1629 100755
--- a/misc/fontbuild
+++ b/misc/fontbuild
@@ -16,6 +16,7 @@ import signal
import subprocess
from functools import partial
from fontmake.font_project import FontProject
+from defcon import Font
from fontTools import designspaceLib
from fontTools import varLib
from fontTools.misc.transform import Transform
@@ -109,6 +110,7 @@ class VarFontProject(FontProject):
decomposeGlyphs = set()
for ufo in ufos:
+ updateFontVersion(ufo)
isItalic = ufo.info.italicAngle != 0
for glyph in ufo:
if glyph.components and composedGlyphIsNonTrivial(glyph, yAxisIsNonTrivial=isItalic):
@@ -125,6 +127,24 @@ class VarFontProject(FontProject):
self.save_otfs(ufos, ttf=True, interpolatable=True, **kwargs)
+def updateFontVersion(font, updateCreated=True):
+ version = getVersion()
+ buildtag = getGitHash()
+ versionMajor, versionMinor = [int(num) for num in version.split(".")]
+ now = datetime.datetime.utcnow()
+ font.info.version = version
+ font.info.versionMajor = versionMajor
+ font.info.versionMinor = versionMinor
+ font.info.woffMajorVersion = versionMajor
+ font.info.woffMinorVersion = versionMinor
+ font.info.year = now.year
+ font.info.openTypeNameVersion = "%s;%s" % (version, buildtag)
+ font.info.openTypeNameUniqueID = "%s %s:%d:%s" % (font.info.familyName, font.info.styleName, now.year, buildtag)
+ if updateCreated:
+ # creation date & time (YYYY/MM/DD HH:MM:SS)
+ font.info.openTypeHeadCreated = now.strftime("%Y/%m/%d %H:%M:%S")
+
+
# setFontInfo patches font.info
#
def setFontInfo(font, weight, updateCreated=True):
@@ -135,10 +155,6 @@ def setFontInfo(font, weight, updateCreated=True):
# For OpenType NAME table IDs, see
# https://docs.microsoft.com/en-us/typography/opentype/spec/name#name-ids
#
- version = getVersion()
- buildtag = getGitHash()
- versionMajor, versionMinor = [int(num) for num in version.split(".")]
- now = datetime.datetime.utcnow()
family = font.info.familyName # i.e. "Inter UI"
style = font.info.styleName # e.g. "Medium Italic"
isitalic = font.info.italicAngle != 0
@@ -146,19 +162,8 @@ def setFontInfo(font, weight, updateCreated=True):
# weight
font.info.openTypeOS2WeightClass = weight
- # creation date & time (YYYY/MM/DD HH:MM:SS)
- if updateCreated:
- font.info.openTypeHeadCreated = now.strftime("%Y/%m/%d %H:%M:%S")
-
# version
- font.info.version = version
- font.info.versionMajor = versionMajor
- font.info.versionMinor = versionMinor
- font.info.woffMajorVersion = versionMajor
- font.info.woffMinorVersion = versionMinor
- font.info.year = now.year
- font.info.openTypeNameVersion = "%s;%s" % (version, buildtag)
- font.info.openTypeNameUniqueID = "%s %s:%d:%s" % (family, style, now.year, buildtag)
+ updateFontVersion(font, updateCreated=updateCreated)
# Names
family_nosp = re.sub(r'\s', '', family)
@@ -378,9 +383,12 @@ class Main(object):
project = FontProject(verbose=self.logLevelName, validate_ufo=args.validate)
+ ufo = Font(args.srcfile)
+ updateFontVersion(ufo)
+
# run fontmake to produce OTF/TTF file at tmpfilename
project.run_from_ufos(
- [args.srcfile],
+ [ ufo ],
output_path=tmpfilename,
output=formats,
subroutinize=True,