Decrease minimum selectable font size from 12px to 8px

This commit is contained in:
James Babcock committed 2026-09-05 16:56:29 -07:00
1 parent 1524766996
commit c9a35b0922
3 files changed
+13 -11

No files matched your search

+2 -2
View File
@@ -34,10 +34,10 @@ const MAX_SIZE_GROWTH = 48;
/** /**
* Guaranteed line-height range of getDefaultSmallFont, which UI layouts may * Guaranteed line-height range of getDefaultSmallFont, which UI layouts may
* rely on (getDefaultMediumFont's range follows: 16..29). The font picker * 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). * 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; export const SMALL_FONT_MAX_LINE_HEIGHT = 21;
/** Whether a small-font selection at this path+size satisfies the UI bound. */ /** Whether a small-font selection at this path+size satisfies the UI bound. */
+10 -8
View File
@@ -27,7 +27,7 @@ import { drawRightValueMenuItem, drawSelectionHighlight, openModalMenu, type Men
import { LIST_ROW_TEXT_INSET, listRowHeight } from "./metrics"; import { LIST_ROW_TEXT_INSET, listRowHeight } from "./metrics";
import type { Layer, LayerContext } from "./layers"; 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 DEFAULT_TTF_SIZE = 16;
const PREVIEW_TEXT = "The quick brown fox jumps over 0123456789"; const PREVIEW_TEXT = "The quick brown fox jumps over 0123456789";
@@ -35,10 +35,10 @@ type FontPickerOptions = {
title: string; title: string;
/** Only offer faces where every style is monospace (terminal picker). */ /** Only offer faces where every style is monospace (terminal picker). */
monospaceOnly: boolean; 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 * clamped to an allowed size on face/weight changes). The UI-font picker
* uses it to keep getDefaultSmallFont's line height within its guaranteed * 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; sizeAllowed?: (path: string, size: number) => boolean;
/** Bitmap faces offered ahead of the installed TTF families. */ /** Bitmap faces offered ahead of the installed TTF families. */
bitmapFaces: readonly { face: BitmapFace; label: string }[]; bitmapFaces: readonly { face: BitmapFace; label: string }[];
@@ -217,10 +217,10 @@ export class FontPickerLayer implements Layer {
openModalMenu(ctx, "Font Face", items, Math.max(0, currentIndex)); 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 { private setFamily(family: FontFamily): void {
const previous = this.draft; 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; const size = previous.kind === "ttf" ? previous.size : DEFAULT_TTF_SIZE;
let font = family.fonts[0]!; let font = family.fonts[0]!;
for (const candidate of family.fonts) { for (const candidate of family.fonts) {
@@ -262,15 +262,17 @@ export class FontPickerLayer implements Layer {
private openSizeMenu(ctx: LayerContext): void { private openSizeMenu(ctx: LayerContext): void {
if (this.draft.kind !== "ttf") return; if (this.draft.kind !== "ttf") return;
const draft = this.draft; 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), label: String(size),
disabled: () => this.options.sizeAllowed !== undefined && !this.options.sizeAllowed(draft.font.path, size),
onSelect: (innerCtx) => { onSelect: (innerCtx) => {
this.draft = { ...draft, size }; this.draft = { ...draft, size };
innerCtx.stack.pop(); 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])));
} }
} }
+1 -1
View File
@@ -2,7 +2,7 @@
* Font-derived layout metrics for list-style UIs, so row spacing, selection * 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 * highlights, and text line steps track the user's font size instead of
* assuming the 12px bitmap default. The font picker guarantees * 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 * 16..29px — see ui-fonts.ts), so layouts driven by these helpers have
* bounded growth. * bounded growth.
* *