Support custom editor font weights in steps of 50 (#74)

JetBrains Mono at 500 looks heavier than PyCharm's rendering, and 450 was rounded up to 500. Adds a Custom option with an input to the Main and Bold font weight rows; weights are clamped to 100–900 and rounded to the nearest 50 (the terminal, which follows the editor weights, gets the same steps).

Verified in the app: Custom → 450 shows the input and the preview renders at 450. Maintainer follow-up: formatted the dialog test.

Related: #32

https://claude.ai/code/session_01VUYsdXA2nkF5v6zsC93dpn
Цей коміт міститься в:
胡翀 authored and GitHub committed 2026-10-27 14:38:42 +08:00
1 джерело 566b4fdeb1
коміт b4742b730b
4 files changed
+54 -21

No files matched your search

+2 -1
Переглянути файл
@@ -60,9 +60,10 @@ describe("color schemes", () => {
const d = validateEditorExtras({});
expect([d.fontWeight, d.boldFontWeight]).toEqual([400, 700]);
const v = validateEditorExtras({ fontWeight: 349, boldFontWeight: 1200 });
expect([v.fontWeight, v.boldFontWeight]).toEqual([300, 900]);
expect([v.fontWeight, v.boldFontWeight]).toEqual([350, 900]);
expect(validateEditorExtras({ fontWeight: "bold" }).fontWeight).toBe(400);
expect(fontWeightVars(500, undefined)).toEqual({ "--fw-code": "500", "--fw-code-bold": "700" });
expect(fontWeightVars(450, 650)).toEqual({ "--fw-code": "450", "--fw-code-bold": "650" });
});
it("coerces editor settings to their defaults' shape", () => {
+2 -2
Переглянути файл
@@ -205,10 +205,10 @@ export const FONT_WEIGHTS: ReadonlyArray<readonly [number, string]> = [
[900, "Black"],
];
/** Nearest CSS weight step (100–900); `def` for anything that is not a number. */
/** CSS weight from 100 to 900, rounded to the nearest 50. */
export function fontWeightOf(raw: unknown, def: number): number {
if (typeof raw !== "number" || !Number.isFinite(raw)) return def;
return Math.min(900, Math.max(100, Math.round(raw / 100) * 100));
return Math.min(900, Math.max(100, Math.round(raw / 50) * 50));
}
/** `--fw-code` / `--fw-code-bold`: what editor-font text and its bold runs render with. */