From c9a35b0922cb704e32d1f1806cc2165328fdf01f Mon Sep 17 00:00:00 2001 From: James Babcock Date: Sat, 5 Sep 2026 16:56:29 -0700 Subject: [PATCH] Decrease minimum selectable font size from 12px to 8px --- app/graphics/ui-fonts.ts | 4 ++-- app/ui/font-picker.ts | 18 ++++++++++-------- app/ui/metrics.ts | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/graphics/ui-fonts.ts b/app/graphics/ui-fonts.ts index bcca0c53..9a04505e 100644 --- a/app/graphics/ui-fonts.ts +++ b/app/graphics/ui-fonts.ts @@ -34,10 +34,10 @@ const MAX_SIZE_GROWTH = 48; /** * Guaranteed line-height range of getDefaultSmallFont, which UI layouts may * rely on (getDefaultMediumFont's range follows: 16..29). The font picker - * disables sizes outside it, and resolution falls back to the bitmap face if + * hides sizes outside it, and resolution falls back to the bitmap face if * a stored selection somehow lands outside (e.g. the font file changed). */ -export const SMALL_FONT_MIN_LINE_HEIGHT = 12; +export const SMALL_FONT_MIN_LINE_HEIGHT = 8; export const SMALL_FONT_MAX_LINE_HEIGHT = 21; /** Whether a small-font selection at this path+size satisfies the UI bound. */ diff --git a/app/ui/font-picker.ts b/app/ui/font-picker.ts index 72b8adc4..70b113ca 100644 --- a/app/ui/font-picker.ts +++ b/app/ui/font-picker.ts @@ -27,7 +27,7 @@ import { drawRightValueMenuItem, drawSelectionHighlight, openModalMenu, type Men import { LIST_ROW_TEXT_INSET, listRowHeight } from "./metrics"; import type { Layer, LayerContext } from "./layers"; -const SIZE_CHOICES = [12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28] as const; +const SIZE_CHOICES = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28] as const; const DEFAULT_TTF_SIZE = 16; const PREVIEW_TEXT = "The quick brown fox jumps over 0123456789"; @@ -35,10 +35,10 @@ type FontPickerOptions = { title: string; /** Only offer faces where every style is monospace (terminal picker). */ monospaceOnly: boolean; - /** When set, sizes where this returns false are disabled (and drafts are + /** When set, sizes where this returns false are hidden (and drafts are * clamped to an allowed size on face/weight changes). The UI-font picker * uses it to keep getDefaultSmallFont's line height within its guaranteed - * 12..21px range; the terminal picker has no such bound. */ + * 8..21px range; the terminal picker has no such bound. */ sizeAllowed?: (path: string, size: number) => boolean; /** Bitmap faces offered ahead of the installed TTF families. */ bitmapFaces: readonly { face: BitmapFace; label: string }[]; @@ -217,10 +217,10 @@ export class FontPickerLayer implements Layer { openModalMenu(ctx, "Font Face", items, Math.max(0, currentIndex)); } - /** Switch families, carrying the weight (nearest available) and size over. */ + /** Switch families, preferring Light (nearest available) and carrying the size over. */ private setFamily(family: FontFamily): void { const previous = this.draft; - const targetOrder = previous.kind === "ttf" ? previous.font.weightOrder : 400; + const targetOrder = 300; const size = previous.kind === "ttf" ? previous.size : DEFAULT_TTF_SIZE; let font = family.fonts[0]!; for (const candidate of family.fonts) { @@ -262,15 +262,17 @@ export class FontPickerLayer implements Layer { private openSizeMenu(ctx: LayerContext): void { if (this.draft.kind !== "ttf") return; const draft = this.draft; - const items = SIZE_CHOICES.map((size): MenuItem => ({ + const sizes = SIZE_CHOICES.filter((size) => + this.options.sizeAllowed === undefined || this.options.sizeAllowed(draft.font.path, size), + ); + const items = sizes.map((size): MenuItem => ({ label: String(size), - disabled: () => this.options.sizeAllowed !== undefined && !this.options.sizeAllowed(draft.font.path, size), onSelect: (innerCtx) => { this.draft = { ...draft, size }; innerCtx.stack.pop(); }, })); - openModalMenu(ctx, "Size", items, Math.max(0, SIZE_CHOICES.indexOf(draft.size as (typeof SIZE_CHOICES)[number]))); + openModalMenu(ctx, "Size", items, Math.max(0, sizes.indexOf(draft.size as (typeof SIZE_CHOICES)[number]))); } } diff --git a/app/ui/metrics.ts b/app/ui/metrics.ts index 2dc19a20..4c99f4d6 100644 --- a/app/ui/metrics.ts +++ b/app/ui/metrics.ts @@ -2,7 +2,7 @@ * Font-derived layout metrics for list-style UIs, so row spacing, selection * highlights, and text line steps track the user's font size instead of * assuming the 12px bitmap default. The font picker guarantees - * getDefaultSmallFont's lineHeight is 12..21px (and getDefaultMediumFont's + * getDefaultSmallFont's lineHeight is 8..21px (and getDefaultMediumFont's * 16..29px — see ui-fonts.ts), so layouts driven by these helpers have * bounded growth. *