From 7cefafd675983be4ec403214423128496acca3b8 Mon Sep 17 00:00:00 2001 From: subframe7536 <1667077010@qq.com> Date: Thu, 5 Dec 2024 01:08:08 +0800 Subject: [PATCH] NL build in release, add suffix `NL` to name if disable ligature --- build.py | 7 ++++--- release.py | 19 ++++++++++++++----- source/py/feature.py | 6 ++++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/build.py b/build.py index 848e2dc..5caa5aa 100644 --- a/build.py +++ b/build.py @@ -298,10 +298,11 @@ class FontConfig: if args.cn_narrow: self.cn["narrow"] = True - if self.debug: - self.family_name += " Debug" - name_arr = [word.capitalize() for word in self.family_name.split(" ")] + if not self.enable_liga: + name_arr.append("NL") + if self.debug: + name_arr.append("Debug") self.family_name = " ".join(name_arr) self.family_name_compact = "".join(name_arr) diff --git a/release.py b/release.py index 8ee96ae..31179f4 100644 --- a/release.py +++ b/release.py @@ -12,7 +12,7 @@ def move_and_log(file_path: str, target_path: str): print(f"Move {file_path} -> {target_path}") move(file_path, target_path) -def build(normal: bool, hinted: bool, cache: bool = False): +def build(normal: bool, hinted: bool, liga: bool, cache: bool = False): args = [ "python", "build.py", @@ -31,6 +31,11 @@ def build(normal: bool, hinted: bool, cache: bool = False): else: args.append("--no-hinted") + if liga: + args.append("--liga") + else: + args.append("--no-liga") + print(" ".join(args)) subprocess.run(args) @@ -53,10 +58,14 @@ rmtree(output_release, ignore_errors=True) mkdir(output_release) # build all formats -build(normal=True, hinted=True) -build(normal=True, hinted=False, cache=True) -build(normal=False, hinted=True) -build(normal=False, hinted=False, cache=True) +build(normal=True, liga=True, hinted=True) +build(normal=True, liga=True, hinted=False, cache=True) +build(normal=True, liga=False, hinted=True) +build(normal=True, liga=False, hinted=False, cache=True) +build(normal=False, liga=True, hinted=True) +build(normal=False, liga=True, hinted=False, cache=True) +build(normal=False, liga=False, hinted=True) +build(normal=False, liga=False, hinted=False, cache=True) # copy woff2 to root rmtree("woff2", ignore_errors=True) diff --git a/source/py/feature.py b/source/py/feature.py index d356938..48787c5 100644 --- a/source/py/feature.py +++ b/source/py/feature.py @@ -48,8 +48,10 @@ def freeze_feature(font, calt, moving_rules=[], config={}): glyph_dict = font["glyf"].glyphs hmtx_dict = font["hmtx"].metrics for index in target_feature.LookupListIndex: - lookup = font["GSUB"].table.LookupList.Lookup[index] - for old_key, new_key in lookup.SubTable[0].mapping.items(): + lookup = font["GSUB"].table.LookupList.Lookup[index].SubTable[0].mapping + if not lookup: + continue + for old_key, new_key in lookup.items(): if ( old_key in glyph_dict and old_key in hmtx_dict