From 1ef62915f7c0d5eeead76660cc02a01e8c86c0a9 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Mon, 2 Mar 2026 03:31:28 +0100 Subject: [PATCH] Almost perfect --- build.py | 8 +++++--- scripts/condense.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 scripts/condense.py diff --git a/build.py b/build.py index 64812ec..7e36286 100755 --- a/build.py +++ b/build.py @@ -36,9 +36,9 @@ ITALIC_VF = os.path.join(SRC_DIR, "Newsreader-Italic-VariableFont_opsz,wght.ttf VARIANTS = [ # (output_name, source_vf, wght, opsz) - ("Readerly-Regular", REGULAR_VF, 430, 9), + ("Readerly-Regular", REGULAR_VF, 425, 9), ("Readerly-Bold", REGULAR_VF, 550, 9), - ("Readerly-Italic", ITALIC_VF, 430, 9), + ("Readerly-Italic", ITALIC_VF, 425, 9), ("Readerly-BoldItalic", ITALIC_VF, 550, 9), ] @@ -171,7 +171,8 @@ def main(): # Step 2: Apply vertical scale (opens TTF, saves as SFD) print("\n── Step 2: Scale lowercase ──\n") - scale_code = load_script_as_function(os.path.join(SCRIPTS_DIR, "scale.py")) + scale_code = load_script_as_function(os.path.join(SCRIPTS_DIR, "scale.py")) + condense_code = load_script_as_function(os.path.join(SCRIPTS_DIR, "condense.py")) clear_code = "\n".join( f'if {g!r} in f:\n' @@ -188,6 +189,7 @@ def main(): script = build_per_font_script(ttf_path, sfd_path, [ ("Clearing problematic glyphs", clear_code), ("Scaling Y", scale_code), + ("Condensing X", condense_code), ]) run_fontforge_script(script) diff --git a/scripts/condense.py b/scripts/condense.py new file mode 100644 index 0000000..961439b --- /dev/null +++ b/scripts/condense.py @@ -0,0 +1,31 @@ +""" +FontForge: Condense all glyphs horizontally +──────────────────────────────────────────── +Applies a horizontal scale to all glyphs, reducing set width. + +Run inside FontForge (or via build.py which sets `f` before running this). +""" + +import fontforge +import psMat + +f = fontforge.activeFont() + +# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +# CONFIGURATION +# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +SCALE_X = 0.95 + +# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +# APPLY +# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +mat = psMat.scale(SCALE_X, 1.0) + +f.selection.all() +f.transform(mat, ("round",)) + +count = sum(1 for g in f.glyphs() if g.isWorthOutputting()) +print(f" Condensed {count} glyphs by X={SCALE_X:.0%}") +print("Done.")