1
0

Fix zero-area contours after export to TTF

This commit is contained in:
2026-03-02 13:33:08 +01:00
parent 834534a00c
commit b2160079a7
3 changed files with 96 additions and 3 deletions

View File

@@ -179,7 +179,7 @@ def build_export_script(sfd_path, ttf_path, old_kern=True):
def clean_ttf_degenerate_contours(ttf_path):
"""Remove degenerate contours (<=2 points) from a TTF in-place."""
"""Remove zero-area contours (<=2 points) from a TTF in-place."""
try:
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables._g_l_y_f import GlyphCoordinates
@@ -236,7 +236,7 @@ def clean_ttf_degenerate_contours(ttf_path):
if hasattr(glyf, "recalcBounds"):
glyf.recalcBounds(glyph_set) # type: ignore[attr-defined]
font.save(ttf_path)
print(f" Cleaned {removed_total} degenerate contour(s)")
print(f" Cleaned {removed_total} zero-area contour(s)")
font.close()
@@ -305,6 +305,7 @@ def _build(tmp_dir, family=DEFAULT_FAMILY, old_kern=True):
print(result.stderr, file=sys.stderr)
sys.exit(1)
print(f" {len(variants)} font(s) instanced.")
# Step 2: Apply vertical scale (opens TTF, saves as SFD)
@@ -374,6 +375,7 @@ def _build(tmp_dir, family=DEFAULT_FAMILY, old_kern=True):
run_fontforge_script(script)
clean_ttf_degenerate_contours(ttf_path)
print("\n" + "=" * 60)
print(" Build complete!")
print(f" SFD fonts are in: {OUT_SFD_DIR}/")