Skip to content

Commit

Permalink
feat: add punctuation marks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 25, 2024
1 parent c95eabf commit ab04470
Show file tree
Hide file tree
Showing 221 changed files with 653 additions and 470 deletions.
13 changes: 8 additions & 5 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
max-width: 1024px;
margin: 0 auto;
text-align: center;
line-height: 0.85;
}
.download {
text-align: center;
Expand Down Expand Up @@ -91,7 +90,7 @@ <h1>宝宝字帖<ruby>拼音字体<rt>Pinyin Font</rt></ruby><sup>v1.7.0</sup></
</header>
<h2><ruby>拼音笔顺体<rt>Pinyin Step Font</rt></ruby></h2>
<p spellcheck="false" contenteditable="true">
Hello World 1987
H e l l o World 1987
</p>
<p>
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Expand All @@ -109,13 +108,17 @@ <h2><ruby>拼音常规体<rt>Pinyin Regular Font</rt></ruby></h2>
<p class="regular" spellcheck="false" contenteditable="true">
Hello World 1987
</p>
<p class="regular">
<p class="regular" style="font-size: 32px;" spellcheck="false" contenteditable="true">
Lorem ipsum dolor sit amet, consectetur adipiscing elit? Sed do eiusmod 'tempor' incididunt ut labore et "dolore" magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</p>
<p class="regular" style="font-size: 32px;">
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
</p>
<p class="regular">
<p class="regular" style="font-size: 32px;">abcdefghijklmnopqrstuvwxyz</p>
<p class="regular" style="font-size: 62px;">
a b c d e f g h i j k l m n o p q r s t u v w x y z
</p>
<p class="regular">
<p class="regular" style="font-size: 62px;">
ā á ǎ à ō ó ǒ ò ē é ě è ī í ǐ ì ū ú ǔ ù ǖ ǘ ǚ ǜ ü ai ei ui ao ou iu ie üe er an en in un ün zhì
</p>
<p class="regular">
Expand Down
335 changes: 196 additions & 139 deletions docs/pinyin-regular.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/pinyin-regular.ttf
Binary file not shown.
Binary file modified docs/pinyin-regular.woff2
Binary file not shown.
335 changes: 196 additions & 139 deletions docs/pinyin-step.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/pinyin-step.ttf
Binary file not shown.
Binary file modified docs/pinyin-step.woff2
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"author": "jaywcjlove",
"license": "MIT",
"devDependencies": {
"@types/svg2ttf": "^5.0.3",
"fs-extra": "^11.2.0",
"semver": "^7.6.3",
"svg2ttf": "^6.0.3",
Expand Down
53 changes: 40 additions & 13 deletions scripts/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,53 @@ export function filterSvgFiles(svgFolderPath) {
return svgArr;
}

function charToSvgFontUnicode(char) {
// 获取字符的 Unicode 码点
let unicode = char.codePointAt(0);
// 转换为十六进制格式,并大写表示
let unicodeHex = unicode.toString(16).toUpperCase();
// 格式化为 SVG 字体使用的 Unicode 表示
let svgFontUnicode = `&#x${unicodeHex};`;
return svgFontUnicode;
}
/// 符号
const symbol = {
space: ' ', // 普通空格
nonBreakingSpace: '\u00A0', // 不间断空格
enSpace: '\u2002', // 半个空格
emSpace: '\u2003', // 全个空格
quarterEmSpace: '\u2005', // 四分之一空格
thinSpace: '\u2009', // 细空格
zeroWidthSpace: '\u200B', // 零宽度空格
ideographicSpace: '\u3000', // 全角空格
narrowNoBreakSpace: '\u202F', // 窄不间断空格(可选)
mediumMathematicalSpace: '\u205F', // 中等数学空格(可选)
zeroWidthNonJoiner: '\u200C', // 零宽度非连接符(可选)
zeroWidthJoiner: '\u200D', // 零宽度连接符(可选)

period: ".", // 句号
comma: ",", // 逗号
question: "?", // 问号
exclamation: "!", // 感叹号
colon: ":", // 冒号
semicolon: ";", // 分号
apostrophe: "'", // 单引号
quotation: '"', // 双引号
leftBrace: "{", // 左大括号
rightBrace: "}", // 右大括号
leftParenthesis: "(", // 左小括号
rightParenthesis: ")", // 右小括号
leftBracket: "[", // 左中括号
rightBracket: "]", // 右中括号
hyphen: "-", // 连字符
underscore: "_", // 下划线
ampersand: "&", // 与
atSign: "@", // @
};

function writeFontStream(svgPath, fontStream) {
const fileNmae = path.basename(svgPath, ".svg");
let unicodeName = fileNmae;
if (unicodeName.endsWith('_')) {
unicodeName = unicodeName.replace(/_$/g, '');
}
const glyph = fs.createReadStream(svgPath)
//console.log(`\n ┌┈▶ ${fileNmae} ${charToSvgFontUnicode(unicodeName)}`);
glyph.metadata = { unicode: [unicodeName] , name: fileNmae };
if (symbol[unicodeName]) {
unicodeName = symbol[unicodeName];
}
const glyph = fs.createReadStream(svgPath);
//console.log(`\n ┌┈▶ ${fileNmae} ${unicode}`);
glyph.metadata = { unicode: [unicodeName.normalize('NFC')] , name: fileNmae.replace(/_$/g, '') };
fontStream.write(glyph);
}

Expand Down Expand Up @@ -77,7 +105,6 @@ function svgToSVGFont(fontName = "pinyin",src = "svg", dist = "./docs/pinyin.svg
}
// Update version in docs/index.html
const pkg = fs.readJsonSync('./package.json');

function svgFontToTTF(src = "./docs/pinyin.svg", dist = "./docs/pinyin.ttf") {
const svgFont = fs.readFileSync(src, "utf8");
const version = semver.parse(pkg.version);
Expand Down
2 changes: 1 addition & 1 deletion svg/regular/0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion svg/regular/1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion svg/regular/2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ab04470

Please sign in to comment.