diff --git a/devTools/fonts/Makefile b/devTools/fonts/Makefile
index 6895049b3a9..95cab7a08e6 100644
--- a/devTools/fonts/Makefile
+++ b/devTools/fonts/Makefile
@@ -2,7 +2,7 @@ VENV := .env
PYTHON := $(VENV)/bin/python3
PIP := $(VENV)/bin/pip3
SUBSET := $(VENV)/bin/pyftsubset
-PRETTIER := node ../../node_modules/prettier/bin-prettier.js
+PRETTIER := node ../../node_modules/.bin/prettier
.PHONY: all install report test clean
default: all
@@ -41,7 +41,9 @@ $(PLAYFAIR).tsv:
$(PLAYFAIR): $(PLAYFAIR).tsv
mkdir -p $@
@cat $< | while IFS=$$'\t' read -r url filename; do \
- curl "$$url" -o "$@/$$(basename $$filename)"; \
+ FONT="$@/$$(basename $$filename)"; \
+ curl -# "$$url" -o "$$FONT"; \
+ $(PYTHON) fix-numerals.py "$$FONT"; \
done
PlayfairDisplay-%.woff2: PlayfairDisplay-%.ttf
$(SUBSET) $< --unicodes="*" --flavor=woff2 --layout-features+=$(OT_FEATURES) --name-IDs="*" --output-file="$@"
diff --git a/devTools/fonts/fix-numerals.py b/devTools/fonts/fix-numerals.py
new file mode 100644
index 00000000000..8bd680ed51c
--- /dev/null
+++ b/devTools/fonts/fix-numerals.py
@@ -0,0 +1,72 @@
+#!./env/bin/python3
+"""
+This script performs an in-place modification of the specified font file to insert missing
+character-map entries for superscript and subscript numerals. It's intended to be used on the
+PlayfairDisplay TTFs downloaded from google fonts since they lack those mappings. If invoked with
+the filename "-" it will read from stdin and write the modified font to stdout.
+"""
+from subprocess import run
+from os.path import exists, dirname, abspath
+import sys
+import re
+
+TTX = f'{dirname(abspath(__file__))}/.env/bin/ttx'
+
+# unicode codepoint -> glyph name mappings
+scripts = {
+ # subscripts
+ 0x2080: "zero.subs",
+ 0x2081: "one.subs",
+ 0x2082: "two.subs",
+ 0x2083: "three.subs",
+ 0x2084: "four.subs",
+ 0x2085: "five.subs",
+ 0x2086: "six.subs",
+ 0x2087: "seven.subs",
+ 0x2088: "eight.subs",
+ 0x2089: "nine.subs",
+
+ # superscripts
+ 0x2070: "zero.sups",
+ 0x00B9: "uni00B9", # one
+ 0x00B2: "uni00B2", # two
+ 0x00B3: "uni00B3", # three
+ 0x2074: "four.sups",
+ 0x2075: "five.sups",
+ 0x2076: "six.sups",
+ 0x2077: "seven.sups",
+ 0x2078: "eight.sups",
+ 0x2079: "nine.sups",
+}
+
+def update_cmap(path):
+ pipe_input = sys.stdin.buffer.read() if path=="-" else None
+ if not exists(path) and not pipe_input:
+ print("No such file:", path, file=sys.stderr)
+ sys.exit(1)
+
+ # decompile the TTF
+ print(f"Updating character tables in {path}...", end=' ', flush=True, file=sys.stderr)
+ ttx_orig = run([TTX, '-o', '-', path], capture_output=True, input=pipe_input).stdout.decode('utf-8')
+
+ # bail out if this font has already been modified
+ for m in re.findall(r'', ttx_orig, re.DOTALL):
+ if 'zero.subs' in m:
+ print("(already contains super/subscript definitions)", file=sys.stderr)
+ sys.exit(0)
+
+ # add missing definitions to all cmap tables in the font
+ cmap_additions = "".join([
+ f'' for uni, name in scripts.items()
+ ])
+ ttx_modified = re.sub(r'()', cmap_additions + r'\1', ttx_orig).encode('utf-8')
+
+ # compile the updated font and overwrite the existing file
+ run([TTX, '-q', '-o', path, '-'], input=ttx_modified)
+ print("(done)", file=sys.stderr)
+
+if __name__ == "__main__":
+ try:
+ update_cmap(*sys.argv[1:2])
+ except TypeError:
+ print("Usage: fix-numerals.py ")
diff --git a/devTools/fonts/test.js b/devTools/fonts/test.js
index c7ec055df47..b7b71080494 100644
--- a/devTools/fonts/test.js
+++ b/devTools/fonts/test.js
@@ -31,6 +31,8 @@ const FAMILIES = {
}
const SAMPLE_TEXT =
+ // `x0x1x2x3x4x5x6x7x8x9x0x1x2x3x4x5x6x7x8x9`
+ // `x⁰x¹x²x³x⁴x⁵x⁶x⁷x⁸x⁹x₀x₁x₂x₃x₄x₅x₆x₇x₈x₉`
"hamburgefonstiv 0123456789 ←↑→↓↔↕↖↗↘↙"
function pangram(family, postscriptNames = false) {
diff --git a/public/fonts/PlayfairDisplay-Black.woff2 b/public/fonts/PlayfairDisplay-Black.woff2
index 35f440cd761..be443c1643a 100644
Binary files a/public/fonts/PlayfairDisplay-Black.woff2 and b/public/fonts/PlayfairDisplay-Black.woff2 differ
diff --git a/public/fonts/PlayfairDisplay-BlackItalic.woff2 b/public/fonts/PlayfairDisplay-BlackItalic.woff2
index 22cdec5df32..2beeed16125 100644
Binary files a/public/fonts/PlayfairDisplay-BlackItalic.woff2 and b/public/fonts/PlayfairDisplay-BlackItalic.woff2 differ
diff --git a/public/fonts/PlayfairDisplay-Bold.woff2 b/public/fonts/PlayfairDisplay-Bold.woff2
index da4892102b7..e4c6d24f66f 100644
Binary files a/public/fonts/PlayfairDisplay-Bold.woff2 and b/public/fonts/PlayfairDisplay-Bold.woff2 differ
diff --git a/public/fonts/PlayfairDisplay-BoldItalic.woff2 b/public/fonts/PlayfairDisplay-BoldItalic.woff2
index 8fdcec9011f..9f2a18053eb 100644
Binary files a/public/fonts/PlayfairDisplay-BoldItalic.woff2 and b/public/fonts/PlayfairDisplay-BoldItalic.woff2 differ
diff --git a/public/fonts/PlayfairDisplay-ExtraBold.woff2 b/public/fonts/PlayfairDisplay-ExtraBold.woff2
index 2f078f18abd..0a64d5ec283 100644
Binary files a/public/fonts/PlayfairDisplay-ExtraBold.woff2 and b/public/fonts/PlayfairDisplay-ExtraBold.woff2 differ
diff --git a/public/fonts/PlayfairDisplay-ExtraBoldItalic.woff2 b/public/fonts/PlayfairDisplay-ExtraBoldItalic.woff2
index 6f8e12907c1..75888ab050b 100644
Binary files a/public/fonts/PlayfairDisplay-ExtraBoldItalic.woff2 and b/public/fonts/PlayfairDisplay-ExtraBoldItalic.woff2 differ
diff --git a/public/fonts/PlayfairDisplay-Italic.woff2 b/public/fonts/PlayfairDisplay-Italic.woff2
index 5daba923943..2d33d81f56a 100644
Binary files a/public/fonts/PlayfairDisplay-Italic.woff2 and b/public/fonts/PlayfairDisplay-Italic.woff2 differ
diff --git a/public/fonts/PlayfairDisplay-Medium.woff2 b/public/fonts/PlayfairDisplay-Medium.woff2
index 363ace25ad8..13094f287dd 100644
Binary files a/public/fonts/PlayfairDisplay-Medium.woff2 and b/public/fonts/PlayfairDisplay-Medium.woff2 differ
diff --git a/public/fonts/PlayfairDisplay-MediumItalic.woff2 b/public/fonts/PlayfairDisplay-MediumItalic.woff2
index 664cd69e0b8..508168e2d5d 100644
Binary files a/public/fonts/PlayfairDisplay-MediumItalic.woff2 and b/public/fonts/PlayfairDisplay-MediumItalic.woff2 differ
diff --git a/public/fonts/PlayfairDisplay-Regular.woff2 b/public/fonts/PlayfairDisplay-Regular.woff2
index c0ed73b3da1..d5f7498567c 100644
Binary files a/public/fonts/PlayfairDisplay-Regular.woff2 and b/public/fonts/PlayfairDisplay-Regular.woff2 differ
diff --git a/public/fonts/PlayfairDisplay-SemiBold.woff2 b/public/fonts/PlayfairDisplay-SemiBold.woff2
index c3e6f580c98..cf93fed98e2 100644
Binary files a/public/fonts/PlayfairDisplay-SemiBold.woff2 and b/public/fonts/PlayfairDisplay-SemiBold.woff2 differ
diff --git a/public/fonts/PlayfairDisplay-SemiBoldItalic.woff2 b/public/fonts/PlayfairDisplay-SemiBoldItalic.woff2
index 92b259da3a3..24ec800b07a 100644
Binary files a/public/fonts/PlayfairDisplay-SemiBoldItalic.woff2 and b/public/fonts/PlayfairDisplay-SemiBoldItalic.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-Black.woff2 b/public/fonts/PlayfairDisplayLatin-Black.woff2
index fa1e1d861ab..34b5cb23e6e 100644
Binary files a/public/fonts/PlayfairDisplayLatin-Black.woff2 and b/public/fonts/PlayfairDisplayLatin-Black.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-BlackItalic.woff2 b/public/fonts/PlayfairDisplayLatin-BlackItalic.woff2
index 8a352f4a013..c446d4feaed 100644
Binary files a/public/fonts/PlayfairDisplayLatin-BlackItalic.woff2 and b/public/fonts/PlayfairDisplayLatin-BlackItalic.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-Bold.woff2 b/public/fonts/PlayfairDisplayLatin-Bold.woff2
index e8101099507..251cc5a0bc8 100644
Binary files a/public/fonts/PlayfairDisplayLatin-Bold.woff2 and b/public/fonts/PlayfairDisplayLatin-Bold.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-BoldItalic.woff2 b/public/fonts/PlayfairDisplayLatin-BoldItalic.woff2
index 54fb1ea32b3..957898bb288 100644
Binary files a/public/fonts/PlayfairDisplayLatin-BoldItalic.woff2 and b/public/fonts/PlayfairDisplayLatin-BoldItalic.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-ExtraBold.woff2 b/public/fonts/PlayfairDisplayLatin-ExtraBold.woff2
index a9d3e2ec660..c81829a074f 100644
Binary files a/public/fonts/PlayfairDisplayLatin-ExtraBold.woff2 and b/public/fonts/PlayfairDisplayLatin-ExtraBold.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-ExtraBoldItalic.woff2 b/public/fonts/PlayfairDisplayLatin-ExtraBoldItalic.woff2
index 34cee4ca7f5..b57e000a861 100644
Binary files a/public/fonts/PlayfairDisplayLatin-ExtraBoldItalic.woff2 and b/public/fonts/PlayfairDisplayLatin-ExtraBoldItalic.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-Italic.woff2 b/public/fonts/PlayfairDisplayLatin-Italic.woff2
index 7ff7a1966b1..7f9b727d7b8 100644
Binary files a/public/fonts/PlayfairDisplayLatin-Italic.woff2 and b/public/fonts/PlayfairDisplayLatin-Italic.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-Medium.woff2 b/public/fonts/PlayfairDisplayLatin-Medium.woff2
index bfeec215284..af42cdde47b 100644
Binary files a/public/fonts/PlayfairDisplayLatin-Medium.woff2 and b/public/fonts/PlayfairDisplayLatin-Medium.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-MediumItalic.woff2 b/public/fonts/PlayfairDisplayLatin-MediumItalic.woff2
index e8b21993523..e2624770d5e 100644
Binary files a/public/fonts/PlayfairDisplayLatin-MediumItalic.woff2 and b/public/fonts/PlayfairDisplayLatin-MediumItalic.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-Regular.woff2 b/public/fonts/PlayfairDisplayLatin-Regular.woff2
index 57eba90fd92..76de4f5cade 100644
Binary files a/public/fonts/PlayfairDisplayLatin-Regular.woff2 and b/public/fonts/PlayfairDisplayLatin-Regular.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-SemiBold.woff2 b/public/fonts/PlayfairDisplayLatin-SemiBold.woff2
index ebbe71984a0..6edd4fe26b8 100644
Binary files a/public/fonts/PlayfairDisplayLatin-SemiBold.woff2 and b/public/fonts/PlayfairDisplayLatin-SemiBold.woff2 differ
diff --git a/public/fonts/PlayfairDisplayLatin-SemiBoldItalic.woff2 b/public/fonts/PlayfairDisplayLatin-SemiBoldItalic.woff2
index 05ac6f7fb82..6bccefe0401 100644
Binary files a/public/fonts/PlayfairDisplayLatin-SemiBoldItalic.woff2 and b/public/fonts/PlayfairDisplayLatin-SemiBoldItalic.woff2 differ