mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 00:49:41 +02:00
feat: bundled Nerd Font symbols fallback + per-device terminal font setting
Shell prompts using Nerd Font glyphs (powerline, p10k/starship folder and git icons) rendered as missing-glyph boxes: the built-in xterm stack has no private-use-area symbols, and phones have no Nerd Fonts installed at all. - Bundle Symbols Nerd Font Mono (icons-only, MIT, 1.2MB woff2) served from fonts/ and appended to the terminal stack before monospace — browsers fall back per glyph, so icons render everywhere while text stays in the text fonts. font-display: block + preload keep tofu out of xterm's glyph atlas. - New per-device terminalFontFamily setting (App Settings > Terminal & Input > Font): prepended to the built-in stack, never a replacement, so the symbols fallback and final monospace always survive. Applied live on save (refit + echo-overlay refreshFont, mirroring setFontSize). - Single source for both xterm surfaces: TERMINAL_FONT_DEFAULT_STACK + resolveTerminalFontFamily() in constants.js, unit-tested. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VjnbbZRBuvR5E3SDouwXr9
This commit is contained in:
co-authored by
Claude Fable 5
parent
09bf00c815
commit
108c00e78d
@@ -527,6 +527,41 @@ function sortSessionsByActivity(rows) {
|
||||
return (Array.isArray(rows) ? rows.slice() : []).sort(compareSessionActivity);
|
||||
}
|
||||
|
||||
// Terminal font stack — the single source for every xterm surface (the main
|
||||
// terminal in terminal-ui.js, the log-viewer terminal in panels-ui.js).
|
||||
// "Symbols Nerd Font Mono" is a bundled icons-only webfont (fonts/ +
|
||||
// @font-face in styles.css): browsers fall back PER GLYPH, so Nerd Font
|
||||
// prompt icons (powerline segments, folder/git glyphs from p10k, starship,
|
||||
// oh-my-posh) render even though the text fonts carry no private-use-area
|
||||
// symbols — while all readable text keeps coming from the text fonts.
|
||||
const TERMINAL_FONT_DEFAULT_STACK =
|
||||
'"Fira Code", "Cascadia Code", "JetBrains Mono", "SF Mono", Monaco, "Symbols Nerd Font Mono", monospace';
|
||||
|
||||
/**
|
||||
* Resolve the xterm fontFamily from the per-device `terminalFontFamily`
|
||||
* setting. A user-set family (or comma-separated list) is PREPENDED to the
|
||||
* built-in stack, never a replacement — the symbols fallback and a final
|
||||
* `monospace` must survive whatever the user types. Blank input yields the
|
||||
* default. Unquoted names that need quoting for CSS (spaces, digits leading,
|
||||
* etc.) are quoted; embedded quotes are stripped rather than escaped, since
|
||||
* a font name cannot contain them anyway.
|
||||
*/
|
||||
function resolveTerminalFontFamily(custom) {
|
||||
const raw = typeof custom === 'string' ? custom.trim() : '';
|
||||
if (!raw) return TERMINAL_FONT_DEFAULT_STACK;
|
||||
const families = raw
|
||||
.split(',')
|
||||
.map((f) => f.trim().replace(/^["']|["']$/g, '').replace(/["']/g, '').trim())
|
||||
.filter(Boolean)
|
||||
// Drop generic families the user may append — the default stack already
|
||||
// ends in `monospace`, and a duplicate earlier entry would shadow the
|
||||
// symbols fallback behind it.
|
||||
.filter((f) => !/^(monospace|serif|sans-serif|system-ui)$/i.test(f))
|
||||
.map((f) => (/^[A-Za-z][A-Za-z0-9-]*$/.test(f) ? f : `"${f}"`));
|
||||
if (!families.length) return TERMINAL_FONT_DEFAULT_STACK;
|
||||
return `${families.join(', ')}, ${TERMINAL_FONT_DEFAULT_STACK}`;
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.WEBGL_FALLBACK = WEBGL_FALLBACK;
|
||||
window.evaluateWebGLLongTaskTrip = evaluateWebGLLongTaskTrip;
|
||||
@@ -560,6 +595,10 @@ if (typeof window !== 'undefined') {
|
||||
compare: compareSessionActivity,
|
||||
sort: sortSessionsByActivity,
|
||||
};
|
||||
window.CodemanTerminalFont = {
|
||||
DEFAULT_STACK: TERMINAL_FONT_DEFAULT_STACK,
|
||||
resolve: resolveTerminalFontFamily,
|
||||
};
|
||||
}
|
||||
|
||||
// Scheduler API — prioritize terminal writes over background UI updates.
|
||||
|
||||
Reference in New Issue
Block a user