diff --git a/apps/web/src/appearanceFonts.ts b/apps/web/src/appearanceFonts.ts index e7c2867cb279f..f167290702685 100644 --- a/apps/web/src/appearanceFonts.ts +++ b/apps/web/src/appearanceFonts.ts @@ -263,6 +263,18 @@ function resolveGenericFamilyLabel(generic: string): string | null { return null; } +// Synthetic Apple labels are not necessarily available as named CSS families. +export function displayFontFamily(family: string): string { + const label = family + .trim() + .replace(/^(['"])(.*)\1$/, "$2") + .trim() + .toLowerCase(); + if (label === "sf pro") return appearanceFontStack(family, DEFAULT_SANS_FONT_STACK); + if (label === "sf mono") return DEFAULT_CODE_FONT_STACK; + return cssFontFamilies(family) ?? ""; +} + export function resolveDefaultFamilyLabel(stack: string): string | null { for (const raw of stack.split(",")) { const family = raw.trim().replace(/^(['"])(.*)\1$/, "$2"); diff --git a/apps/web/src/components/settings/FontFamilyPicker.tsx b/apps/web/src/components/settings/FontFamilyPicker.tsx index 3f6d5d6f59b17..8b824c80574b4 100644 --- a/apps/web/src/components/settings/FontFamilyPicker.tsx +++ b/apps/web/src/components/settings/FontFamilyPicker.tsx @@ -1,7 +1,11 @@ import { LegendList, type LegendListRef } from "@legendapp/list/react"; import { CheckIcon } from "lucide-react"; import { useEffect, useRef, useState, useSyncExternalStore } from "react"; -import { isMonospaceFamily, queryInstalledFontFamilies } from "../../appearanceFonts"; +import { + displayFontFamily, + isMonospaceFamily, + queryInstalledFontFamilies, +} from "../../appearanceFonts"; import { Combobox, ComboboxEmpty, @@ -148,7 +152,7 @@ export function FontFamilyPicker({ return (
- + {family}