28d9c29b35
- 添加 .gitignore 配置 - 添加 HTML 简历模板 (resume.html) - 添加转换脚本 (convert.js, convert.py) - 添加字体下载脚本 (download_font.js) - 添加项目配置 (package.json)
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
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();
|