Files
resume/download_font.js
T

39 lines
1.3 KiB
JavaScript
Raw Normal View History

2026-07-11 10:16:46 +08:00
const https = require('https');
const fs = require('fs');
const path = require('path');
function downloadFile(url, dest) {
return new Promise((resolve, reject) => {
const file = fs.createWriteStream(dest);
https.get(url, (response) => {
response.pipe(file);
file.on('finish', () => {
file.close();
resolve();
});
}).on('error', (err) => {
fs.unlink(dest, () => {});
reject(err);
});
});
}
async function downloadFonts() {
const fontsDir = path.join(__dirname, 'fonts');
// Download Noto Sans SC Regular
const regularUrl = 'https://fonts.gstatic.com/s/notosanssc/v37/k3kCo84MPvpLmixcA63oeAL7Iqp5IZJF9bmaG9_FnYxNbPzS5HE.ttf';
const boldUrl = 'https://fonts.gstatic.com/s/notosanssc/v37/k3kCo84MPvpLmixcA63oeAL7Iqp5IZJF9bmaG9_EnYxNbPzS5HE.ttf';
try {
await downloadFile(regularUrl, path.join(fontsDir, 'NotoSansSC-Regular.ttf'));
console.log('Downloaded NotoSansSC-Regular.ttf');
await downloadFile(boldUrl, path.join(fontsDir, 'NotoSansSC-Bold.ttf'));
console.log('Downloaded NotoSansSC-Bold.ttf');
} catch (err) {
console.error('Error downloading fonts:', err);
}
}
downloadFonts();