support italic feature freeze config and add normal preset
This commit is contained in:
parent
eb4f226904
commit
db18eb97f5
6 changed files with 220 additions and 31 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
node_modules
|
||||
.astro
|
||||
node_modules
|
||||
dist
|
||||
/FontPatcher
|
||||
/fonts
|
||||
/source/cn/static
|
35
README.md
35
README.md
|
@ -37,20 +37,14 @@ Base on `Jetbrains Mono` and **much "Opinioned"**
|
|||
- cv04: Alternative `l` (with bottom left bar) and `1` (without bottom bar)
|
||||
- cv98: Full width `…`(ellipsis) and `—`(emdash) support for Maple Mono NF CN
|
||||
- cv99: Traditional punctuations support for Maple Mono NF CN
|
||||
- ss01: Non-cursive italic style `f l i j x y`
|
||||
- ss01: Non-cursive italic style `l i j k x`
|
||||
- ss02: Disable ligautures on equals like `==` / `!=` / `<=`
|
||||
- ss03: Ignore cases on all tags
|
||||
- ss04: Disable ligatures on `__`, `#__`, `***`
|
||||
- ss04: Disable ligatures on `__`, `#__`, `***`, `\n`
|
||||
|
||||
## Build
|
||||
|
||||
### Browser
|
||||
|
||||
WIP
|
||||
|
||||
### Local
|
||||
|
||||
clone the repo and run in your local machine.
|
||||
clone the repo and run in your local machine. Make sure you have `python3` and `pip` installed
|
||||
|
||||
```shell
|
||||
git clone https://github.com/subframe7536/maple-font --depth 1 -b variable
|
||||
|
@ -58,20 +52,23 @@ pip install foundrytools-cli
|
|||
python build.py
|
||||
```
|
||||
|
||||
You can change config in `config.json`
|
||||
|
||||
Make sure you have `python3` and `pip` installed
|
||||
|
||||
- for custom `font-patcher` args, `font-forge` (and maybe `python3-fontforge` as well) is needed
|
||||
- for `Ubuntu` or `Debian`, maybe `python-is-python3` is needed as well
|
||||
|
||||
```shell
|
||||
pip install foundrytools-cli
|
||||
python build.py
|
||||
```
|
||||
|
||||
If you have trouble to install the dependencies, just create a new Github codespace on `variable` branch and run the commands there
|
||||
|
||||
### Customize
|
||||
|
||||
You can change build config in `config.json`
|
||||
|
||||
- There is `--normal` option in `build.py` for common config, just like `Jetbrains Mono` (with slashed zero)
|
||||
- For custom `font-patcher` args, `font-forge` (and maybe `python3-fontforge` as well) is needed
|
||||
|
||||
### Chinses version
|
||||
|
||||
1. Download CN base font at [Gitee release](https://gitee.com/subframe7536/Maple/releases/tag/v7.0-beta22-cn)
|
||||
2. put them into `./source/cn`
|
||||
3. run `build.py` and **BE PATIENT**, instantiation will take about 15 minutes
|
||||
|
||||
## credit
|
||||
|
||||
- [Jetbrains Mono](https://github.com/JetBrains/JetBrainsMono)
|
||||
|
|
43
build.py
43
build.py
|
@ -29,6 +29,9 @@ if not package_installed:
|
|||
# whether to archieve fonts
|
||||
release_mode = "--release" in sys.argv
|
||||
|
||||
# whether to use normal preset
|
||||
use_normal = "--normal" in sys.argv
|
||||
|
||||
# =========================================================================================
|
||||
|
||||
WIN_FONTFORGE_PATH = "C:/Program Files (x86)/FontForgeBuilds/bin/fontforge.exe"
|
||||
|
@ -68,6 +71,19 @@ build_config = {
|
|||
"ss04": "ignore",
|
||||
"zero": "ignore",
|
||||
},
|
||||
"feature_freeze_italic": {
|
||||
"cv01": "ignore",
|
||||
"cv02": "ignore",
|
||||
"cv03": "ignore",
|
||||
"cv04": "ignore",
|
||||
"cv98": "ignore",
|
||||
"cv99": "ignore",
|
||||
"ss01": "ignore",
|
||||
"ss02": "ignore",
|
||||
"ss03": "ignore",
|
||||
"ss04": "ignore",
|
||||
"zero": "ignore",
|
||||
},
|
||||
# nerd font settings
|
||||
"nerd_font": {
|
||||
# whether to enable Nerd Font
|
||||
|
@ -105,7 +121,7 @@ build_config = {
|
|||
}
|
||||
|
||||
try:
|
||||
with open("config.json", "r") as f:
|
||||
with open("./source/preset-normal.json" if use_normal else "config.json", "r") as f:
|
||||
data = json.load(f)
|
||||
if "$schema" in data:
|
||||
del data["$schema"]
|
||||
|
@ -268,12 +284,13 @@ def get_font_name(style_name_compact: str):
|
|||
_style_name = style_name_compact[:-6] + " Italic"
|
||||
|
||||
if style_name_compact in skip_subfamily_list:
|
||||
return "", _style_name, _style_name
|
||||
return "", _style_name, _style_name, is_italic
|
||||
else:
|
||||
return (
|
||||
" " + style_name_compact.replace("Italic", ""),
|
||||
"Italic" if is_italic else "Regular",
|
||||
_style_name,
|
||||
is_italic,
|
||||
)
|
||||
|
||||
|
||||
|
@ -311,7 +328,7 @@ def add_cv98(font):
|
|||
lang_sys_rec.LangSys.FeatureIndex.append(feature_index)
|
||||
|
||||
|
||||
def freeze_feature(font: TTFont):
|
||||
def freeze_feature(font: TTFont, is_italic: bool):
|
||||
# check feature list
|
||||
feature_record = font["GSUB"].table.FeatureList.FeatureRecord
|
||||
feature_dict = {
|
||||
|
@ -325,7 +342,9 @@ def freeze_feature(font: TTFont):
|
|||
]
|
||||
|
||||
# Process features
|
||||
for tag, status in build_config["feature_freeze"].items():
|
||||
for tag, status in build_config[
|
||||
f"feature_freeze{'_italic' if is_italic else ''}"
|
||||
].items():
|
||||
target_feature = feature_dict.get(tag)
|
||||
if not target_feature or status == "ignore":
|
||||
continue
|
||||
|
@ -364,7 +383,7 @@ def build_mono(f: str):
|
|||
|
||||
style_name_compact = f[10:-4]
|
||||
|
||||
style_name1, style_name2, style_name = get_font_name(style_name_compact)
|
||||
style_name1, style_name2, style_name, is_italic = get_font_name(style_name_compact)
|
||||
|
||||
set_font_name(
|
||||
font,
|
||||
|
@ -389,7 +408,7 @@ def build_mono(f: str):
|
|||
elif style_name1 == " ExtraLight":
|
||||
font["OS/2"].usWeightClass = 275
|
||||
|
||||
freeze_feature(font)
|
||||
freeze_feature(font, is_italic)
|
||||
|
||||
font.save(_path)
|
||||
font.close()
|
||||
|
@ -434,7 +453,9 @@ def build_nf(f: str, use_font_patcher: bool):
|
|||
# format font name
|
||||
style_name_compact_nf = f[10:-4]
|
||||
|
||||
style_name_nf1, style_name_nf2, style_name_nf = get_font_name(style_name_compact_nf)
|
||||
style_name_nf1, style_name_nf2, style_name_nf, _ = get_font_name(
|
||||
style_name_compact_nf
|
||||
)
|
||||
|
||||
set_font_name(
|
||||
nf_font,
|
||||
|
@ -473,7 +494,9 @@ def build_cn(f: str):
|
|||
]
|
||||
)
|
||||
|
||||
style_name_cn1, style_name_cn2, style_name_cn = get_font_name(style_name_compact_cn)
|
||||
style_name_cn1, style_name_cn2, style_name_cn, is_italic = get_font_name(
|
||||
style_name_compact_cn
|
||||
)
|
||||
|
||||
set_font_name(
|
||||
font,
|
||||
|
@ -499,7 +522,7 @@ def build_cn(f: str):
|
|||
# https://github.com/subframe7536/maple-font/issues/188
|
||||
add_cv98(font)
|
||||
|
||||
freeze_feature(font)
|
||||
freeze_feature(font, is_italic)
|
||||
|
||||
if build_config["cn"]["fix_meta_table"]:
|
||||
# add code page, Latin / Japanese / Simplify Chinese / Traditional Chinese
|
||||
|
@ -543,6 +566,8 @@ def main():
|
|||
font = TTFont(input_file)
|
||||
font.save(input_file.replace(src_dir, output_variable))
|
||||
|
||||
run(f"ftcli fix italic-angle {output_variable}")
|
||||
run(f"ftcli fix monospace {output_variable}")
|
||||
run(f"ftcli converter vf2i {output_variable} -out {output_ttf}")
|
||||
run(f"ftcli fix italic-angle {output_ttf}")
|
||||
run(f"ftcli fix monospace {output_ttf}")
|
||||
|
|
13
config.json
13
config.json
|
@ -16,6 +16,19 @@
|
|||
"ss04": "ignore",
|
||||
"zero": "ignore"
|
||||
},
|
||||
"feature_freeze_italic": {
|
||||
"cv01": "ignore",
|
||||
"cv02": "ignore",
|
||||
"cv03": "ignore",
|
||||
"cv04": "ignore",
|
||||
"cv98": "ignore",
|
||||
"cv99": "ignore",
|
||||
"ss01": "ignore",
|
||||
"ss02": "ignore",
|
||||
"ss03": "ignore",
|
||||
"ss04": "ignore",
|
||||
"zero": "ignore"
|
||||
},
|
||||
"nerd_font": {
|
||||
"enable": true,
|
||||
"version": "3.2.1",
|
||||
|
|
48
source/preset-normal.json
Normal file
48
source/preset-normal.json
Normal file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"$schema": "./schema.json",
|
||||
"family_name": "Maple Mono",
|
||||
"use_hinted": true,
|
||||
"pool_size": 4,
|
||||
"feature_freeze": {
|
||||
"cv01": "enable",
|
||||
"cv02": "enable",
|
||||
"cv03": "ignore",
|
||||
"cv04": "ignore",
|
||||
"cv98": "ignore",
|
||||
"cv99": "ignore",
|
||||
"ss01": "ignore",
|
||||
"ss02": "ignore",
|
||||
"ss03": "ignore",
|
||||
"ss04": "ignore",
|
||||
"zero": "ignore"
|
||||
},
|
||||
"feature_freeze_italic": {
|
||||
"cv01": "ignore",
|
||||
"cv02": "ignore",
|
||||
"cv03": "ignore",
|
||||
"cv04": "ignore",
|
||||
"cv98": "ignore",
|
||||
"cv99": "ignore",
|
||||
"ss01": "enable",
|
||||
"ss02": "ignore",
|
||||
"ss03": "ignore",
|
||||
"ss04": "ignore",
|
||||
"zero": "ignore"
|
||||
},
|
||||
"nerd_font": {
|
||||
"enable": true,
|
||||
"version": "3.2.1",
|
||||
"mono": false,
|
||||
"use_font_patcher": false,
|
||||
"glyphs": [
|
||||
"--complete"
|
||||
],
|
||||
"extra_args": []
|
||||
},
|
||||
"cn": {
|
||||
"enable": true,
|
||||
"with_nerd_font": true,
|
||||
"fix_meta_table": true,
|
||||
"clean_cache": false
|
||||
}
|
||||
}
|
|
@ -42,7 +42,7 @@
|
|||
},
|
||||
"cv03": {
|
||||
"type": "string",
|
||||
"description": "Alternative 'i' (without bottom left bar)",
|
||||
"description": "Alternative regular 'i' (without bottom left bar)",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
|
@ -78,7 +78,112 @@
|
|||
},
|
||||
"ss01": {
|
||||
"type": "string",
|
||||
"description": "Non-cursive italic style",
|
||||
"description": "Non-cursive italic style of 'l i j k x'",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
"enable"
|
||||
]
|
||||
},
|
||||
"ss02": {
|
||||
"type": "string",
|
||||
"description": "Disable ligautures on equals like '==', '!=', '<='",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
"enable"
|
||||
]
|
||||
},
|
||||
"ss03": {
|
||||
"type": "string",
|
||||
"description": "Ignore cases on all tags",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
"enable"
|
||||
]
|
||||
},
|
||||
"ss04": {
|
||||
"type": "string",
|
||||
"description": "Disable ligatures on '__', '#__', '***' and escape strings",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
"enable"
|
||||
]
|
||||
},
|
||||
"zero": {
|
||||
"type": "string",
|
||||
"description": "Dot style '0'",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
"enable"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"feature_freeze_italic": {
|
||||
"type": "object",
|
||||
"description": "Freeze some font features (No effect on Variable font) for italic font \n enable: enable font features by default \n disable: remove some font features \n ignore: skip handle target font features",
|
||||
"properties": {
|
||||
"cv01": {
|
||||
"type": "string",
|
||||
"description": "Classic '@', '$', '&', 'Q', '=>', '->'",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
"enable"
|
||||
]
|
||||
},
|
||||
"cv02": {
|
||||
"type": "string",
|
||||
"description": "Alternative 'a' (with top alarm)",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
"enable"
|
||||
]
|
||||
},
|
||||
"cv03": {
|
||||
"type": "string",
|
||||
"description": "Alternative regular 'i' (without bottom left bar)",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
"enable"
|
||||
]
|
||||
},
|
||||
"cv04": {
|
||||
"type": "string",
|
||||
"description": "Alternative 'l' (with bottom left bar) and '1' (without bottom bar)",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
"enable"
|
||||
]
|
||||
},
|
||||
"cv98": {
|
||||
"type": "string",
|
||||
"description": "Full width '…'(ellipsis) and '—'(emdash) support for Maple Mono NF CN",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
"enable"
|
||||
]
|
||||
},
|
||||
"cv99": {
|
||||
"type": "string",
|
||||
"description": "Traditional punctuations support for Maple Mono NF CN",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
"enable"
|
||||
]
|
||||
},
|
||||
"ss01": {
|
||||
"type": "string",
|
||||
"description": "Non-cursive italic style of 'l i j k x'",
|
||||
"enum": [
|
||||
"ignore",
|
||||
"disable",
|
||||
|
|
Loading…
Reference in a new issue