Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

feat(i18n): bundle the app's three faces, drop Google Fonts, add CJK/Arabic fallbacks

chaitanyagiri41ea4c37b1a2
diff --git a/src/renderer/index.html b/src/renderer/index.html
index 5fdae888..39448a91 100644
--- a/src/renderer/index.html
+++ b/src/renderer/index.html
@@ -3,14 +3,14 @@
<head>
<meta charset="UTF-8" />
<title>Munder Difflin</title>
- <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: blob:; connect-src 'self' https://api.openai.com https://*.openai.com wss://api.openai.com wss://*.openai.com; media-src 'self' blob: mediastream:;" />
- <link rel="preconnect" href="https://fonts.googleapis.com" />
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
+ <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data: blob:; connect-src 'self' https://api.openai.com https://*.openai.com wss://api.openai.com wss://*.openai.com; media-src 'self' blob: mediastream:;" />
<!-- v0.3.4 type revamp: Press Start 2P stays as the BRAND display face
(small caps labels only); body/UI moves to Inter and code/terminal to
- JetBrains Mono — the pixel body fonts (Pixelify/VT323) read as toy-like
- and strained at data-dense sizes. -->
- <link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet" />
+ JetBrains Mono. The pixel body fonts (Pixelify/VT323) read as toy-like
+ and strained at data-dense sizes.
+ v0.4.6: these three faces are BUNDLED (src/renderer/src/design/fonts.css)
+ rather than fetched from fonts.googleapis.com, which is blocked in
+ mainland China. The CSP above no longer allows either Google font host. -->
<style>
#cth-splash {
position: fixed; inset: 0; display: flex; flex-direction: column;
diff --git a/src/renderer/src/assets/fonts/LICENSE.txt b/src/renderer/src/assets/fonts/LICENSE.txt
new file mode 100644
index 00000000..92d8221c
--- /dev/null
+++ b/src/renderer/src/assets/fonts/LICENSE.txt
@@ -0,0 +1,113 @@
+Bundled fonts and their licenses
+================================
+
+Munder Difflin ships three font files inside the application bundle, in
+src/renderer/src/assets/fonts/. They are NOT ours. All three are licensed under
+the SIL Open Font License, Version 1.1, whose full text follows the attributions
+below. The OFL requires this notice to travel with every copy of the software.
+
+ press-start-2p-latin-400.woff2
+ Press Start 2P (latin subset, weight 400)
+ Copyright (c) 2012, Cody "CodeMan38" Boisclair ([email protected])
+ https://fonts.google.com/specimen/Press+Start+2P
+
+ inter-latin-var.woff2
+ Inter (latin subset, variable, weights 400 to 700)
+ Copyright (c) 2016 The Inter Project Authors
+ https://github.com/rsms/inter
+
+ jetbrains-mono-latin-var.woff2
+ JetBrains Mono (latin subset, variable, weights 400 to 700)
+ Copyright 2020 The JetBrains Mono Project Authors
+ https://github.com/JetBrains/JetBrainsMono
+
+No CJK or Arabic face is bundled: a full CJK face is 8 to 10 MB, and every
+platform we ship on already carries one. The design tokens name those system
+faces as fallbacks instead (see src/renderer/src/design/tokens.css).
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/src/renderer/src/assets/fonts/inter-latin-var.woff2 b/src/renderer/src/assets/fonts/inter-latin-var.woff2
new file mode 100644
index 00000000..91dc3e85
Binary files /dev/null and b/src/renderer/src/assets/fonts/inter-latin-var.woff2 differ
diff --git a/src/renderer/src/assets/fonts/jetbrains-mono-latin-var.woff2 b/src/renderer/src/assets/fonts/jetbrains-mono-latin-var.woff2
new file mode 100644
index 00000000..2ca6ac60
Binary files /dev/null and b/src/renderer/src/assets/fonts/jetbrains-mono-latin-var.woff2 differ
diff --git a/src/renderer/src/assets/fonts/press-start-2p-latin-400.woff2 b/src/renderer/src/assets/fonts/press-start-2p-latin-400.woff2
new file mode 100644
index 00000000..cefec4c1
Binary files /dev/null and b/src/renderer/src/assets/fonts/press-start-2p-latin-400.woff2 differ
diff --git a/src/renderer/src/design/fonts.css b/src/renderer/src/design/fonts.css
new file mode 100644
index 00000000..29961173
--- /dev/null
+++ b/src/renderer/src/design/fonts.css
@@ -0,0 +1,42 @@
+/* Self-hosted typography.
+ *
+ * These three faces used to load from fonts.googleapis.com at runtime. Both that
+ * host and fonts.gstatic.com are blocked in mainland China, so the app booted
+ * there with every face silently falling back: the Press Start 2P brand chrome
+ * rendered as generic monospace and the whole UI looked broken to exactly the
+ * users we had just added a zh-CN locale for. A desktop app should not need the
+ * network to render its own typography, so the files ship inside the bundle.
+ *
+ * Latin subsets only, and Inter/JetBrains Mono are VARIABLE fonts, so one file
+ * per family covers weights 400 to 700. 84KB for all three. CJK and Arabic are
+ * deliberately NOT bundled: a full CJK face is 8-10MB, which is not worth it
+ * when every OS we ship on already has a good one. The token stacks in
+ * tokens.css name those system faces instead.
+ *
+ * Vite fingerprints and inlines these URLs at build time, so the paths below are
+ * source paths, not runtime ones. */
+
+@font-face {
+ font-family: 'Press Start 2P';
+ font-style: normal;
+ font-weight: 400;
+ font-display: swap;
+ src: url('../assets/fonts/press-start-2p-latin-400.woff2') format('woff2');
+}
+
+@font-face {
+ font-family: 'Inter';
+ font-style: normal;
+ /* Variable: one file answers every weight the design tokens ask for. */
+ font-weight: 400 700;
+ font-display: swap;
+ src: url('../assets/fonts/inter-latin-var.woff2') format('woff2');
+}
+
+@font-face {
+ font-family: 'JetBrains Mono';
+ font-style: normal;
+ font-weight: 400 700;
+ font-display: swap;
+ src: url('../assets/fonts/jetbrains-mono-latin-var.woff2') format('woff2');
+}
diff --git a/src/renderer/src/design/global.css b/src/renderer/src/design/global.css
index 1c5c0d97..8ee112c1 100644
--- a/src/renderer/src/design/global.css
+++ b/src/renderer/src/design/global.css
@@ -1,3 +1,4 @@
+@import './fonts.css';
@import './tokens.css';
*, *::before, *::after { box-sizing: border-box; }
diff --git a/src/renderer/src/design/tokens.css b/src/renderer/src/design/tokens.css
index 8ecd0bb7..d76bbcf8 100644
--- a/src/renderer/src/design/tokens.css
+++ b/src/renderer/src/design/tokens.css
@@ -52,9 +52,11 @@
/* Type — v0.3.4: Press Start 2P stays as the BRAND face for small caps
labels; everything the user actually reads is Inter (UI) and JetBrains
Mono (code/terminal). Pixelify/VT323 were the main readability drag. */
- --cth-font-display: "Press Start 2P", monospace;
- --cth-font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
- --cth-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
+ /* Press Start 2P is latin-only by design. CJK and Arabic text in a display
+ slot falls through to a system face rather than to generic monospace. */
+ --cth-font-display: "Press Start 2P", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Geeza Pro", "Noto Naskh Arabic", "Segoe UI Historic", monospace;
+ --cth-font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Geeza Pro", "Noto Naskh Arabic", "Segoe UI Historic", sans-serif;
+ --cth-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, "PingFang SC", "Microsoft YaHei", "Noto Sans Mono CJK SC", "Noto Sans CJK SC", "Geeza Pro", "Noto Naskh Arabic", "Segoe UI Historic", monospace;
/* Type scale — v0.3.4: one step tighter (Inter reads larger than Pixelify
at equal px, and the controls were oversized) */
diff --git a/src/renderer/src/design/tokens.ts b/src/renderer/src/design/tokens.ts
index 96a791dd..e0232885 100644
--- a/src/renderer/src/design/tokens.ts
+++ b/src/renderer/src/design/tokens.ts
@@ -57,9 +57,9 @@ export const space = {
} as const;
export const type = {
- display: '"Press Start 2P", monospace',
- ui: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif',
- mono: '"JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace'
+ display: '"Press Start 2P", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Geeza Pro", "Noto Naskh Arabic", "Segoe UI Historic", monospace',
+ ui: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Geeza Pro", "Noto Naskh Arabic", "Segoe UI Historic", sans-serif',
+ mono: '"JetBrains Mono", ui-monospace, "SF Mono", Menlo, "PingFang SC", "Microsoft YaHei", "Noto Sans Mono CJK SC", "Noto Sans CJK SC", "Geeza Pro", "Noto Naskh Arabic", "Segoe UI Historic", monospace'
} as const;
export const tileSize = 32; // px — the world is built from 32×32 tiles
diff --git a/src/shared/releaseDrop.ts b/src/shared/releaseDrop.ts
index fa9663de..bd06cf42 100644
--- a/src/shared/releaseDrop.ts
+++ b/src/shared/releaseDrop.ts
@@ -111,8 +111,8 @@ const FRAME_BASE_CSS = `
--shadow-chip: 3px 3px 0 var(--ink);
--radius: 0px;
--pad: clamp(24px, 4.5vw, 48px);
- --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
- --font-sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
+ --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, "PingFang SC", "Microsoft YaHei", "Noto Sans Mono CJK SC", "Geeza Pro", "Noto Naskh Arabic", monospace;
+ --font-sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Geeza Pro", "Noto Naskh Arabic", sans-serif;
--font-ui: var(--font-sans);
}
* { box-sizing: border-box; }
diff --git a/test/bundled-fonts.test.cjs b/test/bundled-fonts.test.cjs
new file mode 100644
index 00000000..1bd371a2
--- /dev/null
+++ b/test/bundled-fonts.test.cjs
@@ -0,0 +1,120 @@
+'use strict';
+
+// The app used to <link> its three faces from fonts.googleapis.com. That host and
+// fonts.gstatic.com are blocked in mainland China, so the app booted there with
+// every face falling back and the UI looked broken. These tests hold the fix in
+// place: the files ship in the bundle, nothing reaches for Google at runtime, and
+// the token stacks keep naming a system CJK/Arabic face.
+
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+
+const root = path.join(__dirname, '..');
+const read = (p) => fs.readFileSync(path.join(root, p), 'utf8');
+
+const FONT_DIR = 'src/renderer/src/assets/fonts';
+const FILES = [
+ 'press-start-2p-latin-400.woff2',
+ 'inter-latin-var.woff2',
+ 'jetbrains-mono-latin-var.woff2'
+];
+
+test('the three faces are real woff2 files inside the repo', () => {
+ for (const f of FILES) {
+ const buf = fs.readFileSync(path.join(root, FONT_DIR, f));
+ // 'wOF2' — a truncated or HTML-error-page download would not carry it.
+ assert.equal(buf.subarray(0, 4).toString('latin1'), 'wOF2', `${f} is not woff2`);
+ assert.ok(buf.length > 2000, `${f} is suspiciously small (${buf.length}b)`);
+ }
+});
+
+test('bundling stays small: no CJK face was quietly added', () => {
+ // A full CJK face is 8-10MB. The founder ruled we do not ship one; if someone
+ // adds one later this budget is where they have to argue for it.
+ const total = FILES.reduce((n, f) => n + fs.statSync(path.join(root, FONT_DIR, f)).size, 0);
+ assert.ok(total < 300 * 1024, `bundled fonts total ${total}b, over the 300KB budget`);
+});
+
+test('the OFL license and attribution ship with the fonts', () => {
+ const lic = read(`${FONT_DIR}/LICENSE.txt`);
+ assert.match(lic, /SIL OPEN FONT LICENSE Version 1\.1/);
+ for (const name of ['Press Start 2P', 'Inter', 'JetBrains Mono']) {
+ assert.ok(lic.includes(name), `${name} has no attribution`);
+ }
+});
+
+test('@font-face points at the bundled files, not a URL', () => {
+ const css = read('src/renderer/src/design/fonts.css');
+ assert.equal((css.match(/@font-face/g) || []).length, 3);
+ for (const f of FILES) assert.ok(css.includes(f), `fonts.css does not reference ${f}`);
+ assert.doesNotMatch(css.replace(/\/\*[\s\S]*?\*\//g, ''), /https?:/);
+});
+
+test('fonts.css is imported before the tokens that use those families', () => {
+ const g = read('src/renderer/src/design/global.css');
+ assert.ok(g.indexOf("@import './fonts.css'") >= 0, 'fonts.css is never imported');
+ assert.ok(
+ g.indexOf("@import './fonts.css'") < g.indexOf("@import './tokens.css'"),
+ 'fonts.css must be imported before tokens.css'
+ );
+});
+
+test('the app HTML no longer reaches for Google, and its CSP forbids it', () => {
+ const html = read('src/renderer/index.html');
+ const withoutComments = html.replace(/<!--[\s\S]*?-->/g, '');
+ assert.doesNotMatch(withoutComments, /fonts\.googleapis\.com|fonts\.gstatic\.com/);
+ const csp = withoutComments.match(/Content-Security-Policy"\s+content="([^"]+)"/);
+ assert.ok(csp, 'no CSP meta tag');
+ assert.match(csp[1], /font-src 'self';/);
+ assert.doesNotMatch(csp[1], /googleapis|gstatic/);
+});
+
+// --- the token stacks -------------------------------------------------------
+
+/** Every font stack the app exposes, from BOTH files that define them. */
+function stacks() {
+ const css = read('src/renderer/src/design/tokens.css');
+ const ts = read('src/renderer/src/design/tokens.ts');
+ const pick = (s, re) => {
+ const m = s.match(re);
+ assert.ok(m, `no match for ${re}`);
+ return m[1];
+ };
+ return {
+ cssDisplay: pick(css, /--cth-font-display:\s*(.+);/),
+ cssUi: pick(css, /--cth-font-ui:\s*(.+);/),
+ cssMono: pick(css, /--cth-font-mono:\s*(.+);/),
+ tsDisplay: pick(ts, /display: '(.+)',/),
+ tsUi: pick(ts, /ui: '(.+)',/),
+ tsMono: pick(ts, /mono: '(.+)'/)
+ };
+}
+
+test('every stack falls through to a system CJK face and an Arabic face', () => {
+ const s = stacks();
+ for (const [name, stack] of Object.entries(s)) {
+ assert.match(stack, /PingFang SC|Microsoft YaHei|Noto Sans( Mono)? CJK SC/, `${name} has no CJK fallback`);
+ assert.match(stack, /Geeza Pro|Noto Naskh Arabic/, `${name} has no Arabic fallback`);
+ }
+});
+
+test('tokens.css and tokens.ts do not drift apart', () => {
+ // tokens.ts says "mirrors tokens.css — update both together". Nothing enforced
+ // that, so a stack could be widened in one file and not the other.
+ const s = stacks();
+ assert.equal(s.tsDisplay, s.cssDisplay);
+ assert.equal(s.tsUi, s.cssUi);
+ assert.equal(s.tsMono, s.cssMono);
+});
+
+test('the release-drop iframe also falls through to a system CJK face', () => {
+ // Its own <style> block, separate from the app tokens, and easy to forget.
+ const drop = read('src/shared/releaseDrop.ts');
+ for (const re of [/--font-mono: (.+);/, /--font-sans: (.+);/]) {
+ const stack = drop.match(re)[1];
+ assert.match(stack, /PingFang SC|Microsoft YaHei|Noto Sans( Mono)? CJK SC/);
+ assert.match(stack, /Geeza Pro|Noto Naskh Arabic/);
+ }
+});