diff --git a/index.html b/index.html
index 1f0d6e5..561f9ae 100644
--- a/index.html
+++ b/index.html
@@ -9,6 +9,8 @@
first render, instead of swapping in afterwards and shifting the layout -->
+
+
diff --git a/src/components/header/Header.css b/src/components/header/Header.css
index a64d399..6b7adb1 100644
--- a/src/components/header/Header.css
+++ b/src/components/header/Header.css
@@ -10,6 +10,12 @@
text-align: center;
}
+/* The home page name stays on one line, so swapping in Kay Pho Du can't change its
+ height (src/fonts.css). Extension titles (.md-text) are long and must wrap. */
+.name:not(.md-text) {
+ white-space: nowrap;
+}
+
.App-header h1 {
font-size: 4rem;
}
@@ -30,7 +36,7 @@
@media screen and (max-width: 768px) {
.App-header h1 {
- font-size: 3rem;
+ font-size: min(3rem, 14vw);
}
.profile-picture {
width: 145px;
diff --git a/src/fonts.css b/src/fonts.css
new file mode 100644
index 0000000..59b81b9
--- /dev/null
+++ b/src/fonts.css
@@ -0,0 +1,46 @@
+/*
+ * The two web fonts, only the subsets the site uses (Latin, plus Latin Extended for
+ * č, š, ž). These replace @fontsource's CSS, which hard-codes font-display: swap.
+ *
+ * The pages are prerendered and paint before the fonts arrive. With swap on Poppins,
+ * lines laid out while it was pending wrapped differently once it settled, and the
+ * header pushed the page down by a line on phones (CLS 0.04–0.08). So:
+ * - Poppins (all body text) is optional: the page never re-lays out text for it.
+ * index.html preloads it, so on Wi-Fi and 4G it's ready in time; on a slow
+ * connection that visit keeps the size-matched "Poppins Fallback" from index.css.
+ * - Kay Pho Du (the name and page titles) stays swap, so the name always ends up in
+ * its own font. The home page name can't wrap (Header.css), so the swap can't
+ * change its line count.
+ */
+@font-face {
+ font-family: "Poppins";
+ font-style: normal;
+ font-display: optional;
+ font-weight: 400;
+ src: url("@fontsource/poppins/files/poppins-latin-400-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;
+}
+@font-face {
+ font-family: "Poppins";
+ font-style: normal;
+ font-display: optional;
+ font-weight: 400;
+ src: url("@fontsource/poppins/files/poppins-latin-ext-400-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;
+}
+@font-face {
+ font-family: "Kay Pho Du";
+ font-style: normal;
+ font-display: swap;
+ font-weight: 700;
+ src: url("@fontsource/kay-pho-du/files/kay-pho-du-latin-700-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;
+}
+@font-face {
+ font-family: "Kay Pho Du";
+ font-style: normal;
+ font-display: swap;
+ font-weight: 700;
+ src: url("@fontsource/kay-pho-du/files/kay-pho-du-latin-ext-700-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;
+}
diff --git a/src/index.tsx b/src/index.tsx
index c69c60c..a659d56 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,7 +1,6 @@
import React from "react";
import { hydrateRoot, createRoot } from "react-dom/client";
-import "@fontsource/kay-pho-du/700.css";
-import "@fontsource/poppins/400.css";
+import "./fonts.css";
import "./index.css";
import "./fontAwesome";
import { BrowserRouter } from "react-router-dom";