Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/web/src/appearanceFonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 6 additions & 2 deletions apps/web/src/components/settings/FontFamilyPicker.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -148,7 +152,7 @@ export function FontFamilyPicker({
return (
<ComboboxItem hideIndicator index={index} key={item} value={item}>
<div className="flex w-full min-w-0 items-center justify-between gap-2">
<span className="min-w-0 truncate" style={{ fontFamily: family }}>
<span className="min-w-0 truncate" style={{ fontFamily: displayFontFamily(family) }}>
{family}
</span>
<span className="flex shrink-0 items-center gap-1.5">
Expand Down
Loading