The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Self-host every font instead of loading them from Google (#23859)
Félix Malfait8774bf86042a
diff --git a/packages/twenty-front/.storybook/preview-head.html b/packages/twenty-front/.storybook/preview-head.htmlindex ed219d82b58..cbd4c1b22ad 100644--- a/packages/twenty-front/.storybook/preview-head.html+++ b/packages/twenty-front/.storybook/preview-head.html@@ -1,5 +1,3 @@-<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.7/iframeResizer.contentWindow.min.js"></script>-<style type="text/css">body {margin: 0;diff --git a/packages/twenty-front/src/modules/command-menu-item/record/single-record/utils/exportBlockNoteEditorToPdf.ts b/packages/twenty-front/src/modules/command-menu-item/record/single-record/utils/exportBlockNoteEditorToPdf.tsindex 7841ae878dc..26636aecd0a 100644--- a/packages/twenty-front/src/modules/command-menu-item/record/single-record/utils/exportBlockNoteEditorToPdf.ts+++ b/packages/twenty-front/src/modules/command-menu-item/record/single-record/utils/exportBlockNoteEditorToPdf.ts@@ -3,44 +3,13 @@ import {PDFExporter,pdfDefaultSchemaMappings,} from '@blocknote/xl-pdf-exporter';-import { Font, pdf } from '@react-pdf/renderer';+import { pdf } from '@react-pdf/renderer';import { saveAs } from 'file-saver';-const registerInterFonts = (() => {- let registrationPromise: Promise<void> | null = null;-- return () => {- if (!registrationPromise) {- registrationPromise = Promise.resolve().then(() => {- Font.register({- family: 'Inter',- fonts: [- {- src: 'https://fonts.gstatic.com/s/inter/v19/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfMZg.ttf',- fontWeight: 400,- },- {- src: 'https://fonts.gstatic.com/s/inter/v19/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuI6fMZg.ttf',- fontWeight: 500,- },- {- src: 'https://fonts.gstatic.com/s/inter/v19/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuGKYMZg.ttf',- fontWeight: 600,- },- ],- });- });- }- return registrationPromise;- };-})();-export const exportBlockNoteEditorToPdf = async (parsedBody: PartialBlock[],filename: string,) => {- await registerInterFonts();-const editor = BlockNoteEditor.create({initialContent: parsedBody,});diff --git a/packages/twenty-sdk/src/cli/utilities/auth/callback-server.ts b/packages/twenty-sdk/src/cli/utilities/auth/callback-server.tsindex c2e7e696361..7fe1fa52934 100644--- a/packages/twenty-sdk/src/cli/utilities/auth/callback-server.ts+++ b/packages/twenty-sdk/src/cli/utilities/auth/callback-server.ts@@ -29,9 +29,6 @@ const pageHtml = ({<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${title} — Twenty</title>- <link rel="preconnect" href="https://fonts.googleapis.com">- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet"><style>:root {--bg-body: #fafafa;@@ -55,7 +52,7 @@ const pageHtml = ({}* { margin: 0; padding: 0; box-sizing: border-box; }body {- font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;background: var(--bg-body);display: flex;align-items: center;diff --git a/packages/twenty-ui/.storybook/preview-head.html b/packages/twenty-ui/.storybook/preview-head.htmlindex 534a4fb9bee..cbd4c1b22ad 100644--- a/packages/twenty-ui/.storybook/preview-head.html+++ b/packages/twenty-ui/.storybook/preview-head.html@@ -1,10 +1,3 @@-<link- href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap"- rel="stylesheet"-/>--<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.7/iframeResizer.contentWindow.min.js"></script>-<style type="text/css">body {margin: 0;diff --git a/packages/twenty-ui/.storybook/preview.tsx b/packages/twenty-ui/.storybook/preview.tsxindex f129471e5ba..02f8465ea63 100644--- a/packages/twenty-ui/.storybook/preview.tsx+++ b/packages/twenty-ui/.storybook/preview.tsx@@ -1,3 +1,7 @@+import '@fontsource/inter/400.css';+import '@fontsource/inter/500.css';+import '@fontsource/inter/600.css';+import { type Preview } from '@storybook/react-vite';import '@ui/theme-constants/theme-light.css';import '@ui/theme-constants/theme-dark.css';diff --git a/packages/twenty-ui/package.json b/packages/twenty-ui/package.jsonindex 7cdfca4e6ed..0b0519d4497 100644--- a/packages/twenty-ui/package.json+++ b/packages/twenty-ui/package.json@@ -30,6 +30,7 @@],"devDependencies": {"@argos-ci/storybook": "^6.0.6",+ "@fontsource/inter": "^5.2.8","@prettier/sync": "^0.5.2","@size-limit/preset-small-lib": "^12.1.0","@storybook-community/storybook-addon-cookie": "^5.0.0",diff --git a/packages/twenty-website/src/app/[locale]/layout.tsx b/packages/twenty-website/src/app/[locale]/layout.tsxindex 69eccd072c8..81433ce6f41 100644--- a/packages/twenty-website/src/app/[locale]/layout.tsx+++ b/packages/twenty-website/src/app/[locale]/layout.tsx@@ -1,5 +1,4 @@import { css } from '@linaria/core';-import { Aleo, Azeret_Mono, Host_Grotesk, VT323 } from 'next/font/google';import localFont from 'next/font/local';import { type ReactNode } from 'react';@@ -14,30 +13,36 @@ import { resolveLocaleParam } from '@/platform/i18n/resolve-locale-param';import { WEBSITE_LOCALE_LIST } from '@/platform/i18n/website-locale-list';import { color, fontFamily, tokenCssVariables } from '@/tokens';-const hostGrotesk = Host_Grotesk({- subsets: ['latin'],- weight: ['300', '400', '500', '600'],+// Host Grotesk and Azeret Mono are variable fonts, declared over their full+// wght axis so the browser interpolates every weight the site asks for.+const hostGrotesk = localFont({+ src: '../../fonts/host-grotesk-latin-variable.woff2',+ weight: '300 800',+ style: 'normal',variable: '--font-sans',display: 'swap',});-const aleo = Aleo({- subsets: ['latin'],- weight: ['300'],+const aleo = localFont({+ src: '../../fonts/aleo-latin-300.woff2',+ weight: '300',+ style: 'normal',variable: '--font-serif',display: 'swap',});-const azeretMono = Azeret_Mono({- subsets: ['latin'],- weight: ['300', '500'],+const azeretMono = localFont({+ src: '../../fonts/azeret-mono-latin-variable.woff2',+ weight: '100 900',+ style: 'normal',variable: '--font-mono',display: 'swap',});-const vt323 = VT323({- subsets: ['latin'],+const vt323 = localFont({+ src: '../../fonts/vt323-latin-400.woff2',weight: '400',+ style: 'normal',variable: '--font-retro',display: 'swap',});diff --git a/packages/twenty-website/src/fonts/README.md b/packages/twenty-website/src/fonts/README.mdnew file mode 100644index 00000000000..267c7fc7ead--- /dev/null+++ b/packages/twenty-website/src/fonts/README.md@@ -0,0 +1,17 @@+# Fonts++Self-hosted so that neither a build nor a page view ever reaches a third-party+font host. Bound to CSS variables through `next/font/local` in+`src/app/[locale]/layout.tsx`.++Every file is the `latin` subset only, matching what the site renders, and every+family is licensed under the SIL Open Font License 1.1.++- `host-grotesk-latin-variable.woff2`: Host Grotesk, variable `wght` 300-800, https://github.com/Element-Type/HostGrotesk+- `azeret-mono-latin-variable.woff2`: Azeret Mono, variable `wght` 100-900, https://github.com/displaay/azeret+- `aleo-latin-300.woff2`: Aleo Light, https://github.com/AlessioLaiso/aleo+- `vt323-latin-400.woff2`: VT323, https://github.com/phoikoi/VT323+- `inter-latin-{400,500,600}.woff2`: Inter (classic v12), https://github.com/rsms/inter++To refresh a file, take it from the family's upstream release rather than from a+font CDN.diff --git a/packages/twenty-website/src/fonts/aleo-latin-300.woff2 b/packages/twenty-website/src/fonts/aleo-latin-300.woff2new file mode 100644index 00000000000..985be6b5139Binary files /dev/null and b/packages/twenty-website/src/fonts/aleo-latin-300.woff2 differdiff --git a/packages/twenty-website/src/fonts/azeret-mono-latin-variable.woff2 b/packages/twenty-website/src/fonts/azeret-mono-latin-variable.woff2new file mode 100644index 00000000000..b078559debfBinary files /dev/null and b/packages/twenty-website/src/fonts/azeret-mono-latin-variable.woff2 differdiff --git a/packages/twenty-website/src/fonts/host-grotesk-latin-variable.woff2 b/packages/twenty-website/src/fonts/host-grotesk-latin-variable.woff2new file mode 100644index 00000000000..44d652b5072Binary files /dev/null and b/packages/twenty-website/src/fonts/host-grotesk-latin-variable.woff2 differdiff --git a/packages/twenty-website/src/fonts/vt323-latin-400.woff2 b/packages/twenty-website/src/fonts/vt323-latin-400.woff2new file mode 100644index 00000000000..fd760b5bad0Binary files /dev/null and b/packages/twenty-website/src/fonts/vt323-latin-400.woff2 differdiff --git a/yarn.lock b/yarn.lockindex 31c1644adb2..8d603c8120e 100644--- a/yarn.lock+++ b/yarn.lock@@ -50026,6 +50026,7 @@ __metadata:dependencies:"@argos-ci/storybook": "npm:^6.0.6""@base-ui/react": "npm:^1.5.0"+ "@fontsource/inter": "npm:^5.2.8""@monaco-editor/react": "npm:^4.7.0""@prettier/sync": "npm:^0.5.2""@radix-ui/colors": "npm:^3.0.0"