Skip to content

Commit 7460389

Browse files
committed
feat: add copyright.
1 parent edc427f commit 7460389

6 files changed

+11
-3
lines changed

docs/pinyin-regular.ttf

328 Bytes
Binary file not shown.

docs/pinyin-regular.woff2

96 Bytes
Binary file not shown.

docs/pinyin-step.ttf

328 Bytes
Binary file not shown.

docs/pinyin-step.woff2

176 Bytes
Binary file not shown.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"license": "MIT",
1717
"devDependencies": {
1818
"fs-extra": "^11.2.0",
19+
"semver": "^7.6.3",
1920
"svg2ttf": "^6.0.3",
2021
"svgicons2svgfont": "^12.0.0",
2122
"ttf2woff": "^3.0.0",

scripts/main.mjs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from 'fs-extra';
22
import path from 'path';
3+
import semver from 'semver';
34
import SVGIcons2SVGFont from 'svgicons2svgfont';
45
import svg2ttf from 'svg2ttf';
56
import ttf2woff2 from 'ttf2woff2';
@@ -74,10 +75,18 @@ function svgToSVGFont(fontName = "pinyin",src = "svg", dist = "./docs/pinyin.svg
7475
fontStream.end();
7576
});
7677
}
78+
// Update version in docs/index.html
79+
const pkg = fs.readJsonSync('./package.json');
7780

7881
function svgFontToTTF(src = "./docs/pinyin.svg", dist = "./docs/pinyin.ttf") {
7982
const svgFont = fs.readFileSync(src, "utf8");
80-
const ttf = svg2ttf(svgFont, {});
83+
const version = semver.parse(pkg.version);
84+
const ttf = svg2ttf(svgFont, {
85+
description: "Pinyin font specifically designed for the app 'Baby Copybook'.",
86+
copyright: "Copyright (c) 2024, Wang Chujiang <https://wangchujiang.com>",
87+
url: "https://github.com/jaywcjlove/pinyin-font",
88+
version: `Version ${version.major}.${version.minor}`,
89+
});
8190
const ttfBuf = Buffer.from(ttf.buffer);
8291
fs.writeFileSync(dist, ttfBuf);
8392
console.log(`SUCCESS TTF font successfully created!\n ╰┈▶ ${dist}`);
@@ -101,8 +110,6 @@ function ttfTowoff2(src = "./docs/pinyin.ttf", dist = "./docs/pinyin.woff2") {
101110
svgFontToTTF("./docs/pinyin-regular.svg", "./docs/pinyin-regular.ttf");
102111
ttfTowoff2("./docs/pinyin-regular.ttf", "./docs/pinyin-regular.woff2");
103112

104-
// Update version in docs/index.html
105-
const pkg = fs.readJsonSync('./package.json');
106113
const fileContent = fs.readFileSync('./docs/index.html', 'utf-8');
107114
const updatedContent = fileContent.replace(/<sup>.*<\/sup>/g, `<sup>v${pkg.version}</sup>`)
108115
.replace(/url\('.\/pinyin-step\.ttf.*'\)\s/g, `url('./pinyin-step.ttf?v=${pkg.version}') `)

0 commit comments

Comments
 (0)