ligature option no longer effect cvXX, add --feat cli args #267
This commit is contained in:
parent
f3edc3808f
commit
287683a984
3 changed files with 22 additions and 9 deletions
14
build.py
14
build.py
|
@ -61,6 +61,11 @@ def parse_args():
|
|||
type=str,
|
||||
help="Setup output directory prefix",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--feat",
|
||||
type=lambda x: x.strip().split(","),
|
||||
help="Freeze font features, splited by `,` (e.g. `--feat zero,cv01,ss07,ss08`)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--hinted",
|
||||
dest="hinted",
|
||||
|
@ -242,6 +247,11 @@ class FontConfig:
|
|||
if "github_mirror" not in self.nerd_font:
|
||||
self.nerd_font["github_mirror"] = "github.com"
|
||||
|
||||
if args.feat is not None:
|
||||
for f in args.feat:
|
||||
if f in self.feature_freeze:
|
||||
self.feature_freeze[f] = "enable"
|
||||
|
||||
if args.hinted is not None:
|
||||
self.use_hinted = args.hinted
|
||||
|
||||
|
@ -344,12 +354,10 @@ def handle_ligatures(
|
|||
"""
|
||||
whether to enable ligatures and freeze font features
|
||||
"""
|
||||
if not enable_ligature:
|
||||
del font["GSUB"]
|
||||
return
|
||||
|
||||
freeze_feature(
|
||||
font=font,
|
||||
calt=enable_ligature,
|
||||
moving_rules=["ss03", "ss07", "ss08"],
|
||||
config=freeze_config,
|
||||
)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
def freeze_feature(font, moving_rules, config):
|
||||
def freeze_feature(font, calt, moving_rules, config):
|
||||
# check feature list
|
||||
feature_record = font["GSUB"].table.FeatureList.FeatureRecord
|
||||
feature_dict = {
|
||||
|
@ -7,9 +7,14 @@ def freeze_feature(font, moving_rules, config):
|
|||
if feature.FeatureTag != "calt"
|
||||
}
|
||||
|
||||
if calt:
|
||||
calt_features = [
|
||||
feature.Feature for feature in feature_record if feature.FeatureTag == "calt"
|
||||
]
|
||||
else:
|
||||
for feature in feature_record:
|
||||
if feature.FeatureTag == "calt":
|
||||
feature.LookupListIndex = []
|
||||
|
||||
# Process features
|
||||
for tag, status in config.items():
|
||||
|
@ -21,7 +26,7 @@ def freeze_feature(font, moving_rules, config):
|
|||
target_feature.LookupListIndex = []
|
||||
continue
|
||||
|
||||
if tag in moving_rules:
|
||||
if tag in moving_rules and calt:
|
||||
# Enable by moving rules into "calt"
|
||||
for calt_feat in calt_features:
|
||||
calt_feat.LookupListIndex.extend(target_feature.LookupListIndex)
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
},
|
||||
"ligature": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to enable ligature. Remove all the ligatures if set to false",
|
||||
"description": "Whether to enable ligature.\nIf set to false, all the ligatures will be removed and 'ssXX' options in 'feature_freeze' will no longer effect",
|
||||
"default": true
|
||||
},
|
||||
"feature_freeze": {
|
||||
|
|
Loading…
Reference in a new issue