add forgive flag
This commit is contained in:
parent
f548ce9235
commit
1f6eb081fc
2 changed files with 21 additions and 5 deletions
15
build.py
15
build.py
|
@ -179,6 +179,11 @@ def parse_args():
|
|||
action="store_true",
|
||||
help="Build font archives with config and license. If has `--cache` flag, only archive Nerd-Font and CN formats",
|
||||
)
|
||||
build_group.add_argument(
|
||||
"--forgive",
|
||||
action="store_true",
|
||||
help="Forgive errors",
|
||||
)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
@ -270,6 +275,7 @@ class FontConfig:
|
|||
}
|
||||
self.glyph_width = 600
|
||||
self.glyph_width_cn_narrow = 1000
|
||||
self.forgive = False
|
||||
self.__load_config(args.normal)
|
||||
self.__load_args(args)
|
||||
|
||||
|
@ -351,6 +357,9 @@ class FontConfig:
|
|||
if args.apply_fea_file:
|
||||
self.apply_fea_file = True
|
||||
|
||||
if args.forgive:
|
||||
self.forgive = True
|
||||
|
||||
if args.cn_rebuild:
|
||||
self.cn["clean_cache"] = True
|
||||
self.cn["use_static_base_font"] = False
|
||||
|
@ -1056,7 +1065,9 @@ def main():
|
|||
)
|
||||
|
||||
verify_glyph_width(
|
||||
font=font, expect_widths=font_config.get_valid_glyph_width_list()
|
||||
font=font,
|
||||
expect_widths=font_config.get_valid_glyph_width_list(),
|
||||
forgive=font_config.forgive,
|
||||
)
|
||||
|
||||
add_gasp(font)
|
||||
|
@ -1137,6 +1148,7 @@ def main():
|
|||
joinPaths(build_option.output_nf, listdir(build_option.output_nf)[0])
|
||||
),
|
||||
expect_widths=font_config.get_valid_glyph_width_list(),
|
||||
forgive=font_config.forgive,
|
||||
)
|
||||
|
||||
# =========================================================================================
|
||||
|
@ -1175,6 +1187,7 @@ def main():
|
|||
joinPaths(build_option.output_cn, listdir(build_option.output_cn)[0])
|
||||
),
|
||||
expect_widths=font_config.get_valid_glyph_width_list(True),
|
||||
forgive=font_config.forgive,
|
||||
)
|
||||
|
||||
# =========================================================================================
|
||||
|
|
|
@ -191,7 +191,7 @@ def match_unicode_names(file_path: str) -> dict[str, str]:
|
|||
|
||||
|
||||
# https://github.com/subframe7536/maple-font/issues/314
|
||||
def verify_glyph_width(font: TTFont, expect_widths: list[int]):
|
||||
def verify_glyph_width(font: TTFont, expect_widths: list[int], forgive: bool):
|
||||
print("Verify glyph width...")
|
||||
result: tuple[str, int] = []
|
||||
for name in font.getGlyphOrder():
|
||||
|
@ -203,9 +203,12 @@ def verify_glyph_width(font: TTFont, expect_widths: list[int]):
|
|||
print(f"Every glyph's width should be in {expect_widths}, but these are not:")
|
||||
for item in result:
|
||||
print(f"{item[0]} => {item[1]}")
|
||||
raise Exception(
|
||||
f"The font may contain glyphs that width is not in {expect_widths}, which may broke monospace rule."
|
||||
)
|
||||
if forgive:
|
||||
print("[WARN] Forgive it")
|
||||
else:
|
||||
raise Exception(
|
||||
f"The font may contain glyphs that width is not in {expect_widths}, which may broke monospace rule."
|
||||
)
|
||||
|
||||
|
||||
def compress_folder(
|
||||
|
|
Loading…
Reference in a new issue