Use Google Fonts API v2 to get fonts for ogp

This commit is contained in:
Akihiro Saiki 2025-01-05 01:46:05 +09:00
parent c98ef7e89f
commit eb0e84f9bb
No known key found for this signature in database

View File

@ -35,7 +35,9 @@ export async function getSatoriFont(headerFontName: string, bodyFontName: string
async function fetchTtf(fontName: string, weight: FontWeight): Promise<ArrayBuffer> {
try {
// Get css file from google fonts
const cssResponse = await fetch(`https://fonts.googleapis.com/css?family=${fontName}:${weight}`)
const cssResponse = await fetch(
`https://fonts.googleapis.com/css2?family=${fontName}:wght@${weight}`,
)
const css = await cssResponse.text()
// Extract .ttf url from css file