Open source CapCut alternative.
TypeScript
feat(site): a font card is the typeface, set on its own sheet [rebuild]
David Le94ce396dca94
diff --git a/site/src/cut/components/FontSpecimen.tsx b/site/src/cut/components/FontSpecimen.tsxindex 779c4361..22cbb831 100644--- a/site/src/cut/components/FontSpecimen.tsx+++ b/site/src/cut/components/FontSpecimen.tsx@@ -1,34 +1,38 @@"use client";import { useEffect, useLayoutEffect, useRef, useState } from "react";-import { SPECIMEN_LINES } from "@/cut/lib/fontSpecimen";+import { isCurrentSpecimen, SPECIMEN_LINES } from "@/cut/lib/fontSpecimen";import { linkIdForAsset, onLinkedChanged } from "@/cut/lib/linkedLibrary";import { MEDIA_CORS } from "@/cut/lib/mediaCors";-import { fontStack, onFontsChanged } from "@/cut/lib/types";+import { fontStack, hasFont, onFontsChanged } from "@/cut/lib/types";import { cn } from "@/lib/utils";-// A font drawn in itself: the alphabet the way a font file previews anywhere-// else. The library card carries a small one and the lightbox a large one, both-// from here, so the tile and the big view read as the same object.+// A font drawn in itself. The library card carries a line of it and the big+// view the whole alphabet, both from here, so the two read as the same object.//-// The picture the shelf baked at upload is what it draws. Live text in the face-// is the standby, and it asks the page to have that face installed.+// Live text in the installed face is what it draws. The picture the shelf baked+// at upload is the standby, for a face the page does not have — a shelf that+// did not answer, a listing that has not synced.-const LINES = SPECIMEN_LINES;/** Measured at one size and scaled; large enough that rounding doesn't show. */const PROBE_PX = 100;+/** The share of the room a line is allowed to take. Text measures by advance+ * width, and a swash or an italic leans past that, so the fit leaves a little+ * back rather than setting every face flush to the edge. */+const SAFETY = 0.97;/*** The specimen, set to the width it is given.*- * One size for all three lines: the capitals are the widest line, so fitting- * them sets the size and the rest fall where the face puts them. The size is- * measured rather than computed because a script face runs three times the- * width of a grotesque at the same point size.+ * The size is measured rather than computed because a script face runs three+ * times the width of a grotesque at the same point size, and every card in a+ * grid should carry the same weight of line.*/export function FontSpecimen({assetId,poster,+ lines: LINES = SPECIMEN_LINES,+ fitHeight = false,pad = 16,className,}: {@@ -36,7 +40,14 @@ export function FontSpecimen({assetId: string;/** The specimen the shelf keeps for this file. */poster?: string;- /** Room left either side of the widest line. */+ /** What to set in the face. A card takes one line, the big view the whole+ * alphabet. */+ lines?: readonly string[];+ /** The box has a height of its own — a card — so the line is held inside it+ * as well as inside its width. Where the box grows with the text (the big+ * view), width alone sets the size. */+ fitHeight?: boolean;+ /** Room left either side of the widest line, px. */pad?: number;className?: string;}) {@@ -47,24 +58,46 @@ export function FontSpecimen({// draws in. Both land after the first paint.useEffect(() => onFontsChanged(again), []);useEffect(() => onLinkedChanged(again), []);- const family = fontStack(linkIdForAsset(assetId) ?? "");+ const id = linkIdForAsset(assetId) ?? "";+ const family = fontStack(id);+ const installed = hasFont(id);const box = useRef<HTMLDivElement>(null);const probe = useRef<HTMLSpanElement>(null);const [size, setSize] = useState(0);useLayoutEffect(() => {const fit = () => {+ // The probe holds every line, so its width is the widest of them: on+ // most faces that is the capitals, on some the figures.const line = probe.current?.getBoundingClientRect().width;const width = box.current?.clientWidth;+ const height = box.current?.clientHeight ?? 0;if (!line || !width) return;- setSize((PROBE_PX * (width - pad)) / line);+ // Width sets the size, until the box is short enough that the line would+ // be clipped — a card in a narrow panel column. SAFETY keeps the ends of+ // a line off the edge: a face whose glyphs overhang their advance widths+ // measures narrower than it draws.+ const byWidth = (PROBE_PX * Math.max(0, width - pad * 2) * SAFETY) / line;+ const byHeight =+ fitHeight && height ? (height * SAFETY) / (1.35 * LINES.length) : byWidth;+ setSize(Math.min(byWidth, byHeight));};fit();// The face arrives after the box does, and the box is resized by the grid.const ro = new ResizeObserver(fit);if (box.current) ro.observe(box.current);- return () => ro.disconnect();- }, [family, gen, pad]);- if (poster && !broken)+ // A face measured before it loaded is measured in the fallback, which is+ // narrower than a display face and sets a size the real one overflows.+ // Both signals are needed: `ready` for a face already in flight, the event+ // for one that starts loading after this ran.+ const fonts = document.fonts;+ void fonts?.ready.then(fit).catch(() => {});+ fonts?.addEventListener?.("loadingdone", fit);+ return () => {+ ro.disconnect();+ fonts?.removeEventListener?.("loadingdone", fit);+ };+ }, [family, gen, pad, LINES, fitHeight]);+ if (poster && isCurrentSpecimen(poster) && !broken && !installed)return (// eslint-disable-next-line @next/next/no-img-element -- library media file, not Next-optimizable<img@@ -85,10 +118,14 @@ export function FontSpecimen({<spanref={probe}aria-hidden- className="pointer-events-none invisible fixed top-0 left-0 whitespace-nowrap"+ className="pointer-events-none invisible fixed top-0 left-0"style={{ fontSize: PROBE_PX }}>- {LINES[0]}+ {LINES.map((line) => (+ <span key={line} className="block whitespace-nowrap">+ {line}+ </span>+ ))}</span><spanclassName="text-center leading-[1.35] whitespace-nowrap"diff --git a/site/src/cut/components/LibraryView.tsx b/site/src/cut/components/LibraryView.tsxindex 0470c7ba..85f26698 100644--- a/site/src/cut/components/LibraryView.tsx+++ b/site/src/cut/components/LibraryView.tsx@@ -63,7 +63,7 @@ import {setObjectDragImage,} from "@/cut/lib/assetDrag";import { useInView } from "@/cut/hooks/useInView";-import { isMediaFile } from "@/cut/lib/media";+import { fileKind, isMediaFile } from "@/cut/lib/media";import { patchLibrary, refetchLibrary, useLibrary } from "@/cut/lib/queries";import {createLibraryFolder,@@ -116,6 +116,11 @@ import { formatTime } from "@/cut/lib/time";import { cn } from "@/lib/utils";import { CopyNameLabel } from "./AssetRefs";import { FontSpecimen } from "./FontSpecimen";+import {+ SPECIMEN_BG,+ SPECIMEN_INK,+ SPECIMEN_META,+} from "@/cut/lib/fontSpecimen";import { AudioCardFace } from "./AudioPanel";import {buildDragGhost,@@ -1064,23 +1069,36 @@ export function LibraryCard({// the video correctly, so we render the frame instead of a baked thumbnail.const posterT = Math.min(1, Math.max(0.1, (a.duration || 2) / 10));// The size pill only shows on hover, so the lookup waits for the first one.+ // A font wears its size in the footer at rest, so that one asks as it scrolls+ // into view.const [hovered, setHovered] = useState(false);+ const font = a.type === "font";const sizeBytes = useMediaFileSize(offline ? "" : libraryMediaUrl(a.fileName, a.residency),- hovered,+ hovered || (font && seen),);+ // TTF · 42 KB — what the file is, and how much of it there is.+ const fontMeta = [+ fileKind(a.fileName),+ sizeBytes != null && formatBytes(sizeBytes),+ ]+ .filter(Boolean)+ .join(" · ");const frame =area && a.type !== "audio" && a.width && a.height? { w: a.width, h: a.height }- : a.type === "font"- ? { w: 16, h: 9 }+ : font+ ? { w: 16, h: 6 }: { w: 1, h: 1 };- const tileStyle = area- ? {- width: Math.round(Math.sqrt((area * frame.w) / frame.h)),- aspectRatio: `${frame.w} / ${frame.h}`,- }- : undefined;+ const tileStyle = {+ ...(area+ ? {+ width: Math.round(Math.sqrt((area * frame.w) / frame.h)),+ aspectRatio: `${frame.w} / ${frame.h}`,+ }+ : {}),+ ...(font ? { backgroundColor: SPECIMEN_BG, color: SPECIMEN_INK } : {}),+ };return (<div@@ -1111,14 +1129,54 @@ export function LibraryCard({data-drag-objectclassName={cn("relative max-w-full cursor-grab overflow-hidden rounded-xl border bg-muted transition-shadow group-hover:shadow-[0_4px_20px_rgba(0,0,0,0.1)] active:cursor-grabbing",- !area && (a.type === "font" ? "aspect-video" : "aspect-square"),+ !area && (font ? "aspect-[16/7]" : "aspect-square"),+ // The sheet is the card, so nothing is drawn around it; the type+ // scales with the tile, which runs from a panel column to a full row.+ font && "@container flex flex-col",selected || flash? "border-[#0a84ff] ring-2 ring-[#0a84ff]"- : "border-border",+ : font+ ? "border-transparent"+ : "border-border",)}style={tileStyle}>- {offline ? (+ {font ? (+ // A pangram set in the face, and under a hairline the name it goes by+ // with the file behind it. Nothing to load from a shelf that isn't+ // answering, so that card shows the kind mark instead.+ <div className="flex size-full min-h-0 flex-col">+ <div className="grid min-h-0 flex-1 place-items-center px-3 pt-3 @[220px]:px-5 @[220px]:pt-5">+ {offline ? (+ <Type className="size-6 text-white/35" />+ ) : (+ <FontSpecimen+ assetId={a.id}+ fitHeight+ pad={0}+ className="size-full"+ />+ )}+ </div>+ <div className="mx-3 flex items-center justify-between gap-2 border-t border-white/10 py-2 @[220px]:mx-5 @[220px]:py-3">+ <CopyNameLabel+ name={a.name}+ dark+ mention={mention}+ className="min-w-0 text-[11px] font-medium @[220px]:text-[13px]"+ />+ {fontMeta && (+ <span+ data-drag-omit+ className="shrink-0 text-[10px] tabular-nums @[220px]:text-[11px]"+ style={{ color: SPECIMEN_META }}+ >+ {fontMeta}+ </span>+ )}+ </div>+ </div>+ ) : offline ? (// Nothing to load from a shelf that isn't answering, so the card// shows what it knows: the kind of file, its name, its length.<span className="grid size-full place-items-center">@@ -1126,8 +1184,6 @@ export function LibraryCard({<Music className="size-6 text-muted-foreground/50" />) : a.type === "image" ? (<ImageIcon className="size-6 text-muted-foreground/50" />- ) : a.type === "font" ? (- <Type className="size-6 text-muted-foreground/50" />) : (<Film className="size-6 text-muted-foreground/50" />)}@@ -1172,11 +1228,6 @@ export function LibraryCard({loading="lazy"className="size-full object-cover"/>- ) : a.type === "font" ? (- <FontSpecimen- assetId={a.id}- className="size-full bg-white text-black"- />) : (<AudioCardFaceurl={libraryMediaUrl(a.fileName, a.residency)}@@ -1187,34 +1238,36 @@ export function LibraryCard({}/>)}- {a.type !== "audio" && (a.type === "video" || sizeBytes != null) && (- // Length and size share one pill in the corner: on a card this narrow- // two of them collide. The length reads at rest, the size takes over- // on hover, where the + button is what the pointer is there for.- <span- data-drag-omit- className={cn(- "absolute right-1.5 bottom-1.5 rounded-md bg-black/65 px-1.5 py-0.5 font-mono text-[10px] text-white tabular-nums",- a.type !== "video" &&- "opacity-0 transition-opacity group-hover:opacity-100",- )}- >- {a.type === "video" && (- <span className={cn(sizeBytes != null && "group-hover:hidden")}>- {formatTime(a.duration)}- </span>- )}- {sizeBytes != null && (- <span- className={cn(- a.type === "video" && "hidden group-hover:inline",- )}- >- {formatBytes(sizeBytes)}- </span>- )}- </span>- )}+ {a.type !== "audio" &&+ !font &&+ (a.type === "video" || sizeBytes != null) && (+ // Length and size share one pill in the corner: on a card this narrow+ // two of them collide. The length reads at rest, the size takes over+ // on hover, where the + button is what the pointer is there for.+ <span+ data-drag-omit+ className={cn(+ "absolute right-1.5 bottom-1.5 rounded-md bg-black/65 px-1.5 py-0.5 font-mono text-[10px] text-white tabular-nums",+ a.type !== "video" &&+ "opacity-0 transition-opacity group-hover:opacity-100",+ )}+ >+ {a.type === "video" && (+ <span className={cn(sizeBytes != null && "group-hover:hidden")}>+ {formatTime(a.duration)}+ </span>+ )}+ {sizeBytes != null && (+ <span+ className={cn(+ a.type === "video" && "hidden group-hover:inline",+ )}+ >+ {formatBytes(sizeBytes)}+ </span>+ )}+ </span>+ )}{a.type === "audio" && sizeBytes != null && (// Clear of the play circle, matching the face's duration pill.<span className="absolute bottom-3 left-12 rounded-md bg-[#2b4e42] px-1.5 py-0.5 font-mono text-[10px] text-[#d6eddf] tabular-nums opacity-0 transition-opacity group-hover:opacity-100">@@ -1228,9 +1281,13 @@ export function LibraryCard({className={cn("absolute grid size-6 place-items-center rounded-full bg-primary text-primary-foreground opacity-0 shadow transition-all group-hover:opacity-100 hover:scale-110",// Audio keeps play bottom-left; + swaps in where the badge hides.+ // A font's bottom edge is its footer, so its + takes the corner+ // the name used to sit in.a.type === "audio"? "right-1.5 bottom-1.5"- : "bottom-1.5 left-1.5",+ : font+ ? "top-1.5 left-1.5"+ : "bottom-1.5 left-1.5",)}onClick={(e) => {e.stopPropagation();@@ -1256,13 +1313,22 @@ export function LibraryCard({<DropdownMenuTriggeraria-label="More actions"title="More actions"- className="absolute top-1.5 right-1.5 grid size-6 place-items-center rounded-full bg-black/40 text-white opacity-0 transition-opacity group-hover:opacity-100 hover:bg-black/60 data-[state=open]:opacity-100"+ className={cn(+ "absolute top-1.5 right-1.5 grid size-6 place-items-center rounded-full text-white opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100",+ // A black scrim disappears into the charcoal sheet.+ font+ ? "bg-white/10 hover:bg-white/20"+ : "bg-black/40 hover:bg-black/60",+ )}onClick={(e) => e.stopPropagation()}><Ellipsis className="size-3.5" /></DropdownMenuTrigger><DropdownMenuContent- align="end"+ // Hung off the card's right edge rather than laid over the media:+ // the tile stays readable behind the open menu.+ align="start"+ alignOffset={4}className="w-44"onClick={(e) => e.stopPropagation()}>@@ -1293,16 +1359,18 @@ export function LibraryCard({)}</DropdownMenuContent></DropdownMenu>- <CopyNameLabel- name={a.name}- dark={a.type === "audio"}- mention={mention}- className={cn(- "absolute top-1.5 left-1.5 max-w-[70%] px-2 py-1 text-[11px] font-medium text-white transition-[max-width] group-hover:max-w-[calc(100%-2.75rem)]",- // The emerald fill is its own backdrop; thumbnails need the scrim pill.- a.type !== "audio" && "rounded-lg bg-black/55 backdrop-blur-sm",- )}- />+ {!font && (+ <CopyNameLabel+ name={a.name}+ dark={a.type === "audio"}+ mention={mention}+ className={cn(+ "absolute top-1.5 left-1.5 max-w-[70%] px-2 py-1 text-[11px] font-medium text-white transition-[max-width] group-hover:max-w-[calc(100%-2.75rem)]",+ // The emerald fill is its own backdrop; thumbnails need the scrim pill.+ a.type !== "audio" && "rounded-lg bg-black/55 backdrop-blur-sm",+ )}+ />+ )}</div></div>);diff --git a/site/src/cut/components/Lightbox.tsx b/site/src/cut/components/Lightbox.tsxindex 2f0839b4..f6e1bab4 100644--- a/site/src/cut/components/Lightbox.tsx+++ b/site/src/cut/components/Lightbox.tsx@@ -3,7 +3,6 @@import { useEffect, useRef, useState } from "react";import { Check, Copy, FileText, Loader2, Music, Plus, X } from "lucide-react";import { Button } from "@/components/ui/button";-import { cn } from "@/lib/utils";import { MEDIA_CORS } from "@/cut/lib/mediaCors";import { addLibraryAssetToProject, fetchLibrary } from "@/cut/lib/library";import { useLightbox, type LightboxItem } from "@/cut/lib/lightbox";@@ -12,6 +11,11 @@ import { usePreviewAudio } from "@/cut/lib/previewAudio";import { useEditor } from "@/cut/lib/store";import { DocText, useDocText } from "./DocText";import { FontSpecimen } from "./FontSpecimen";+import {+ SPECIMEN_ALPHABET,+ SPECIMEN_BG,+ SPECIMEN_INK,+} from "@/cut/lib/fontSpecimen";import { PeakStrip } from "./AudioPanel";// The asset lightbox: the big version of a stock, generated, or chat asset@@ -261,15 +265,16 @@ function AudioBody({ item }: { item: LightboxItem }) {/** A font, big: the sheet a font file previews on, the alphabet filling it. */function FontBody({ item }: { item: LightboxItem }) {return (+ // The sheet keeps its margin whichever way the alphabet arrives: the baked+ // picture is the same charcoal, so padding it reads as more sheet.<div- className={cn(- "overflow-hidden rounded-2xl bg-white text-black shadow-2xl",- item.poster ? "" : "px-10 py-12",- )}+ className="overflow-hidden rounded-2xl px-10 py-12 shadow-2xl"+ style={{ backgroundColor: SPECIMEN_BG, color: SPECIMEN_INK }}><FontSpecimenassetId={item.libraryId ?? ""}poster={item.poster}+ lines={SPECIMEN_ALPHABET}pad={0}className="w-full"/>diff --git a/site/src/cut/lib/fontSpecimen.ts b/site/src/cut/lib/fontSpecimen.tsindex bd4e2832..bc7276d0 100644--- a/site/src/cut/lib/fontSpecimen.ts+++ b/site/src/cut/lib/fontSpecimen.ts@@ -1,22 +1,43 @@/**- * The picture a font shows of itself.+ * The picture a font shows of itself, on a warm charcoal sheet: a pangram on+ * the card, the alphabet in the big view.*- * Drawing the alphabet in a live face depends on that face being installed in+ * Drawing the line in a live face depends on that face being installed in* whatever page is looking at it, which is a thing that can be true one minute* and false the next — a shelf that did not answer, a listing that had not* synced. The specimen is baked once, at upload, from bytes that are in hand,- * and the shelf keeps it as the file's cover. What the card shows afterwards is- * a picture, so it is the same every time.+ * and the shelf keeps it as the file's cover, so a card with no face installed+ * still shows the typeface.*/import { createRasterCanvas, rasterCanvasToPng } from "./raster";-export const SPECIMEN_LINES = [+/** What a card shows: one line, enough of the face to recognise it by. */+export const SPECIMEN_LINES = ["Pack my box with five dozen jugs"];++/** What the big view shows, and what the cover is baked from: every letter and+ * figure, the way a font file previews anywhere else. */+export const SPECIMEN_ALPHABET = ["ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz","1234567890",];+/** The sheet the specimen is set on, shared by the baked picture and the card+ * that draws the face live, so the two read as one object. */+export const SPECIMEN_BG = "#1E1C18";+/** The face itself on that sheet. */+export const SPECIMEN_INK = "#F1EFE8";+/** The card's footnote beside the name: file kind and size. */+export const SPECIMEN_META = "#8A877E";++/** What a baked specimen is called. The name carries the sheet's colours, so a+ * cover baked before this one is spotted by its name and passed over: an old+ * white sheet inside the charcoal card would read as a hole in it. */+export const SPECIMEN_FILE_SUFFIX = ".specimen-dark.png";+export const isCurrentSpecimen = (url: string) =>+ url.split("?")[0].endsWith(SPECIMEN_FILE_SUFFIX);+const W = 1600;const H = 900;const PAD = 90;@@ -33,18 +54,19 @@ export async function specimenPng(family: string): Promise<Blob> {const canvas = createRasterCanvas(W, H);const ctx = canvas.getContext("2d") as CanvasRenderingContext2D | null;if (!ctx) throw new Error("No 2D context for the specimen.");- ctx.fillStyle = "#ffffff";+ ctx.fillStyle = SPECIMEN_BG;ctx.fillRect(0, 0, W, H);- ctx.fillStyle = "#111111";+ ctx.fillStyle = SPECIMEN_INK;ctx.textAlign = "center";ctx.textBaseline = "middle";ctx.font = `${PROBE}px "${family}"`;- const widest = ctx.measureText(SPECIMEN_LINES[0]).width;+ const widest = ctx.measureText(SPECIMEN_ALPHABET[0]).width;const size = widest > 0 ? (PROBE * (W - PAD * 2)) / widest : PROBE;ctx.font = `${size}px "${family}"`;const step = size * 1.35;- SPECIMEN_LINES.forEach((line, i) => {- ctx.fillText(line, W / 2, H / 2 + (i - 1) * step);+ const mid = (SPECIMEN_ALPHABET.length - 1) / 2;+ SPECIMEN_ALPHABET.forEach((line, i) => {+ ctx.fillText(line, W / 2, H / 2 + (i - mid) * step);});return rasterCanvasToPng(canvas);}diff --git a/site/src/cut/lib/library.ts b/site/src/cut/lib/library.tsindex 71070581..b3367b4b 100644--- a/site/src/cut/lib/library.ts+++ b/site/src/cut/lib/library.ts@@ -8,7 +8,7 @@ import { downloadFromUrl } from "./download";import { normalizeLink } from "./link";import { installFontFace } from "./fontAssets";import { fontLabelFor } from "./fontName";-import { specimenPng } from "./fontSpecimen";+import { SPECIMEN_FILE_SUFFIX, specimenPng } from "./fontSpecimen";import {enrichAsset,importRemote,@@ -395,7 +395,9 @@ export async function carryAssetTo(`/api/cut/library/media/${encodeURIComponent(asset.fileName)}`,);if (!res.ok) throw new Error("Could not read that file off its shelf.");- const from = libraryPosterUrl(asset);+ // A font's cover is baked from its bytes on the way in, so the shelf it+ // lands on draws its own — always the current sheet.+ const from = asset.type === "font" ? undefined : libraryPosterUrl(asset);const cover = from? await backendFor(asset.residency).fetch(@@ -460,7 +462,7 @@ export async function uploadToLibrary(const font = isFontFile(file) ? await checkFont(file) : null;const fontLabel = font?.label ?? null;const poster = keep.poster ?? font?.poster ?? null;- const posterName = `${file.name}.specimen.png`;+ const posterName = `${file.name}${SPECIMEN_FILE_SUFFIX}`;const fontMeta = { type: "font" as const, duration: 0 };if (residency === "cloud") {// Presign -> direct R2 PUT -> complete, with the media probed here — thediff --git a/site/src/cut/lib/media.ts b/site/src/cut/lib/media.tsindex e527f02e..f9cac1d8 100644--- a/site/src/cut/lib/media.ts+++ b/site/src/cut/lib/media.ts@@ -155,6 +155,11 @@ export function isFontFile(file: File) {return file.type.startsWith("font/") || /\.(ttf|otf|woff2?)$/i.test(file.name);}+/** The kind mark a card wears for a file: its extension, uppercased. Empty for+ * a name that carries none. */+export const fileKind = (fileName: string) =>+ (/\.([a-z0-9]+)$/i.exec(fileName)?.[1] ?? "").toUpperCase();+/** Fonts are small; a file past this is a mistake worth catching before the* bytes move. The storage quota is the real ceiling. */export const MAX_FONT_BYTES = 10 * 1024 ** 2;diff --git a/site/src/cut/lib/types.ts b/site/src/cut/lib/types.tsindex 45f2740b..eca4a4a9 100644--- a/site/src/cut/lib/types.ts+++ b/site/src/cut/lib/types.ts@@ -841,6 +841,12 @@ export function onFontsChanged(cb: () => void): () => void {return () => fontListeners.delete(cb);}+/** Whether the registry holds this id, which is to say the face behind it is+ * installed and will draw. Registration happens after the bytes install, so a+ * hit here means live text shows the typeface rather than the fallback face. */+export const hasFont = (id: string) =>+ FONTS.some((f) => f.id === id) || registeredFonts.some((f) => f.id === id);+/** CSS stack for a font id, tolerant of unknown ids (falls back to the first* font) so kit-typed elements and older docs always resolve to something. */export const fontStack = (id: string) =>