diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..86ef470 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,31 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}\\index.js", + "args": [ + "--max_old_space_size=8192", + "--optimize_for_size", + "--stack_size=4096", + "--require", + "babel-core/register", + "--config=./src/config/catus.bottom.js", + "--data=src/data-small-org.json", + "--font-name=Leo-Pinyin-Bottom", + "--base-font=resources/fonts/NotoSerifSC-Regular.ttf", + "--ruby-font=resources/fonts/LXGWWenKaiMono-Regular.ttf", + ] + } + ] +} + + diff --git a/TODO.md b/TODO.md index 4fcc69e..b431f3a 100644 --- a/TODO.md +++ b/TODO.md @@ -1,8 +1,9 @@ 8TODO List -- [ ] Remove chars that not in input fonts- [X] Build serif version +- [ ] Change the font names to be without '-' +- [ ] Include the built fonts in 'input' folder +- [ ] Remove chars that not in input fonts +- [X] Build serif version - [ ] Tạo thêm hình ảnh font sau khi tạo ra - [ ] Make right option - [X] Build 4 variants: top/bottom/left/right - [X] Change font output folder to `output` -- [ ] Change the font names to be without '-' -- [ ] Include the built fonts in 'input' folder diff --git a/build_bottom_full.sh b/build_bottom_full.sh index 8d4a181..5e587fa 100755 --- a/build_bottom_full.sh +++ b/build_bottom_full.sh @@ -1,5 +1,5 @@ rm -f build/svg/* -time node --max_old_space_size=8192 --optimize_for_size --stack_size=4096 --require babel-core/register ./index.js --config=./src/config/bottom.js --data=src/data-org.json --font-name=Leo-Pinyin-Bottom --base-font=resources/fonts/NotoSerifSC-Regular.ttf --ruby-font=resources/fonts/LXGWWenKaiMono-Regular.ttf +time node --max_old_space_size=8192 --optimize_for_size --stack_size=4096 --require babel-core/register ./index.js --config=./src/config/catus.bottom.js --data=src/data-org.json --font-name=Leo-Pinyin-Bottom --base-font=resources/fonts/NotoSerifSC-Regular.ttf --ruby-font=resources/fonts/LXGWWenKaiMono-Regular.ttf -python3 tools/font_stats.py build/Leo-Pinyin-Bottom.ttf --detailed \ No newline at end of file +#python3 tools/font_stats.py build/Leo-Pinyin-Bottom.ttf --detailed \ No newline at end of file diff --git a/find_coderanges.py b/find_coderanges.py index 15676af..592fac9 100644 --- a/find_coderanges.py +++ b/find_coderanges.py @@ -546,6 +546,7 @@ def get_unicode_ranges_with_names(font_path): font_path = "resources/fonts/LXGWWenKaiMono-Regular.ttf" font_path = "resources/fonts/SourceHanSansCN-Regular.ttf" font_path = "resources/fonts/WqyMono.ttf" +font_path = "output/Pinyin-Test-Bottom-Small.ttf" get_unicode_ranges_with_names(font_path) diff --git a/index.js b/index.js index 5f045f1..cd94ea2 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,34 @@ -import webfont from 'webfont' import jsonfile from 'jsonfile' +import webfont from 'webfont' import { argv } from 'yargs' + + + + + import helpers from './src/helpers' import ruby from './src/ruby' import svg from './src/svg' + + + + + function generateSvg(data, config) { const baseEngine = ruby.loadFont(config.baseFontFilepath) const rubyEngine = ruby.loadFont(config.rubyFontFilepath) + const build_folder = `${config.workingDir}` + + const fs = require('fs'); + + if (!fs.existsSync(build_folder)) { + fs.mkdirSync(build_folder, { recursive: true }); + console.log(`Folder created: ${build_folder}`); + } else { + console.log(`Folder already exists: ${build_folder}`); + } for (let datum = 0; datum < data.length; datum += 1) { const char = data[datum] diff --git a/resources/Hanzi-Pinyin-Font.top (1).ttf b/resources/fonts/Hanzi-Pinyin-Font.top.ttf similarity index 100% rename from resources/Hanzi-Pinyin-Font.top (1).ttf rename to resources/fonts/Hanzi-Pinyin-Font.top.ttf