fonts.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { Figtree, Fraunces, Noto_Serif_SC } from "next/font/google";
  2. import localFont from "next/font/local";
  3. /**
  4. * Text and interface: SF Pro on Apple devices (nothing to download), Figtree,
  5. * a friendly geometric sans, everywhere else. Not preloaded, so Apple devices
  6. * never fetch it.
  7. */
  8. export const fontText = Figtree({
  9. subsets: ["latin"],
  10. variable: "--ff-text",
  11. display: "swap",
  12. preload: false,
  13. });
  14. /**
  15. * Display: Fraunces, a soft variable serif. Its SOFT axis rounds the letters,
  16. * so the headline can melt like liquid under the cursor, and its optical-size
  17. * axis draws each size as designed: crisp, high-contrast cuts for the big
  18. * headline, sturdier ones for card titles. (Without it every size is drawn
  19. * from the 9 pt master.) About 120 KB, fetched after the first paint.
  20. */
  21. export const fontDisplay = Fraunces({
  22. subsets: ["latin"],
  23. axes: ["SOFT", "opsz"],
  24. variable: "--ff-display",
  25. display: "swap",
  26. // Loaded after the first paint by <FontLoader />.
  27. preload: false,
  28. });
  29. /**
  30. * Chinese display: Noto Serif SC (思源宋体), the Han companion to Fraunces in
  31. * headings. Google cuts it into about a hundred slices by unicode-range, so a
  32. * page downloads only the slices holding the characters it shows; English
  33. * pages show none and download nothing. Chinese body text uses the system's
  34. * sans (see --font-sans).
  35. */
  36. export const fontDisplayZh = Noto_Serif_SC({
  37. weight: "600",
  38. variable: "--ff-display-zh",
  39. display: "swap",
  40. preload: false,
  41. adjustFontFallback: false,
  42. });
  43. /** Italic Fraunces cut to the four glyphs of the original headline name. The
  44. * hero name is now Han, so this only remains as a Latin fallback in --font-name. */
  45. export const fontName = localFont({
  46. src: "../assets/fonts/fraunces-italic-eric.woff2",
  47. style: "italic",
  48. weight: "100 900",
  49. variable: "--ff-name",
  50. display: "swap",
  51. preload: false,
  52. adjustFontFallback: "Times New Roman",
  53. });
  54. /** What <FontLoader /> asks the browser to load once the page has painted. */
  55. export const deferredFaces = [
  56. `600 1em ${fontDisplay.style.fontFamily.split(",")[0]}`,
  57. `italic 600 1em ${fontName.style.fontFamily.split(",")[0]}`,
  58. ];