2024-01-10 11:35:21 +03:00
|
|
|
import { writeFile } from 'node:fs/promises';
|
|
|
|
import { join } from 'node:path';
|
|
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
|
2024-09-06 13:54:18 +03:00
|
|
|
import { AffineCanvasTextFonts } from '@blocksuite/blocks';
|
2024-01-10 11:35:21 +03:00
|
|
|
|
|
|
|
const fontPath = join(
|
|
|
|
fileURLToPath(import.meta.url),
|
|
|
|
'..',
|
|
|
|
'..',
|
|
|
|
'packages',
|
|
|
|
'frontend',
|
2024-10-16 08:12:40 +03:00
|
|
|
'core',
|
|
|
|
'public',
|
|
|
|
'fonts'
|
2024-01-10 11:35:21 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
await Promise.all(
|
2024-05-17 08:27:43 +03:00
|
|
|
AffineCanvasTextFonts.map(async ({ url }) => {
|
2024-01-10 11:35:21 +03:00
|
|
|
const buffer = await fetch(url).then(res =>
|
|
|
|
res.arrayBuffer().then(res => Buffer.from(res))
|
|
|
|
);
|
|
|
|
const filename = url.split('/').pop();
|
|
|
|
const distPath = join(fontPath, filename);
|
|
|
|
await writeFile(distPath, buffer);
|
|
|
|
console.info(`Downloaded ${distPath} successfully`);
|
|
|
|
})
|
|
|
|
);
|