fonts.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. /** The italic "Eric" in the headline: Fraunces Italic subset to four glyphs, all axes (6 KB). */
  44. export const fontName = localFont({
  45. src: "../assets/fonts/fraunces-italic-eric.woff2",
  46. style: "italic",
  47. weight: "100 900",
  48. variable: "--ff-name",
  49. display: "swap",
  50. preload: false,
  51. adjustFontFallback: "Times New Roman",
  52. });
  53. /** What <FontLoader /> asks the browser to load once the page has painted. */
  54. export const deferredFaces = [
  55. `600 1em ${fontDisplay.style.fontFamily.split(",")[0]}`,
  56. `italic 600 1em ${fontName.style.fontFamily.split(",")[0]}`,
  57. ];