Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Stabilize albums font loading

Anand Baburajanc62a57ff4f4f
diff --git a/web/apps/albums/public/fonts/inter-cyrillic-wght-normal.woff2 b/web/apps/albums/public/fonts/inter-cyrillic-wght-normal.woff2
new file mode 100644
index 0000000000..d750914763
Binary files /dev/null and b/web/apps/albums/public/fonts/inter-cyrillic-wght-normal.woff2 differ
diff --git a/web/apps/albums/public/fonts/inter-greek-wght-normal.woff2 b/web/apps/albums/public/fonts/inter-greek-wght-normal.woff2
new file mode 100644
index 0000000000..024f077032
Binary files /dev/null and b/web/apps/albums/public/fonts/inter-greek-wght-normal.woff2 differ
diff --git a/web/apps/albums/public/fonts/inter-latin-ext-wght-normal.woff2 b/web/apps/albums/public/fonts/inter-latin-ext-wght-normal.woff2
new file mode 100644
index 0000000000..479d010d29
Binary files /dev/null and b/web/apps/albums/public/fonts/inter-latin-ext-wght-normal.woff2 differ
diff --git a/web/apps/albums/public/fonts/inter-latin-wght-normal.woff2 b/web/apps/albums/public/fonts/inter-latin-wght-normal.woff2
new file mode 100644
index 0000000000..d15208de03
Binary files /dev/null and b/web/apps/albums/public/fonts/inter-latin-wght-normal.woff2 differ
diff --git a/web/apps/albums/public/fonts/inter-vietnamese-wght-normal.woff2 b/web/apps/albums/public/fonts/inter-vietnamese-wght-normal.woff2
new file mode 100644
index 0000000000..a40c4699cb
Binary files /dev/null and b/web/apps/albums/public/fonts/inter-vietnamese-wght-normal.woff2 differ
diff --git a/web/apps/albums/src/app/styles/fonts.css b/web/apps/albums/src/app/styles/fonts.css
new file mode 100644
index 0000000000..fc91a7ad3d
--- /dev/null
+++ b/web/apps/albums/src/app/styles/fonts.css
@@ -0,0 +1,57 @@
+@font-face {
+ font-family: "Inter Variable";
+ font-style: normal;
+ font-display: fallback;
+ font-weight: 100 900;
+ src: url("/fonts/inter-cyrillic-wght-normal.woff2")
+ format("woff2-variations");
+ unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
+}
+
+@font-face {
+ font-family: "Inter Variable";
+ font-style: normal;
+ font-display: fallback;
+ font-weight: 100 900;
+ src: url("/fonts/inter-greek-wght-normal.woff2") format("woff2-variations");
+ unicode-range:
+ U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
+}
+
+@font-face {
+ font-family: "Inter Variable";
+ font-style: normal;
+ font-display: fallback;
+ font-weight: 100 900;
+ src: url("/fonts/inter-vietnamese-wght-normal.woff2")
+ format("woff2-variations");
+ 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;
+}
+
+@font-face {
+ font-family: "Inter Variable";
+ font-style: normal;
+ font-display: fallback;
+ font-weight: 100 900;
+ src: url("/fonts/inter-latin-ext-wght-normal.woff2")
+ format("woff2-variations");
+ 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: "Inter Variable";
+ font-style: normal;
+ font-display: fallback;
+ font-weight: 100 900;
+ src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
+ 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/web/apps/albums/src/pages/_app.tsx b/web/apps/albums/src/pages/_app.tsx
index c1bdf55f75..78f7abec7e 100644
--- a/web/apps/albums/src/pages/_app.tsx
+++ b/web/apps/albums/src/pages/_app.tsx
@@ -1,7 +1,7 @@
import { AlbumsAppProviders } from "@/app/providers/AlbumsAppProviders";
-import "@fontsource-variable/inter";
import type { AppProps } from "next/app";
+import "@/app/styles/fonts.css";
import "@/app/styles/global.css";
import "photoswipe/dist/photoswipe.css";
// Keep our PhotoSwipe overrides after the library CSS so the reduced z-index
diff --git a/web/packages/base/components/Head.tsx b/web/packages/base/components/Head.tsx
index 70cc479e69..3317e5c622 100644
--- a/web/packages/base/components/Head.tsx
+++ b/web/packages/base/components/Head.tsx
@@ -12,14 +12,30 @@ interface CustomHeadProps {
title: string;
}
+const AlbumsFontPreloads: React.FC = () => (
+ <>
+ <link
+ rel="preload"
+ href="/fonts/inter-latin-wght-normal.woff2"
+ as="font"
+ type="font/woff2"
+ crossOrigin="anonymous"
+ />
+ </>
+);
+
/**
* A custom version of "next/head" that sets the title, description, favicon and
* some other boilerplate <head> tags.
*
* This assumes the existence of `public/images/favicon.png`.
*/
-export const CustomHead: React.FC<CustomHeadProps> = ({ title }) => (
+export const CustomHead: React.FC<React.PropsWithChildren<CustomHeadProps>> = ({
+ title,
+ children,
+}) => (
<Head>
+ {children}
<title>{title}</title>
<link rel="icon" href="/images/favicon.png" type="image/png" />
<meta
@@ -48,6 +64,7 @@ export const CustomHead: React.FC<CustomHeadProps> = ({ title }) => (
*/
export const CustomHeadAlbumsStatic: React.FC = () => (
<Head>
+ <AlbumsFontPreloads />
<title>Ente Photos</title>
<link rel="icon" href="/images/favicon.png" type="image/png" />
<meta
@@ -80,7 +97,9 @@ export const CustomHeadAlbums: React.FC<CustomHeadProps> = ({ title }) =>
isCustomAlbumsAppOrigin ||
(haveWindow() &&
new URL(window.location.href).origin != albumsAppOrigin()) ? (
- <CustomHead {...{ title }} />
+ <CustomHead {...{ title }}>
+ <AlbumsFontPreloads />
+ </CustomHead>
) : (
<CustomHeadAlbumsStatic />
);