summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2023-06-08 20:10:47 +0300
committerRasmus Andersson <rasmus@notion.se>2023-06-08 20:10:47 +0300
commitd88ab4204a4fc8af6e04913274be1907d7f29248 (patch)
tree64097fb6dde83ff1cb077d4ce294a4591cfe9b26
parent9e6dd3d7fb7793e2194483064d2488ea44ca1893 (diff)
downloadinter-d88ab4204a4fc8af6e04913274be1907d7f29248.tar.xz
fixes name table entries for static files, re issue #519
-rw-r--r--Makefile1
-rw-r--r--misc/tools/fix-static-display-names.py7
-rw-r--r--misc/tools/postprocess_instance_ufo.py23
-rw-r--r--src/Inter-Italic.glyphspackage/fontinfo.plist2
-rw-r--r--src/Inter-Roman.glyphspackage/fontinfo.plist7
5 files changed, 35 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index b9287a360..45f49ce37 100644
--- a/Makefile
+++ b/Makefile
@@ -170,7 +170,6 @@ $(FONTDIR)/static/%.otf: $(UFODIR)/%.ufo build/features_data | $(FONTDIR)/static
$(FONTDIR)/static/InterDisplay-%.ttf: $(UFODIR)/InterDisplay-%.ufo build/features_data | $(FONTDIR)/static venv
. $(VENV) ; fontmake -u $< -o ttf --output-path $@ $(FM_ARGS_2)
- . $(VENV) ; python misc/tools/fix-static-display-names.py $@
$(FONTDIR)/static/%.ttf: $(UFODIR)/%.ufo build/features_data | $(FONTDIR)/static venv
. $(VENV) ; fontmake -u $< -o ttf --output-path $@ $(FM_ARGS_2)
diff --git a/misc/tools/fix-static-display-names.py b/misc/tools/fix-static-display-names.py
index 5df05b6b2..33789c47f 100644
--- a/misc/tools/fix-static-display-names.py
+++ b/misc/tools/fix-static-display-names.py
@@ -81,6 +81,7 @@ def main():
family = "Inter Display"
style = remove_substring(getStyleName(font), "Display")
+ isItalic = style.find('Italic') != -1
if style == '':
style = 'Regular'
@@ -110,14 +111,16 @@ def main():
id[3] = fullNamePs
rec.string = ";".join(id)
elif id == LEGACY_FAMILY: # ID 1
- rec.string = family
+ rec.string = family + ' ' + style
+ elif id == SUBFAMILY_NAME: # ID 2
+ rec.string = 'Italic' if isItalic else 'Regular'
elif id == PREFERRED_FAMILY: # ID 16
rec.string = family
elif id == WWS_FAMILY: # ID 21
rec.string = family
elif id == WWS_SUBFAMILY: # ID 22
rec.string = style
- elif id in (SUBFAMILY_NAME, TYPO_SUBFAMILY_NAME): # ID 2, ID 17
+ elif id == TYPO_SUBFAMILY_NAME: # ID 17
rec.string = style
# print("————————————————————————————————————————————————————")
diff --git a/misc/tools/postprocess_instance_ufo.py b/misc/tools/postprocess_instance_ufo.py
index b391503e9..8c2c5c528 100644
--- a/misc/tools/postprocess_instance_ufo.py
+++ b/misc/tools/postprocess_instance_ufo.py
@@ -1,7 +1,14 @@
-import sys
+import sys, re
import defcon
+WHITESPACE_RE = re.compile(r'\s+')
+
+
+def rmspace(s):
+ return WHITESPACE_RE.sub('', s)
+
+
# See https://github.com/rsms/inter/issues/508
# TODO: Remove when https://github.com/googlefonts/glyphsLib/issues/821 is fixed
def fix_fractional_advance_width(ufo):
@@ -19,6 +26,20 @@ def main(argv):
ufo_file = argv[1]
ufo = defcon.Font(ufo_file)
fix_fractional_advance_width(ufo)
+
+ # fix legacy names to make style linking work in MS Windows
+ familyName = ufo.info.familyName # e.g. "Inter Display"
+ styleName = ufo.info.styleName # e.g. "ExtraBold"
+ ufo.info.openTypeNamePreferredFamilyName = familyName
+ ufo.info.openTypeNamePreferredSubfamilyName = styleName
+
+ ufo.info.familyName = familyName + ' ' + styleName
+ ufo.info.styleName = 'Regular' if styleName.find('Italic') == -1 else 'Italic'
+
+ # must also set these explicitly to avoid PostScript names like "Inter-ThinRegular":
+ # "postscriptFontName" maps to name ID 6 "postscriptName"
+ ufo.info.postscriptFontName = rmspace(familyName) + '-' + rmspace(styleName)
+
ufo.save(ufo_file)
diff --git a/src/Inter-Italic.glyphspackage/fontinfo.plist b/src/Inter-Italic.glyphspackage/fontinfo.plist
index 01e77778f..b29217a5d 100644
--- a/src/Inter-Italic.glyphspackage/fontinfo.plist
+++ b/src/Inter-Italic.glyphspackage/fontinfo.plist
@@ -4040,6 +4040,7 @@ instanceInterpolations = {
};
isBold = 1;
isItalic = 1;
+linkStyle = Regular;
name = "Bold Italic";
weightClass = 700;
},
@@ -4511,6 +4512,7 @@ m010 = 0.52;
};
isBold = 1;
isItalic = 1;
+linkStyle = Regular;
name = "Bold Italic";
properties = (
{
diff --git a/src/Inter-Roman.glyphspackage/fontinfo.plist b/src/Inter-Roman.glyphspackage/fontinfo.plist
index f748f516b..795637a56 100644
--- a/src/Inter-Roman.glyphspackage/fontinfo.plist
+++ b/src/Inter-Roman.glyphspackage/fontinfo.plist
@@ -3987,6 +3987,7 @@ instanceInterpolations = {
"C698F293-3EC0-4A5A-A3A0-0FDB1F5CF265" = 0.48;
};
isBold = 1;
+linkStyle = Regular;
name = Bold;
weightClass = 700;
},
@@ -4407,7 +4408,7 @@ m007 = 0.48;
m009 = 0.52;
};
isBold = 1;
-linkStyle = Display;
+linkStyle = Regular;
name = Bold;
properties = (
{
@@ -4460,6 +4461,8 @@ instanceInterpolations = {
m007 = 0.24;
m009 = 0.76;
};
+isBold = 1;
+linkStyle = Medium;
name = ExtraBold;
properties = (
{
@@ -4511,6 +4514,8 @@ value = 0;
instanceInterpolations = {
m009 = 1;
};
+isBold = 1;
+linkStyle = SemiBold;
name = Black;
properties = (
{