1
1
mirror of https://github.com/rsms/inter.git synced 2024-09-11 10:55:24 +03:00

Remove "Display" named-instances from variable font

A lot of software gets confused when there are named instances that differ
only by opsz. This change removes all "Display" instances from the fvar table
and makes opsz=32 the default, so that software without automatic opsz-to-size
mapping displays the "Display" styles instead of the text styles by default.
This is the same approach taken by Apple San Francisco Pro.

Closes #519
This commit is contained in:
Rasmus Andersson 2023-05-29 10:05:47 -07:00
parent a2d84eb0ea
commit e12027c4c1
8 changed files with 157 additions and 80 deletions

View File

@ -32,6 +32,9 @@ $(UFODIR)/features:
@ln -s ../../src/features $(UFODIR)/features @ln -s ../../src/features $(UFODIR)/features
# designspace & master UFOs # designspace & master UFOs
$(UFODIR)/%.var.designspace: $(UFODIR)/%.designspace | venv
. $(VENV) ; python misc/tools/gen-var-designspace.py $< $@
$(UFODIR)/%.designspace: $(UFODIR)/%.glyphs $(UFODIR)/features | venv $(UFODIR)/%.designspace: $(UFODIR)/%.glyphs $(UFODIR)/features | venv
. $(VENV) ; fontmake $(FM_ARGS) -o ufo -g $< --designspace-path $@ \ . $(VENV) ; fontmake $(FM_ARGS) -o ufo -g $< --designspace-path $@ \
--master-dir $(UFODIR) --instance-dir $(UFODIR) --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-Roman.glyphs \
$(UFODIR)/Inter-Italic.glyphs \ $(UFODIR)/Inter-Italic.glyphs \
$(UFODIR)/Inter-Roman.designspace \ $(UFODIR)/Inter-Roman.designspace \
$(UFODIR)/Inter-Italic.designspace $(UFODIR)/Inter-Italic.designspace \
$(UFODIR)/Inter-Roman.var.designspace \
$(UFODIR)/Inter-Italic.var.designspace
# --------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------
# products # 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 $(FONTDIR)/static-hinted/%.ttf: $(FONTDIR)/static/%.ttf | $(FONTDIR)/static-hinted venv
. $(VENV) ; python -m ttfautohint --no-info "$<" "$@" . $(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) . $(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) . $(VENV) ; fontmake -o variable-cff2 -m $< --output-path $@ $(FM_ARGS_2)
%.woff2: %.ttf | venv %.woff2: %.ttf | venv
@ -196,7 +201,6 @@ $(FONTDIR)/var/inter-roman-and-italic.stamp: \
$(FONTDIR)/var/_Inter-Roman.var.ttf \ $(FONTDIR)/var/_Inter-Roman.var.ttf \
$(FONTDIR)/var/_Inter-Italic.var.ttf \ $(FONTDIR)/var/_Inter-Italic.var.ttf \
| venv | venv
@#. $(VENV) ; python misc/tools/postprocess-vf2.py $^
mkdir $(FONTDIR)/var/gen-stat mkdir $(FONTDIR)/var/gen-stat
. $(VENV) ; gftools gen-stat --out $(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 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 web: var_web static_web
static: \ static: \
$(FONTDIR)/static/Inter.ttc \ $(FONTDIR)/static/Inter.ttc
$(FONTDIR)/static-hinted/Inter-truetype.ttc
$(FONTDIR)/static/Inter.ttc: \ $(FONTDIR)/static/Inter.otc: \
$(FONTDIR)/static/Inter-Regular.otf \ $(FONTDIR)/static/Inter-Regular.otf \
$(FONTDIR)/static/Inter-Black.otf \ $(FONTDIR)/static/Inter-Black.otf \
$(FONTDIR)/static/Inter-BlackItalic.otf \ $(FONTDIR)/static/Inter-BlackItalic.otf \
@ -269,7 +272,7 @@ $(FONTDIR)/static/Inter.ttc: \
$(FONTDIR)/static/Inter-DisplayExtraBoldItalic.otf $(FONTDIR)/static/Inter-DisplayExtraBoldItalic.otf
. $(VENV) ; python -m fontTools.ttLib.__init__ -o $@ $^ . $(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-Regular.ttf \
$(FONTDIR)/static-hinted/Inter-Black.ttf \ $(FONTDIR)/static-hinted/Inter-Black.ttf \
$(FONTDIR)/static-hinted/Inter-BlackItalic.ttf \ $(FONTDIR)/static-hinted/Inter-BlackItalic.ttf \
@ -499,7 +502,7 @@ static_web_hinted: \
$(FONTDIR)/static-hinted/Inter-DisplayExtraBoldItalic.woff2 $(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: \ .PHONY: \
all var var_web web \ 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.) # - step2 runs tests, then makes a zip archive and updates the website (docs/ dir.)
DIST_ZIP = build/release/Inter-${VERSION}.zip DIST_ZIP = build/release/Inter-${VERSION}.zip
DIST_ZIP_EXTRAS = build/release/Inter-${VERSION}-extras.zip
dist: dist_preflight dist: dist_preflight
@# rebuild since font version & ID is based on git hash @# rebuild since font version & ID is based on git hash
@ -599,6 +603,7 @@ dist_step2: test
dist_zip: | venv dist_zip: | venv
. $(VENV) ; python misc/tools/patch-version.py misc/dist/inter.css . $(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)" bash misc/makezip2.sh -reveal-in-finder "$(DIST_ZIP)"
dist_docs: dist_docs:
@ -628,7 +633,7 @@ dist_postflight:
INSTALLDIR := $(HOME)/Library/Fonts/Inter INSTALLDIR := $(HOME)/Library/Fonts/Inter
install: install_var $(INSTALLDIR)/Inter.ttc install: install_var $(INSTALLDIR)/Inter.ttc
@# Remove any old pre ttc fonts @# Remove any old pre-ttc fonts
rm -rf $(INSTALLDIR)/Inter*.otf rm -rf $(INSTALLDIR)/Inter*.otf
install_var: \ install_var: \
@ -638,6 +643,9 @@ install_var: \
$(INSTALLDIR)/%.ttc: $(FONTDIR)/static/%.ttc | $(INSTALLDIR) $(INSTALLDIR)/%.ttc: $(FONTDIR)/static/%.ttc | $(INSTALLDIR)
cp -a $^ $@ cp -a $^ $@
$(INSTALLDIR)/%.otc: $(FONTDIR)/static/%.ttc | $(INSTALLDIR)
cp -a $^ $@
$(INSTALLDIR)/%.otf: $(FONTDIR)/static/%.otf | $(INSTALLDIR) $(INSTALLDIR)/%.otf: $(FONTDIR)/static/%.otf | $(INSTALLDIR)
cp -a $^ $@ cp -a $^ $@

39
misc/dist/help.txt vendored
View File

@ -6,14 +6,13 @@ Contents:
1.2. Installing on Microsoft Windows 1.2. Installing on Microsoft Windows
1.3. Installing on Ubuntu Linux 1.3. Installing on Ubuntu Linux
2. Using Inter in Web content 2. Using Inter in Web content
3. Hinted TrueType fonts (Inter TrueType.ttc) 3. Hinted TrueType fonts
4. Extras 4. Extras
5. License (can I use Inter for x?) 5. License (can I use Inter for x?)
File index: File index:
Inter.ttc Complete font family (CFF1) Inter.ttc Complete font family "Inter"
Inter Variable*.ttf Complete font family (Variable TrueType) Inter Variable*.ttf Complete font family "Inter Variable"
Inter TrueType.ttc Complete font family (TrueType, with TT hints)
Web/* Web fonts and CSS Web/* Web fonts and CSS
--------------------------------------------------------------------- ---------------------------------------------------------------------
@ -21,7 +20,7 @@ File index:
1. Installing font files 1. Installing font files
Inter fonts comes in two flavors: 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 Variable fonts allow you to choose any weight and optical size in
supported software. Variable fonts is a relatively recent new supported software. Variable fonts is a relatively recent new
@ -42,7 +41,8 @@ File index:
1. Open the "Font Book" application. 1. Open the "Font Book" application.
2. In the main menu, select "File" → "Add Fonts..." 2. In the main menu, select "File" → "Add Fonts..."
3. Select "Inter.ttc", "Inter Variable.ttf" and 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 Alternatively, if you prefer not to use Font Book, you can move or
copy the font files directly into ~/Library/Fonts/ copy the font files directly into ~/Library/Fonts/
@ -51,7 +51,7 @@ File index:
1.2. Installing on Microsoft Windows 1.2. Installing on Microsoft Windows
1. Open the zip file you downloaded 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" "Inter Variable Italic.ttf"
3. Right-click the selected files, choose "Install for all users" 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 "Inter Variable Italic.ttf" into your .fonts directory
(cp Inter.ttc *.ttf ~/.fonts/) (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. 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 This distribution contains TrueType fonts with hints in "Inter.ttc"
needed by ClearType) in a separate font bundle "Inter TrueType.ttc"
Microsoft Windows uses a technology called ClearType which alters Microsoft Windows uses a technology called ClearType which alters
the shape of letters to increase sharpness, in particular for low- the shape of letters to increase sharpness, in particular for low-
density displays. This requires a font to have little programs density displays. This requires a font to have little programs
built into them, called TrueType hinting instructions, which lets built into them, called TrueType hinting instructions, which lets
ClearType knows how to alter each character. 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, The variable font is currently not available with TrueType hints,
only the traditional "static" font files are. This will hopefully only the traditional "static" font files are. This will hopefully
change in a future release. change in a future release.
Important: DO NOT INSTALL BOTH VERSIONS! Note that the web fonts does not contain hints to minimize file
size. You can get hinted web fonts from the "extras" distribution.
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"
--------------------------------------------------------------------- ---------------------------------------------------------------------

15
misc/dist/inter.css vendored
View File

@ -8,20 +8,20 @@
font-weight: 100 900; font-weight: 100 900;
font-display: swap; font-display: swap;
font-style: normal; font-style: normal;
src: url("Inter.var.woff2?v=3.19") format("woff2-variations"), src: url("InterVariable.woff2?v=3.19") format("woff2-variations"),
url("Inter.var.woff2?v=3.19") format("woff2"); url("InterVariable.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") tech("variations");
} }
@font-face { @font-face {
font-family: "InterVar"; font-family: "InterVar";
font-weight: 100 900; font-weight: 100 900;
font-display: swap; font-display: swap;
font-style: italic; font-style: italic;
src: url("Inter-Italic.var.woff2?v=3.19") format("woff2-variations"), src: url("InterVariable-Italic.woff2?v=3.19") format("woff2-variations"),
url("Inter-Italic.var.woff2?v=3.19") format("woff2"); url("InterVariable-Italic.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") 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: 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: 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"); } @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: 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: 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"); } @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: 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: 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"); } @font-face { font-family: "InterDisplay"; font-style: normal; font-weight: 200; font-display: swap; src: url("Inter-DisplayExtraLight.woff2?v=3.19") format("woff2"); }

View File

@ -54,29 +54,32 @@ mkdir -p "$(dirname "$OUTFILE_ABS")" "$ZIPDIR"
cp LICENSE.txt "$ZIPDIR/LICENSE.txt" cp LICENSE.txt "$ZIPDIR/LICENSE.txt"
if $OPT_EXTRAS; then 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 misc/dist/extras-readme.txt "$ZIPDIR/README.txt"
cp build/fonts/static/Inter-*.otf "$ZIPDIR/OTF/" & cp build/fonts/static/Inter-*.otf "$ZIPDIR/OTF/" &
cp build/fonts/static-hinted/Inter-*.ttf "$ZIPDIR/TTF/" & cp build/fonts/static-hinted/Inter-*.ttf "$ZIPDIR/TTF/" &
cp build/fonts/static-hinted/Inter-*.woff2 "$ZIPDIR/Web with TrueType hints/" &
else else
mkdir -p "$ZIPDIR/Web" mkdir -p "$ZIPDIR/Web"
cp misc/dist/help.txt "$ZIPDIR/help.txt" cp misc/dist/help.txt "$ZIPDIR/help.txt"
cp build/fonts/static/Inter.ttc "$ZIPDIR/Inter.ttc" 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.var.ttf "$ZIPDIR/Inter Variable.ttf" cp build/fonts/var/InterV-Italic.var.ttf "$ZIPDIR/Inter Variable Italic.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/venv/bin/activate
build/fonts/var/Inter.var.woff2 \ python misc/tools/patch-version.py "$ZIPDIR/Web/inter.css"
build/fonts/var/Inter-Italic.var.woff2 \
misc/dist/inter.css "$ZIPDIR/Web/" &
fi fi
mkdir -p "$(dirname "$OUTFILE_ABS")" mkdir -p "$(dirname "$OUTFILE_ABS")"
wait wait
rm -rf "$OUTFILE_ABS"
pushd "$ZIPDIR" >/dev/null pushd "$ZIPDIR" >/dev/null
zip -q -X -r "$OUTFILE_ABS" * zip -q -X -r "$OUTFILE_ABS" *
popd >/dev/null popd >/dev/null

View File

@ -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._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.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 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.world import world, RFont, RGlyph, OpenFont, NewFont
# from robofab.objects.objectsRF import RFont, RGlyph, OpenFont, NewFont, RContour # from robofab.objects.objectsRF import RFont, RGlyph, OpenFont, NewFont, RContour
@ -296,7 +297,10 @@ def genFontInfo(fontpath, outputType, withGlyphs=True):
version = v[0] version = v[0]
if version.lower() == 'version': if version.lower() == 'version':
version = v[1] 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 info['version'] = version
if outputType is not OUTPUT_TYPE_GLYPHLIST: 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 & 0b0000000000001000: s.append('3: OUTLINED')
if fsSelection & 0b0000000000010000: s.append('4: STRIKEOUT') if fsSelection & 0b0000000000010000: s.append('4: STRIKEOUT')
if fsSelection & 0b0000000000100000: s.append('5: BOLD') if fsSelection & 0b0000000000100000: s.append('5: BOLD')
if fsSelection & 0b0000000010000000: s.append('6: REGULAR') if fsSelection & 0b0000000001000000: s.append('6: REGULAR')
if fsSelection & 0b0000000100000000: s.append('7: USE_TYPO_METRICS') if fsSelection & 0b0000000010000000: s.append('7: USE_TYPO_METRICS')
if fsSelection & 0b0000001000000000: s.append('8: WWS') if fsSelection & 0b0000000100000000: s.append('8: WWS')
if fsSelection & 0b0000010000000000: s.append('9: OBLIQUE') if fsSelection & 0b0000001000000000: s.append('9: OBLIQUE')
os2['fsSelection_raw'] = fsSelection os2['fsSelection_raw'] = bin(fsSelection)
os2['fsSelection'] = s os2['fsSelection'] = s
@ -464,9 +468,25 @@ def genFontInfo(fontpath, outputType, withGlyphs=True):
v.decode('utf8') v.decode('utf8')
meta[k] = v meta[k] = v
except: except:
meta[k] = 'data:;base64,' + b64encode(v) meta[k] = 'data:;base64,' + b64encode(v).decode('ascii')
info['meta'] = meta 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 # rest of tables
for tname in tt.keys(): for tname in tt.keys():
if tname not in info: if tname not in info:

View File

@ -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)

View File

@ -2132,9 +2132,7 @@ dngb_ballotx.squared
name = openTypeHeadFlags; name = openTypeHeadFlags;
value = ( value = (
0, 0,
1, 1
3,
4
); );
}, },
{ {
@ -2158,9 +2156,9 @@ name = openTypeOS2Panose;
value = ( value = (
2, 2,
11, 11,
5, 0,
2, 0,
3, 0,
0, 0,
0, 0,
0, 0,
@ -2233,7 +2231,7 @@ value = 0;
}, },
{ {
name = "Variable Font Origin"; name = "Variable Font Origin";
value = "C698F293-3EC0-4A5A-A3A0-0FDB1F5CF265"; value = "11F4534A-B963-4AB5-820F-DAF9A20CD933";
}, },
{ {
name = "Use Typo Metrics"; name = "Use Typo Metrics";
@ -2241,7 +2239,7 @@ value = 1;
}, },
{ {
name = "Get Hints From Master"; 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"; date = "2016-12-04 18:21:54 +0000";

View File

@ -2132,9 +2132,7 @@ dngb_ballotx.squared
name = openTypeHeadFlags; name = openTypeHeadFlags;
value = ( value = (
0, 0,
1, 1
3,
4
); );
}, },
{ {
@ -2158,9 +2156,9 @@ name = openTypeOS2Panose;
value = ( value = (
2, 2,
11, 11,
5, 0,
2, 0,
3, 0,
0, 0,
0, 0,
0, 0,