diff --git a/Makefile b/Makefile index b2ccd141b..596c637c7 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,9 @@ $(UFODIR)/features: @ln -s ../../src/features $(UFODIR)/features # designspace & master UFOs +$(UFODIR)/%.var.designspace: $(UFODIR)/%.designspace | venv + . $(VENV) ; python misc/tools/gen-var-designspace.py $< $@ + $(UFODIR)/%.designspace: $(UFODIR)/%.glyphs $(UFODIR)/features | venv . $(VENV) ; fontmake $(FM_ARGS) -o ufo -g $< --designspace-path $@ \ --master-dir $(UFODIR) --instance-dir $(UFODIR) @@ -139,7 +142,9 @@ build/ufo-editable/.ok: build/ufo-editable/Inter-Roman.designspace build/ufo-edi $(UFODIR)/Inter-Roman.glyphs \ $(UFODIR)/Inter-Italic.glyphs \ $(UFODIR)/Inter-Roman.designspace \ - $(UFODIR)/Inter-Italic.designspace + $(UFODIR)/Inter-Italic.designspace \ + $(UFODIR)/Inter-Roman.var.designspace \ + $(UFODIR)/Inter-Italic.var.designspace # --------------------------------------------------------------------------------- # products @@ -173,10 +178,10 @@ $(FONTDIR)/static/%.ttf: $(UFODIR)/%.ufo build/features_data | $(FONTDIR)/static $(FONTDIR)/static-hinted/%.ttf: $(FONTDIR)/static/%.ttf | $(FONTDIR)/static-hinted venv . $(VENV) ; python -m ttfautohint --no-info "$<" "$@" -$(FONTDIR)/var/_%.var.ttf: $(UFODIR)/%.designspace build/features_data | $(FONTDIR)/var venv +$(FONTDIR)/var/_%.var.ttf: $(UFODIR)/%.var.designspace build/features_data | $(FONTDIR)/var venv . $(VENV) ; fontmake -o variable -m $< --output-path $@ $(FM_ARGS_2) -$(FONTDIR)/var/_%.var.otf: $(UFODIR)/%.designspace build/features_data | $(FONTDIR)/var venv +$(FONTDIR)/var/_%.var.otf: $(UFODIR)/%.var.designspace build/features_data | $(FONTDIR)/var venv . $(VENV) ; fontmake -o variable-cff2 -m $< --output-path $@ $(FM_ARGS_2) %.woff2: %.ttf | venv @@ -196,7 +201,6 @@ $(FONTDIR)/var/inter-roman-and-italic.stamp: \ $(FONTDIR)/var/_Inter-Roman.var.ttf \ $(FONTDIR)/var/_Inter-Italic.var.ttf \ | venv - @#. $(VENV) ; python misc/tools/postprocess-vf2.py $^ mkdir $(FONTDIR)/var/gen-stat . $(VENV) ; gftools gen-stat --out $(FONTDIR)/var/gen-stat $^ mv $(FONTDIR)/var/gen-stat/_Inter-Roman.var.ttf $(FONTDIR)/var/Inter.var.ttf @@ -227,10 +231,9 @@ var_web: \ web: var_web static_web static: \ - $(FONTDIR)/static/Inter.ttc \ - $(FONTDIR)/static-hinted/Inter-truetype.ttc + $(FONTDIR)/static/Inter.ttc -$(FONTDIR)/static/Inter.ttc: \ +$(FONTDIR)/static/Inter.otc: \ $(FONTDIR)/static/Inter-Regular.otf \ $(FONTDIR)/static/Inter-Black.otf \ $(FONTDIR)/static/Inter-BlackItalic.otf \ @@ -269,7 +272,7 @@ $(FONTDIR)/static/Inter.ttc: \ $(FONTDIR)/static/Inter-DisplayExtraBoldItalic.otf . $(VENV) ; python -m fontTools.ttLib.__init__ -o $@ $^ -$(FONTDIR)/static-hinted/Inter-truetype.ttc: \ +$(FONTDIR)/static-hinted/Inter.ttc: \ $(FONTDIR)/static-hinted/Inter-Regular.ttf \ $(FONTDIR)/static-hinted/Inter-Black.ttf \ $(FONTDIR)/static-hinted/Inter-BlackItalic.ttf \ @@ -499,7 +502,7 @@ static_web_hinted: \ $(FONTDIR)/static-hinted/Inter-DisplayExtraBoldItalic.woff2 -all: var static web static_otf static_ttf static_ttf_hinted +all: var static web static_otf static_ttf static_ttf_hinted static_web_hinted .PHONY: \ all var var_web web \ @@ -568,6 +571,7 @@ zip_beta: \ # - step2 runs tests, then makes a zip archive and updates the website (docs/ dir.) DIST_ZIP = build/release/Inter-${VERSION}.zip +DIST_ZIP_EXTRAS = build/release/Inter-${VERSION}-extras.zip dist: dist_preflight @# rebuild since font version & ID is based on git hash @@ -599,6 +603,7 @@ dist_step2: test dist_zip: | venv . $(VENV) ; python misc/tools/patch-version.py misc/dist/inter.css + bash misc/makezip2.sh -extras "$(DIST_ZIP_EXTRAS)" bash misc/makezip2.sh -reveal-in-finder "$(DIST_ZIP)" dist_docs: @@ -628,7 +633,7 @@ dist_postflight: INSTALLDIR := $(HOME)/Library/Fonts/Inter install: install_var $(INSTALLDIR)/Inter.ttc - @# Remove any old pre ttc fonts + @# Remove any old pre-ttc fonts rm -rf $(INSTALLDIR)/Inter*.otf install_var: \ @@ -638,6 +643,9 @@ install_var: \ $(INSTALLDIR)/%.ttc: $(FONTDIR)/static/%.ttc | $(INSTALLDIR) cp -a $^ $@ +$(INSTALLDIR)/%.otc: $(FONTDIR)/static/%.ttc | $(INSTALLDIR) + cp -a $^ $@ + $(INSTALLDIR)/%.otf: $(FONTDIR)/static/%.otf | $(INSTALLDIR) cp -a $^ $@ diff --git a/misc/dist/help.txt b/misc/dist/help.txt index acc9f4de9..3d1e9b278 100644 --- a/misc/dist/help.txt +++ b/misc/dist/help.txt @@ -6,14 +6,13 @@ Contents: 1.2. Installing on Microsoft Windows 1.3. Installing on Ubuntu Linux 2. Using Inter in Web content - 3. Hinted TrueType fonts (Inter TrueType.ttc) + 3. Hinted TrueType fonts 4. Extras 5. License (can I use Inter for x?) File index: - Inter.ttc Complete font family (CFF1) - Inter Variable*.ttf Complete font family (Variable TrueType) - Inter TrueType.ttc Complete font family (TrueType, with TT hints) + Inter.ttc Complete font family "Inter" + Inter Variable*.ttf Complete font family "Inter Variable" Web/* Web fonts and CSS --------------------------------------------------------------------- @@ -21,7 +20,7 @@ File index: 1. Installing font files Inter fonts comes in two flavors: - Variable (Inter Variable*.ttf) and Static (Inter.ttc). + Variable (Inter Variable*.ttf) and Static (Inter.ttc) Variable fonts allow you to choose any weight and optical size in supported software. Variable fonts is a relatively recent new @@ -42,7 +41,8 @@ File index: 1. Open the "Font Book" application. 2. In the main menu, select "File" → "Add Fonts..." 3. Select "Inter.ttc", "Inter Variable.ttf" and - "Inter Variable Italic.ttf", then press "Open" + "Inter Variable Italic.ttf" + 4. Press the "Open" button Alternatively, if you prefer not to use Font Book, you can move or copy the font files directly into ~/Library/Fonts/ @@ -51,7 +51,7 @@ File index: 1.2. Installing on Microsoft Windows 1. Open the zip file you downloaded - 2. Select the files "Inter TrueType.ttc", "Inter Variable.ttf" and + 2. Select "Inter.ttc", "Inter Variable.ttf" and "Inter Variable Italic.ttf" 3. Right-click the selected files, choose "Install for all users" @@ -68,9 +68,6 @@ File index: "Inter Variable Italic.ttf" into your .fonts directory (cp Inter.ttc *.ttf ~/.fonts/) - If you prefer the look of Microsoft ClearType-style "hinted" fonts, - for step 2, install "Inter TrueType.ttc" (INSTEAD OF "Inter.ttc".) - You may have to restart apps and/or your window server session. --------------------------------------------------------------------- @@ -118,36 +115,22 @@ File index: --------------------------------------------------------------------- -3. Hinted TrueType fonts (Inter TrueType.ttc) +3. Hinted TrueType fonts - This distribution contains TrueType fonts with hints (the programs - needed by ClearType) in a separate font bundle "Inter TrueType.ttc" + This distribution contains TrueType fonts with hints in "Inter.ttc" Microsoft Windows uses a technology called ClearType which alters the shape of letters to increase sharpness, in particular for low- density displays. This requires a font to have little programs built into them, called TrueType hinting instructions, which lets ClearType knows how to alter each character. - The standard distribution of Inter doesn't contain such "hints" - since it is relatively rare (and the web fonts would grow much - larger if they did contain such hinting programs.) - Additionally, some people on Windows do not like the appearance of - ClearType and prefer non-hinted fonts. (Tip: You can customize - ClearType to your liking in Window's settings.) The variable font is currently not available with TrueType hints, only the traditional "static" font files are. This will hopefully change in a future release. - Important: DO NOT INSTALL BOTH VERSIONS! - - DO NOT install both "Inter.ttc" and "Inter TrueType.ttc". - DO install ONE OF those font files, - or else confusing, strange things might happen (conflicts.) - - Recap: - - If you want to make use of ClearType, install "Inter TrueType.ttc" - - If you do not want or need ClearType support, install "Inter.ttc" + Note that the web fonts does not contain hints to minimize file + size. You can get hinted web fonts from the "extras" distribution. --------------------------------------------------------------------- diff --git a/misc/dist/inter.css b/misc/dist/inter.css index e9da8bbed..028d7b522 100644 --- a/misc/dist/inter.css +++ b/misc/dist/inter.css @@ -8,20 +8,20 @@ font-weight: 100 900; font-display: swap; font-style: normal; - src: url("Inter.var.woff2?v=3.19") format("woff2-variations"), - url("Inter.var.woff2?v=3.19") format("woff2"); - src: url("Inter.var.woff2?v=3.19") format("woff2") tech("variations"); + src: url("InterVariable.woff2?v=3.19") format("woff2-variations"), + url("InterVariable.woff2?v=3.19") format("woff2"); + src: url("InterVariable.woff2?v=3.19") format("woff2") tech("variations"); } @font-face { font-family: "InterVar"; font-weight: 100 900; font-display: swap; font-style: italic; - src: url("Inter-Italic.var.woff2?v=3.19") format("woff2-variations"), - url("Inter-Italic.var.woff2?v=3.19") format("woff2"); - src: url("Inter-Italic.var.woff2?v=3.19") format("woff2") tech("variations"); + src: url("InterVariable-Italic.woff2?v=3.19") format("woff2-variations"), + url("InterVariable-Italic.woff2?v=3.19") format("woff2"); + src: url("InterVariable-Italic.woff2?v=3.19") format("woff2") tech("variations"); } -/* static fonts "Inter" */ +/* static fonts */ @font-face { font-family: "Inter"; font-style: normal; font-weight: 100; font-display: swap; src: url("Inter-Thin.woff2?v=3.19") format("woff2"); } @font-face { font-family: "Inter"; font-style: italic; font-weight: 100; font-display: swap; src: url("Inter-ThinItalic.woff2?v=3.19") format("woff2"); } @font-face { font-family: "Inter"; font-style: normal; font-weight: 200; font-display: swap; src: url("Inter-ExtraLight.woff2?v=3.19") format("woff2"); } @@ -40,7 +40,6 @@ @font-face { font-family: "Inter"; font-style: italic; font-weight: 800; font-display: swap; src: url("Inter-ExtraBoldItalic.woff2?v=3.19") format("woff2"); } @font-face { font-family: "Inter"; font-style: normal; font-weight: 900; font-display: swap; src: url("Inter-Black.woff2?v=3.19") format("woff2"); } @font-face { font-family: "Inter"; font-style: italic; font-weight: 900; font-display: swap; src: url("Inter-BlackItalic.woff2?v=3.19") format("woff2"); } -/* static fonts "InterDisplay" */ @font-face { font-family: "InterDisplay"; font-style: normal; font-weight: 100; font-display: swap; src: url("Inter-DisplayThin.woff2?v=3.19") format("woff2"); } @font-face { font-family: "InterDisplay"; font-style: italic; font-weight: 100; font-display: swap; src: url("Inter-DisplayThinItalic.woff2?v=3.19") format("woff2"); } @font-face { font-family: "InterDisplay"; font-style: normal; font-weight: 200; font-display: swap; src: url("Inter-DisplayExtraLight.woff2?v=3.19") format("woff2"); } diff --git a/misc/makezip2.sh b/misc/makezip2.sh index 9f8c17086..77c7817af 100644 --- a/misc/makezip2.sh +++ b/misc/makezip2.sh @@ -54,29 +54,32 @@ mkdir -p "$(dirname "$OUTFILE_ABS")" "$ZIPDIR" cp LICENSE.txt "$ZIPDIR/LICENSE.txt" if $OPT_EXTRAS; then - mkdir -p "$ZIPDIR/OTF" "$ZIPDIR/TTF" + mkdir -p "$ZIPDIR/OTF" "$ZIPDIR/TTF" "$ZIPDIR/Web with TrueType hints" - cp misc/dist/extras-readme.txt "$ZIPDIR/README.txt" - cp build/fonts/static/Inter-*.otf "$ZIPDIR/OTF/" & - cp build/fonts/static-hinted/Inter-*.ttf "$ZIPDIR/TTF/" & + cp misc/dist/extras-readme.txt "$ZIPDIR/README.txt" + cp build/fonts/static/Inter-*.otf "$ZIPDIR/OTF/" & + cp build/fonts/static-hinted/Inter-*.ttf "$ZIPDIR/TTF/" & + cp build/fonts/static-hinted/Inter-*.woff2 "$ZIPDIR/Web with TrueType hints/" & else mkdir -p "$ZIPDIR/Web" - cp misc/dist/help.txt "$ZIPDIR/help.txt" - cp build/fonts/static/Inter.ttc "$ZIPDIR/Inter.ttc" - cp build/fonts/static-hinted/Inter-truetype.ttc "$ZIPDIR/Inter TrueType.ttc" - cp build/fonts/var/InterV.var.ttf "$ZIPDIR/Inter Variable.ttf" - cp build/fonts/var/InterV-Italic.var.ttf "$ZIPDIR/Inter Variable Italic.ttf" + cp misc/dist/help.txt "$ZIPDIR/help.txt" + cp build/fonts/static/Inter.ttc "$ZIPDIR/Inter.ttc" + cp build/fonts/var/InterV.var.ttf "$ZIPDIR/Inter Variable.ttf" + cp build/fonts/var/InterV-Italic.var.ttf "$ZIPDIR/Inter Variable Italic.ttf" + cp build/fonts/static/Inter-*.woff2 "$ZIPDIR/Web/" & + cp build/fonts/var/Inter.var.woff2 "$ZIPDIR/Web/InterVariable.woff2" + cp build/fonts/var/Inter-Italic.var.woff2 "$ZIPDIR/Web/InterVariable-Italic.woff2" + cp misc/dist/inter.css "$ZIPDIR/Web/" - cp build/fonts/static/Inter-*.woff2 \ - build/fonts/var/Inter.var.woff2 \ - build/fonts/var/Inter-Italic.var.woff2 \ - misc/dist/inter.css "$ZIPDIR/Web/" & + . build/venv/bin/activate + python misc/tools/patch-version.py "$ZIPDIR/Web/inter.css" fi mkdir -p "$(dirname "$OUTFILE_ABS")" wait +rm -rf "$OUTFILE_ABS" pushd "$ZIPDIR" >/dev/null zip -q -X -r "$OUTFILE_ABS" * popd >/dev/null diff --git a/misc/tools/fontinfo.py b/misc/tools/fontinfo.py index 5f578f808..0a4565929 100755 --- a/misc/tools/fontinfo.py +++ b/misc/tools/fontinfo.py @@ -21,6 +21,7 @@ from fontTools.ttLib.tables._m_a_x_p import maxpFormat_0_5, maxpFormat_1_0_add from fontTools.ttLib.tables._p_o_s_t import postFormat from fontTools.ttLib.tables.O_S_2f_2 import OS2_format_1, OS2_format_2, OS2_format_5, panoseFormat from fontTools.ttLib.tables._m_e_t_a import table__m_e_t_a +import fontTools.ttLib.tables._t_r_a_k as t_r_a_k # from robofab.world import world, RFont, RGlyph, OpenFont, NewFont # from robofab.objects.objectsRF import RFont, RGlyph, OpenFont, NewFont, RContour @@ -296,7 +297,10 @@ def genFontInfo(fontpath, outputType, withGlyphs=True): version = v[0] if version.lower() == 'version': version = v[1] - version = '.'.join([str(int(v)) for v in version.split('.')]) + try: + version = '.'.join([str(int(v)) for v in version.split('.')]) + except: + version = nameDict['version'] info['version'] = version if outputType is not OUTPUT_TYPE_GLYPHLIST: @@ -447,11 +451,11 @@ def genFontInfo(fontpath, outputType, withGlyphs=True): if fsSelection & 0b0000000000001000: s.append('3: OUTLINED') if fsSelection & 0b0000000000010000: s.append('4: STRIKEOUT') if fsSelection & 0b0000000000100000: s.append('5: BOLD') - if fsSelection & 0b0000000010000000: s.append('6: REGULAR') - if fsSelection & 0b0000000100000000: s.append('7: USE_TYPO_METRICS') - if fsSelection & 0b0000001000000000: s.append('8: WWS') - if fsSelection & 0b0000010000000000: s.append('9: OBLIQUE') - os2['fsSelection_raw'] = fsSelection + if fsSelection & 0b0000000001000000: s.append('6: REGULAR') + if fsSelection & 0b0000000010000000: s.append('7: USE_TYPO_METRICS') + if fsSelection & 0b0000000100000000: s.append('8: WWS') + if fsSelection & 0b0000001000000000: s.append('9: OBLIQUE') + os2['fsSelection_raw'] = bin(fsSelection) os2['fsSelection'] = s @@ -464,9 +468,25 @@ def genFontInfo(fontpath, outputType, withGlyphs=True): v.decode('utf8') meta[k] = v except: - meta[k] = 'data:;base64,' + b64encode(v) + meta[k] = 'data:;base64,' + b64encode(v).decode('ascii') info['meta'] = meta + if 'trak' in tt: + # Apple-specific table, linking size to tracking values. + # https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6trak.html + trak = {} + table = tt['trak'] + for direction in ("horiz", "vert"): + dataName = direction + "Data" + trackData = getattr(table, dataName, t_r_a_k.TrackData()) + td = {} + for k, tableEntry in trackData.__dict__['_map'].items(): + td[k] = { "nameIndex": tableEntry.nameIndex } + for k2 in tableEntry.keys(): + td[k][str(k2)] = tableEntry[k2] + trak[dataName] = td + info['trak'] = trak + # rest of tables for tname in tt.keys(): if tname not in info: diff --git a/misc/tools/gen-var-designspace.py b/misc/tools/gen-var-designspace.py new file mode 100644 index 000000000..7b3e4b757 --- /dev/null +++ b/misc/tools/gen-var-designspace.py @@ -0,0 +1,68 @@ +import sys, argparse, re +from fontTools.designspaceLib import DesignSpaceDocument + + +WHITESPACE_RE = re.compile(r'\s+') + + +def remove_whitespace(s): + return WHITESPACE_RE.sub("", s) + + +def fixup_instances_text(designspace): + # makes the "text" (non-display) instances the default ones + i = len(designspace.instances) + while i > 0: + i -= 1 + instance = designspace.instances[i] + if instance.name.find('Inter Display') != -1: + del designspace.instances[i] + + +def fixup_instances_display(designspace): + # makes the display instances the default ones + i = len(designspace.instances) + while i > 0: + i -= 1 + instance = designspace.instances[i] + if instance.name.find('Inter Display') != -1: + if instance.styleName == 'Display': + instance.styleName = 'Regular' + else: + instance.styleName = instance.styleName.replace('Display ', '') + else: + del designspace.instances[i] + # change default opsz value + for a in designspace.axes: + if a.tag == "opsz": + a.default = a.maximum + break + + +def fixup_postscript_instance_names(designspace): + # make sure there are PostScript names assigned (fontmake does not create these) + psFamilyName = remove_whitespace(designspace.instances[0].familyName) + for instance in designspace.instances: + instance.postScriptFontName = psFamilyName + remove_whitespace(instance.styleName) + + +def main(argv): + ap = argparse.ArgumentParser(description= + 'Generate designspace file for variable font from generic designspace file') + ap.add_argument("input_designspace", help="Path to generic designspace file") + ap.add_argument("output_designspace", help="Path for output designspace file") + + args = ap.parse_args() + + designspace = DesignSpaceDocument.fromfile(args.input_designspace) + + # fixup_instances_text(designspace) + fixup_instances_display(designspace) + + fixup_postscript_instance_names(designspace) + + designspace.write(args.output_designspace) + + +if __name__ == '__main__': + main(sys.argv) diff --git a/src/Inter-Italic.glyphspackage/fontinfo.plist b/src/Inter-Italic.glyphspackage/fontinfo.plist index e40fc6fc7..ee8c4e272 100644 --- a/src/Inter-Italic.glyphspackage/fontinfo.plist +++ b/src/Inter-Italic.glyphspackage/fontinfo.plist @@ -2132,9 +2132,7 @@ dngb_ballotx.squared name = openTypeHeadFlags; value = ( 0, -1, -3, -4 +1 ); }, { @@ -2158,9 +2156,9 @@ name = openTypeOS2Panose; value = ( 2, 11, -5, -2, -3, +0, +0, +0, 0, 0, 0, @@ -2233,7 +2231,7 @@ value = 0; }, { name = "Variable Font Origin"; -value = "C698F293-3EC0-4A5A-A3A0-0FDB1F5CF265"; +value = "11F4534A-B963-4AB5-820F-DAF9A20CD933"; }, { name = "Use Typo Metrics"; @@ -2241,7 +2239,7 @@ value = 1; }, { name = "Get Hints From Master"; -value = "C698F293-3EC0-4A5A-A3A0-0FDB1F5CF265"; +value = "11F4534A-B963-4AB5-820F-DAF9A20CD933"; } ); date = "2016-12-04 18:21:54 +0000"; diff --git a/src/Inter-Roman.glyphspackage/fontinfo.plist b/src/Inter-Roman.glyphspackage/fontinfo.plist index 6c0a7122d..76182206b 100644 --- a/src/Inter-Roman.glyphspackage/fontinfo.plist +++ b/src/Inter-Roman.glyphspackage/fontinfo.plist @@ -2132,9 +2132,7 @@ dngb_ballotx.squared name = openTypeHeadFlags; value = ( 0, -1, -3, -4 +1 ); }, { @@ -2158,9 +2156,9 @@ name = openTypeOS2Panose; value = ( 2, 11, -5, -2, -3, +0, +0, +0, 0, 0, 0,