/** * @file terminalFont — the lane terminal's font, a viewer preference kept in * `localStorage` (`agenthub.terminal.font`) and read by `TerminalView` when a * terminal opens. `jetbrains` (the default) and the rounded `maple` are * bundled webfonts that cover every Vietnamese letter; `system` is the browser's own * fixed-width font, which may not (DejaVu Sans Mono on Linux lacks ấ, ế, ố…, * and those glyphs then fall back to a face of another width). A change fires * `FONT_SIZE_EVENT` (`lib/fontSize.ts`), so an open terminal takes it too. * @author Nguyễn Ngọc Trí Vĩ */ import { FONT_SIZE_EVENT } from "./fontSize"; export const TERMINAL_FONT_KEY = "agenthub.terminal.font"; export const TERMINAL_FONTS = { jetbrains: '"JetBrains Mono", monospace', maple: '"Maple Mono", monospace', system: "monospace", } as const; export type TerminalFont = keyof typeof TERMINAL_FONTS; export function readTerminalFont(): TerminalFont { try { const v = window.localStorage.getItem(TERMINAL_FONT_KEY); if (v && v in TERMINAL_FONTS) return v as TerminalFont; } catch { /* storage blocked — the default */ } return "jetbrains"; } export function writeTerminalFont(font: TerminalFont) { try { window.localStorage.setItem(TERMINAL_FONT_KEY, font); } catch { /* storage blocked — terminals keep the default */ } window.dispatchEvent(new Event(FONT_SIZE_EVENT)); }