improve scripts and docs

This commit is contained in:
subframe7536 2023-07-26 20:36:12 +08:00
parent 1d301f5d1c
commit 47b25e073b
5 changed files with 86 additions and 25 deletions

View file

@ -145,13 +145,30 @@ compatibility & usage: in <a href="https://github.com/tonsky/FiraCode#editor-com
## Build
```
git clone https://github.com/subframe7536/Maple-font
cd Maple-font/source
pip install afdko
to patch Nerd Font, make sure `fontforge` and its Python module is installed
you can adjust some config in `source/build.py`
more fine-grained options can be set at the comming V7
### Normal Build
```shell
git clone https://github.com/subframe7536/Maple-font --depth 1
cd ./Maple-font/source
pip install -r requirements.txt
python build.py
```
### Build font with Chinese characters
```shell
git clone https://github.com/subframe7536/Maple-font --depth 1 -b chinese
cd ./Maple-font/source
pip install -r requirements.txt
./generate-sc.bat
```
## Donate
If this was helpful to you, please feel free to buy me a coffee

View file

@ -139,10 +139,16 @@
## 构建
```
git clone https://github.com/subframe7536/Maple-font
cd Maple-font/source
pip install fonttools
如果你需要使用 Nerd Font请确保你已经安装了 fontforge
你可以在 `source/build.py` 调整部分设置
更细致的设置请等待 V7
```shell
git clone https://github.com/subframe7536/Maple-font --depth 1
cd ./Maple-font/source
pip install -r requirements.txt
python build.py
```
@ -161,6 +167,15 @@ python build.py
<img src="./img/CE21.png" alt="logo">
</p>
### 构建
```shell
git clone https://github.com/subframe7536/Maple-font --depth 1 -b chinese
cd ./Maple-font/source
pip install -r requirements.txt
./generate-sc.bat
```
## Maple UI
> 自改自用的字体,用的是 Google Sans 英数 + 汉仪正圆的汉字,侵删

View file

@ -5,8 +5,11 @@ from os import path, getcwd, makedirs, listdir, remove, write
from subprocess import run
from zipfile import ZipFile
from urllib.request import urlopen
import platform
from ttfautohint import ttfautohint
config = {
"nerd_font": False, # whether to use nerd font
"mono": False, # whether to use half width icon
"family_name": "Maple Mono", # font family name
"nf_use_hinted_ttf": True, # whether to use hinted ttf to generate Nerd Font
@ -48,18 +51,10 @@ mkdirs(path.join(output_path, "ttf-autohint"))
mkdirs(path.join(output_path, "woff2"))
print("=== build start ===")
def auto_hint(f: str, ttf_path: str):
run(
[
"python",
"-m",
"ttfautohint",
ttf_path,
path.join(output_path, "ttf-autohint", f + ".ttf"),
]
ttfautohint(
in_file=ttf_path,
out_file=path.join(output_path, "ttf-autohint", f + ".ttf"),
)
@ -69,7 +64,10 @@ def generate_nerd_font(f: str):
run(
[
path.join(root, "generate-nerdfont.bat"),
path.join(
root,
f"generate-nerdfont.{'bat' if platform.system() == 'Windows' else 'sh'}",
),
f,
get_arg("mono"),
get_arg("nf_use_hinted_ttf"),
@ -117,6 +115,7 @@ def generate_nerd_font(f: str):
remove(nf_path)
print("=== build start ===")
for f in listdir(ttx_path):
print(f)
@ -148,7 +147,8 @@ for f in listdir(ttx_path):
font.close()
generate_nerd_font(f)
if config["nerd_font"]:
generate_nerd_font(f)
woff2.compress(otf_path, path.join(output_path, "woff2", f + ".woff2"))

View file

@ -3,7 +3,7 @@
set python_exe="C:\Program Files (x86)\FontForgeBuilds\bin\ffpython.exe"
set font_dir=..\output\ttf
set output_dir=..\output\NF
set args=-l -c --careful --debug 1
set args=-l -c --careful
if not exist %font_dir% (
echo Font directory does not exist: %font_dir%
@ -27,6 +27,4 @@ if not exist %font_path% (
exit /b 1
)
%python_exe% %cd%\FontPatcher\font-patcher %args% --outputdir %output_dir% %font_path%
echo Font patched successfully!
%python_exe% %cd%\FontPatcher\font-patcher %args% --outputdir %output_dir% %font_path%

View file

@ -0,0 +1,31 @@
#!/bin/bash
font_dir="../output/ttf"
output_dir="../output/NF"
args="-l -c --careful"
if [ ! -d $font_dir ]; then
echo "Font directory does not exist: $font_dir"
exit 1
fi
font_name=$1
if [ $2 -eq 1 ]; then
args="$args -s"
fi
if [ $3 -eq 1 ]; then
font_dir=$font_dir-autohint
fi
font_path=$font_dir/$font_name.ttf
if [ ! -f $font_path ]; then
echo "Font file does not exist: $font_path"
exit 1
fi
fontforge -script ./FontPatcher/font-patcher $args --outputdir $output_dir $font_path
echo "Font patched successfully!"