Files
songs2vid/scripts/fetch-watermark-fonts.mjs
T
Atakan Doğan Özban 9404efd86c Align preview typography with FFmpeg output, add video/song title split, and ship OSS updates.
Separate YouTube video titles from on-video song/artist fields with Pro gating, serve curated fonts and watermark assets for 1:1 preview parity, and include billing/API/docs/deploy stack for self-hosted release.
2026-07-27 16:26:19 +02:00

72 lines
1.9 KiB
JavaScript

/**
* Download curated watermark fonts into assets/fonts for FFmpeg drawtext.
* Run: node scripts/fetch-watermark-fonts.mjs
*/
import fs from "fs/promises";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const outDir = path.join(__dirname, "..", "assets", "fonts");
/** Direct TTF URLs from Google Fonts GitHub (OFL). */
const FONTS = [
{
file: "Inter-Regular.ttf",
url: "https://github.com/google/fonts/raw/main/ofl/inter/Inter%5Bopsz%2Cwght%5D.ttf",
},
{
file: "Montserrat-Regular.ttf",
url: "https://github.com/google/fonts/raw/main/ofl/montserrat/Montserrat%5Bwght%5D.ttf",
},
{
file: "Roboto-Regular.ttf",
url: "https://github.com/google/fonts/raw/main/ofl/roboto/Roboto%5Bwdth%2Cwght%5D.ttf",
},
{
file: "Oswald-Regular.ttf",
url: "https://github.com/google/fonts/raw/main/ofl/oswald/Oswald%5Bwght%5D.ttf",
},
{
file: "PlayfairDisplay-Regular.ttf",
url: "https://github.com/google/fonts/raw/main/ofl/playfairdisplay/PlayfairDisplay%5Bwght%5D.ttf",
},
];
await fs.mkdir(outDir, { recursive: true });
for (const font of FONTS) {
const dest = path.join(outDir, font.file);
try {
await fs.access(dest);
console.log("skip (exists)", font.file);
continue;
} catch {
/* download */
}
console.log("fetch", font.file);
const res = await fetch(font.url, {
headers: { "User-Agent": "songs2vid-font-fetch/1.0" },
redirect: "follow",
});
if (!res.ok) {
console.error("FAILED", font.file, res.status);
continue;
}
const buf = Buffer.from(await res.arrayBuffer());
await fs.writeFile(dest, buf);
console.log("wrote", font.file, buf.length, "bytes");
}
await fs.writeFile(
path.join(outDir, "README.md"),
`# Watermark fonts
Curated TTF assets for FFmpeg \`drawtext\` (OFL via Google Fonts).
Refresh with \`node scripts/fetch-watermark-fonts.mjs\`.
`,
"utf8",
);
console.log("done →", outDir);