end to end app store screenshot creation using AI
TypeScript agentic-aiappleappstoreautomateclaudecursordesigngenerateiosios-appmarketingscreenshotskillsskills-shswiftswiftuiui
fix: default screenshot font to the template's Inter and preload imported fonts
Parth Jadhava1f020611ba9
diff --git a/skills/app-store-screenshots/template/docs/screenshot-fonts.md b/skills/app-store-screenshots/template/docs/screenshot-fonts.mdindex 8784b2c..eb8b2f4 100644--- a/skills/app-store-screenshots/template/docs/screenshot-fonts.md+++ b/skills/app-store-screenshots/template/docs/screenshot-fonts.md@@ -4,6 +4,7 @@ Use the **Font** menu in the toolbar to change the typeface used on the screensh## Included choices+- **Inter (default)** keeps the editor's Inter font, which is what projects created before the font menu existed use.- **Editorial Serif** uses Georgia.- **Modern Sans** uses the device’s clean system sans-serif font.- **Classic Serif** uses Georgia.@@ -16,7 +17,7 @@ Use the **Font** menu in the toolbar to change the typeface used on the screensh2. Choose a licensed WOFF2, WOFF, TTF, or OTF file. It is copied to `public/fonts/imported/` and used immediately in previews and exports.3. You can also add a WOFF2, WOFF, TTF, or OTF file manually as `public/fonts/imported/custom-screenshot-font.<extension>`, choose **Import a font**, and the editor uses it when no imported file has been selected.-The selected font is saved in `app-store-screenshots.json` as `fontId`.+The selected font is saved in `app-store-screenshots.json` as `fontId`; projects without one use Inter.## Relevant codediff --git a/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsx b/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsxindex 4f16391..7cff375 100644--- a/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsx+++ b/skills/app-store-screenshots/template/src/components/editor/screenshot-editor.tsx@@ -3,6 +3,7 @@ import * as React from "react";import JSZip from "jszip";import { Toaster, toast } from "sonner";import {+ DEFAULT_SCREENSHOT_FONT_ID,getExportSizes,hasTheme,SCREENSHOT_FONTS,@@ -46,7 +47,7 @@ export function ScreenshotEditor() {const theme = themeById(state.themeId);const fontFamily = state.fontId === "self-hosted" && state.importedFont? '"ImportedScreenshotFont", Georgia, serif'- : SCREENSHOT_FONTS[state.fontId || "system-sans"].family;+ : SCREENSHOT_FONTS[state.fontId || DEFAULT_SCREENSHOT_FONT_ID].family;const fontFaceCss = state.importedFont? `@font-face { font-family: "ImportedScreenshotFont"; src: url("${state.importedFont.src}") format("${state.importedFont.format}"); font-display: swap; }`: undefined;@@ -432,6 +433,9 @@ export function ScreenshotEditor() {// matches what's on screen.if (typeof document !== "undefined" && document.fonts && document.fonts.ready) {try {+ // fonts.ready only covers faces already requested; explicitly load an+ // imported font so a not-yet-used face can't export as the fallback.+ if (state.fontId === "self-hosted") await document.fonts.load(`64px ${fontFamily}`);await document.fonts.ready;} catch {/* ignore */@@ -585,7 +589,7 @@ export function ScreenshotEditor() {setThemeId={(v) => setState((p) => ({ ...p, themeId: v }))}connectedCanvas={state.connectedCanvas}setConnectedCanvas={(v) => setState((p) => ({ ...p, connectedCanvas: v }))}- fontId={state.fontId || "system-sans"}+ fontId={state.fontId || DEFAULT_SCREENSHOT_FONT_ID}setFontId={(v) => setState((p) => ({ ...p, fontId: v }))}importedFont={state.importedFont}setImportedFont={(importedFont) => setState((p) => ({ ...p, fontId: "self-hosted", importedFont }))}diff --git a/skills/app-store-screenshots/template/src/lib/constants.ts b/skills/app-store-screenshots/template/src/lib/constants.tsindex c9e8e35..e4a4341 100644--- a/skills/app-store-screenshots/template/src/lib/constants.ts+++ b/skills/app-store-screenshots/template/src/lib/constants.ts@@ -160,9 +160,15 @@ export function macW(cW: number, cH: number, clamp = 0.86) {// ---------- Themes ----------export const DEFAULT_THEME_ID: ThemeId = "clean-light";-export const DEFAULT_SCREENSHOT_FONT_ID: ScreenshotFontId = "system-sans";+export const DEFAULT_SCREENSHOT_FONT_ID: ScreenshotFontId = "template-default";export const SCREENSHOT_FONTS: Record<ScreenshotFontId, { name: string; family: string }> = {+ // Inherit the editor's Inter (next/font in app/layout.tsx), which is what the+ // canvas rendered before fonts were selectable, so existing decks don't shift.+ "template-default": {+ name: "Inter (default)",+ family: "inherit",+ },"template-serif": {name: "Editorial Serif",family: "Georgia, 'Times New Roman', serif",diff --git a/skills/app-store-screenshots/template/src/lib/storage.ts b/skills/app-store-screenshots/template/src/lib/storage.tsindex 23dd7d8..b13995a 100644--- a/skills/app-store-screenshots/template/src/lib/storage.ts+++ b/skills/app-store-screenshots/template/src/lib/storage.ts@@ -121,9 +121,10 @@ function mergeWithDefaults(parsed: Partial<ProjectState>): ProjectState {typeof parsed.themeId === "string" && parsed.themeId.trim()? parsed.themeId: DEFAULT_PROJECT.themeId;- const fontId = parsed.fontId && parsed.fontId in SCREENSHOT_FONTS- ? parsed.fontId- : DEFAULT_SCREENSHOT_FONT_ID;+ const fontId =+ typeof parsed.fontId === "string" && Object.prototype.hasOwnProperty.call(SCREENSHOT_FONTS, parsed.fontId)+ ? parsed.fontId+ : DEFAULT_SCREENSHOT_FONT_ID;const importedFont = cleanImportedFont(parsed.importedFont);const slidesByDevice = parsed.slidesByDevice? Object.fromEntries(diff --git a/skills/app-store-screenshots/template/src/lib/types.ts b/skills/app-store-screenshots/template/src/lib/types.tsindex 4bc6d0f..b19fde4 100644--- a/skills/app-store-screenshots/template/src/lib/types.ts+++ b/skills/app-store-screenshots/template/src/lib/types.ts@@ -124,6 +124,7 @@ export type ThemeId =| "vintage-travel-poster";export type ScreenshotFontId =+ | "template-default"| "template-serif"| "system-sans"| "classic-serif"