diff --git a/assets/css/fonts/Inter.css b/assets/css/fonts/Inter.css index c308cb83c..23ffedf8f 100644 --- a/assets/css/fonts/Inter.css +++ b/assets/css/fonts/Inter.css @@ -2,167 +2,62 @@ @font-face { font-family: 'Inter'; font-style: normal; - font-weight: 300; - src: url(../../fonts/Inter-cyrillic-ext-normal-300.woff2); - unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; + font-weight: 100 900; + font-display: swap; + src: local('Inter'), url(../../fonts/Inter-cyrillic-ext-normal.woff2) format('woff2'); + unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; } /* cyrillic */ @font-face { font-family: 'Inter'; font-style: normal; - font-weight: 300; - src: url(../../fonts/Inter-cyrillic-normal-300.woff2); - unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; + font-weight: 100 900; + font-display: swap; + src: local('Inter'), url(../../fonts/Inter-cyrillic-normal.woff2) format('woff2'); + unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; } /* greek-ext */ @font-face { font-family: 'Inter'; font-style: normal; - font-weight: 300; - src: url(../../fonts/Inter-greek-ext-normal-300.woff2); + font-weight: 100 900; + font-display: swap; + src: local('Inter'), url(../../fonts/Inter-greek-ext-normal.woff2) format('woff2'); unicode-range: U+1F00-1FFF; } /* greek */ @font-face { font-family: 'Inter'; font-style: normal; - font-weight: 300; - src: url(../../fonts/Inter-greek-normal-300.woff2); - unicode-range: U+0370-03FF; + font-weight: 100 900; + font-display: swap; + src: local('Inter'), url(../../fonts/Inter-greek-normal.woff2) format('woff2'); + unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; } /* vietnamese */ @font-face { font-family: 'Inter'; font-style: normal; - font-weight: 300; - src: url(../../fonts/Inter-vietnamese-normal-300.woff2); - unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB; + font-weight: 100 900; + font-display: swap; + src: local('Inter'), url(../../fonts/Inter-vietnamese-normal.woff2) format('woff2'); + unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; } /* latin-ext */ @font-face { font-family: 'Inter'; font-style: normal; - font-weight: 300; - src: url(../../fonts/Inter-latin-ext-normal-300.woff2); - unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; + font-weight: 100 900; + font-display: swap; + src: local('Inter'), url(../../fonts/Inter-latin-ext-normal.woff2) format('woff2'); + unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; } /* latin */ @font-face { font-family: 'Inter'; font-style: normal; - font-weight: 300; - src: url(../../fonts/Inter-latin-normal-300.woff2); - unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; -} -/* cyrillic-ext */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 400; - src: url(../../fonts/Inter-cyrillic-ext-normal-400.woff2); - unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; -} -/* cyrillic */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 400; - src: url(../../fonts/Inter-cyrillic-normal-400.woff2); - unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; -} -/* greek-ext */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 400; - src: url(../../fonts/Inter-greek-ext-normal-400.woff2); - unicode-range: U+1F00-1FFF; -} -/* greek */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 400; - src: url(../../fonts/Inter-greek-normal-400.woff2); - unicode-range: U+0370-03FF; -} -/* vietnamese */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 400; - src: url(../../fonts/Inter-vietnamese-normal-400.woff2); - unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB; -} -/* latin-ext */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 400; - src: url(../../fonts/Inter-latin-ext-normal-400.woff2); - unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; -} -/* latin */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 400; - src: url(../../fonts/Inter-latin-normal-400.woff2); - unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; -} -/* cyrillic-ext */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 700; - src: url(../../fonts/Inter-cyrillic-ext-normal-700.woff2); - unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; -} -/* cyrillic */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 700; - src: url(../../fonts/Inter-cyrillic-normal-700.woff2); - unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; -} -/* greek-ext */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 700; - src: url(../../fonts/Inter-greek-ext-normal-700.woff2); - unicode-range: U+1F00-1FFF; -} -/* greek */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 700; - src: url(../../fonts/Inter-greek-normal-700.woff2); - unicode-range: U+0370-03FF; -} -/* vietnamese */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 700; - src: url(../../fonts/Inter-vietnamese-normal-700.woff2); - unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB; -} -/* latin-ext */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 700; - src: url(../../fonts/Inter-latin-ext-normal-700.woff2); - unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; -} -/* latin */ -@font-face { - font-family: 'Inter'; - font-style: normal; - font-weight: 700; - src: url(../../fonts/Inter-latin-normal-700.woff2); - unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; + font-weight: 100 900; + font-display: swap; + src: local('Inter'), url(../../fonts/Inter-latin-normal.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; } diff --git a/assets/css/fonts/README.md b/assets/css/fonts/README.md index 8c939e26b..0812404aa 100644 --- a/assets/css/fonts/README.md +++ b/assets/css/fonts/README.md @@ -3,7 +3,7 @@ ## Inter.css `Inter.css` is a local copy of -https://fonts.googleapis.com/css?family=Inter:300,300i,400,400i,700,700i, modified to pull +https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&display=swap, modified to pull font files (`.woff2`) from local sources. It was created using `download_google_fonts_css.py`. @@ -15,9 +15,9 @@ load them. Example call: ```sh python3 download_google_fonts_css.py \ - "https://fonts.googleapis.com/css?family=Inter:300,300i,400,400i,700,700i" \ + "https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&display=swap" \ ../../../static/fonts \ - ../../fonts + ../../fonts ``` Which would pop out a `Inter.css` file that should be `@import url("Inter.css")`d diff --git a/assets/css/fonts/download_google_fonts_css.py b/assets/css/fonts/download_google_fonts_css.py index cfb5c0526..ba4ddcba2 100755 --- a/assets/css/fonts/download_google_fonts_css.py +++ b/assets/css/fonts/download_google_fonts_css.py @@ -84,7 +84,6 @@ font_lang = None font_family = None font_style = None -font_weight = 0 for line in original_contents: # Check if this line contains a font URL match = re.match(r".*url\((.*)\) format.*", line) @@ -96,16 +95,17 @@ resp = requests.get(font_url) if resp.status_code == 200: # Save the font file - filename = "%s-%s-%s-%d.woff2" % ( - font_family, font_lang, font_style, font_weight + filename = "%s-%s-%s.woff2" % ( + font_family, font_lang, font_style ) font_filepath = font_output_dir + filename with open(font_filepath, "wb") as f: print("Writing font file:", font_filepath) f.write(resp.content) - # Replace google URL with local URL - line = re.sub(r"url\(.+\)", f"url({css_font_path + filename})", line) + # Replace google URL with local URL and allow the browser to load the + # local font if it exists. + line = re.sub(r"url\(.+?\)", f"local('{font_family}'), url({css_font_path + filename})", line) else: print("Warning: failed to download font file:", font_url) @@ -121,9 +121,6 @@ font_style_match = re.match(r".*font-style: (.+);$", line) if font_style_match: font_style = font_style_match.group(1) - font_weight_match = re.match(r".*font-weight: (.+);$", line) - if font_weight_match: - font_weight = int(font_weight_match.group(1)) # Append the potentially modified line to the new css file new_css_file_lines.append(line) diff --git a/changelogs/internal/newsfragments/2000.clarification b/changelogs/internal/newsfragments/2000.clarification new file mode 100644 index 000000000..24cf7b81d --- /dev/null +++ b/changelogs/internal/newsfragments/2000.clarification @@ -0,0 +1 @@ +Update the Inter font and allow the browser to render the page before it is loaded \ No newline at end of file diff --git a/static/fonts/Inter-cyrillic-ext-normal-300.woff2 b/static/fonts/Inter-cyrillic-ext-normal-300.woff2 deleted file mode 100644 index 77f8fe74b..000000000 Binary files a/static/fonts/Inter-cyrillic-ext-normal-300.woff2 and /dev/null differ diff --git a/static/fonts/Inter-cyrillic-ext-normal-400.woff2 b/static/fonts/Inter-cyrillic-ext-normal-400.woff2 deleted file mode 100644 index 0a28013d5..000000000 Binary files a/static/fonts/Inter-cyrillic-ext-normal-400.woff2 and /dev/null differ diff --git a/static/fonts/Inter-cyrillic-ext-normal-700.woff2 b/static/fonts/Inter-cyrillic-ext-normal-700.woff2 deleted file mode 100644 index a5658ff76..000000000 Binary files a/static/fonts/Inter-cyrillic-ext-normal-700.woff2 and /dev/null differ diff --git a/static/fonts/Inter-cyrillic-ext-normal.woff2 b/static/fonts/Inter-cyrillic-ext-normal.woff2 new file mode 100644 index 000000000..2f90b7d72 Binary files /dev/null and b/static/fonts/Inter-cyrillic-ext-normal.woff2 differ diff --git a/static/fonts/Inter-cyrillic-normal-300.woff2 b/static/fonts/Inter-cyrillic-normal-300.woff2 deleted file mode 100644 index 9863e9068..000000000 Binary files a/static/fonts/Inter-cyrillic-normal-300.woff2 and /dev/null differ diff --git a/static/fonts/Inter-cyrillic-normal-400.woff2 b/static/fonts/Inter-cyrillic-normal-400.woff2 deleted file mode 100644 index 9b199dff8..000000000 Binary files a/static/fonts/Inter-cyrillic-normal-400.woff2 and /dev/null differ diff --git a/static/fonts/Inter-cyrillic-normal-700.woff2 b/static/fonts/Inter-cyrillic-normal-700.woff2 deleted file mode 100644 index e7c9b5c0b..000000000 Binary files a/static/fonts/Inter-cyrillic-normal-700.woff2 and /dev/null differ diff --git a/static/fonts/Inter-cyrillic-normal.woff2 b/static/fonts/Inter-cyrillic-normal.woff2 new file mode 100644 index 000000000..17ec069d5 Binary files /dev/null and b/static/fonts/Inter-cyrillic-normal.woff2 differ diff --git a/static/fonts/Inter-greek-ext-normal-300.woff2 b/static/fonts/Inter-greek-ext-normal-300.woff2 deleted file mode 100644 index c5040704a..000000000 Binary files a/static/fonts/Inter-greek-ext-normal-300.woff2 and /dev/null differ diff --git a/static/fonts/Inter-greek-ext-normal-400.woff2 b/static/fonts/Inter-greek-ext-normal-400.woff2 deleted file mode 100644 index 2133c2aa0..000000000 Binary files a/static/fonts/Inter-greek-ext-normal-400.woff2 and /dev/null differ diff --git a/static/fonts/Inter-greek-ext-normal-700.woff2 b/static/fonts/Inter-greek-ext-normal-700.woff2 deleted file mode 100644 index 11f082732..000000000 Binary files a/static/fonts/Inter-greek-ext-normal-700.woff2 and /dev/null differ diff --git a/static/fonts/Inter-greek-ext-normal.woff2 b/static/fonts/Inter-greek-ext-normal.woff2 new file mode 100644 index 000000000..e6821c8e4 Binary files /dev/null and b/static/fonts/Inter-greek-ext-normal.woff2 differ diff --git a/static/fonts/Inter-greek-normal-300.woff2 b/static/fonts/Inter-greek-normal-300.woff2 deleted file mode 100644 index e2d53b38e..000000000 Binary files a/static/fonts/Inter-greek-normal-300.woff2 and /dev/null differ diff --git a/static/fonts/Inter-greek-normal-400.woff2 b/static/fonts/Inter-greek-normal-400.woff2 deleted file mode 100644 index 3d2f76d32..000000000 Binary files a/static/fonts/Inter-greek-normal-400.woff2 and /dev/null differ diff --git a/static/fonts/Inter-greek-normal-700.woff2 b/static/fonts/Inter-greek-normal-700.woff2 deleted file mode 100644 index 5b6ed5009..000000000 Binary files a/static/fonts/Inter-greek-normal-700.woff2 and /dev/null differ diff --git a/static/fonts/Inter-greek-normal.woff2 b/static/fonts/Inter-greek-normal.woff2 new file mode 100644 index 000000000..612258dad Binary files /dev/null and b/static/fonts/Inter-greek-normal.woff2 differ diff --git a/static/fonts/Inter-latin-ext-normal-300.woff2 b/static/fonts/Inter-latin-ext-normal-300.woff2 deleted file mode 100644 index bf5bc6474..000000000 Binary files a/static/fonts/Inter-latin-ext-normal-300.woff2 and /dev/null differ diff --git a/static/fonts/Inter-latin-ext-normal-400.woff2 b/static/fonts/Inter-latin-ext-normal-400.woff2 deleted file mode 100644 index ef110cb8c..000000000 Binary files a/static/fonts/Inter-latin-ext-normal-400.woff2 and /dev/null differ diff --git a/static/fonts/Inter-latin-ext-normal-700.woff2 b/static/fonts/Inter-latin-ext-normal-700.woff2 deleted file mode 100644 index b42f8b12a..000000000 Binary files a/static/fonts/Inter-latin-ext-normal-700.woff2 and /dev/null differ diff --git a/static/fonts/Inter-latin-ext-normal.woff2 b/static/fonts/Inter-latin-ext-normal.woff2 new file mode 100644 index 000000000..90ad5f74d Binary files /dev/null and b/static/fonts/Inter-latin-ext-normal.woff2 differ diff --git a/static/fonts/Inter-latin-normal-300.woff2 b/static/fonts/Inter-latin-normal-300.woff2 deleted file mode 100644 index 605d1b2d9..000000000 Binary files a/static/fonts/Inter-latin-normal-300.woff2 and /dev/null differ diff --git a/static/fonts/Inter-latin-normal-400.woff2 b/static/fonts/Inter-latin-normal-400.woff2 deleted file mode 100644 index b5db4467b..000000000 Binary files a/static/fonts/Inter-latin-normal-400.woff2 and /dev/null differ diff --git a/static/fonts/Inter-latin-normal-700.woff2 b/static/fonts/Inter-latin-normal-700.woff2 deleted file mode 100644 index f6215ed24..000000000 Binary files a/static/fonts/Inter-latin-normal-700.woff2 and /dev/null differ diff --git a/static/fonts/Inter-latin-normal.woff2 b/static/fonts/Inter-latin-normal.woff2 new file mode 100644 index 000000000..891fc5cc5 Binary files /dev/null and b/static/fonts/Inter-latin-normal.woff2 differ diff --git a/static/fonts/Inter-vietnamese-normal-300.woff2 b/static/fonts/Inter-vietnamese-normal-300.woff2 deleted file mode 100644 index 707bb8055..000000000 Binary files a/static/fonts/Inter-vietnamese-normal-300.woff2 and /dev/null differ diff --git a/static/fonts/Inter-vietnamese-normal-400.woff2 b/static/fonts/Inter-vietnamese-normal-400.woff2 deleted file mode 100644 index c9fa5c598..000000000 Binary files a/static/fonts/Inter-vietnamese-normal-400.woff2 and /dev/null differ diff --git a/static/fonts/Inter-vietnamese-normal-700.woff2 b/static/fonts/Inter-vietnamese-normal-700.woff2 deleted file mode 100644 index 0dfa08501..000000000 Binary files a/static/fonts/Inter-vietnamese-normal-700.woff2 and /dev/null differ diff --git a/static/fonts/Inter-vietnamese-normal.woff2 b/static/fonts/Inter-vietnamese-normal.woff2 new file mode 100644 index 000000000..79ac1ef3d Binary files /dev/null and b/static/fonts/Inter-vietnamese-normal.woff2 differ