From 19e915f4e16e07604d45733bd201b6c1756dd312 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sat, 28 Mar 2026 18:59:53 +0100 Subject: [PATCH] Revert to natural hinting w/ control instructions --- build.py | 8 ++++++-- src/ttfautohint-ctrl.txt | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/ttfautohint-ctrl.txt diff --git a/build.py b/build.py index d7df2a7..0ad2cbf 100755 --- a/build.py +++ b/build.py @@ -94,9 +94,10 @@ ASCENDER_RATIO = 0.8 # (gray) is the one that matters. n=natural, q=quantized, s=strong. # - Remaining two chars are for GDI and DirectWrite (not used on Kobo). # - Other options are left at ttfautohint defaults; uncomment to override. +AUTOHINT_CTRL = os.path.join(SRC_DIR, "ttfautohint-ctrl.txt") AUTOHINT_OPTS = [ "--no-info", - "--stem-width-mode=qss", + "--stem-width-mode=nss", # "--hinting-range-min=8", # "--hinting-range-max=50", # "--hinting-limit=200", @@ -772,8 +773,11 @@ def autohint_ttf(ttf_path): return tmp_path = ttf_path + ".autohint.tmp" + opts = list(AUTOHINT_OPTS) + if os.path.isfile(AUTOHINT_CTRL) and os.path.getsize(AUTOHINT_CTRL) > 0: + opts += [f"--control-file={AUTOHINT_CTRL}"] result = subprocess.run( - ["ttfautohint"] + AUTOHINT_OPTS + [ttf_path, tmp_path], + ["ttfautohint"] + opts + [ttf_path, tmp_path], capture_output=True, text=True, ) if result.returncode != 0: diff --git a/src/ttfautohint-ctrl.txt b/src/ttfautohint-ctrl.txt new file mode 100644 index 0000000..ae0b943 --- /dev/null +++ b/src/ttfautohint-ctrl.txt @@ -0,0 +1,14 @@ +# ttfautohint control instructions for Readerly +# See: https://freetype.org/ttfautohint/doc/ttfautohint.html +# +# Syntax reference: +# glyph_name left|right point_idx [(left_offset, right_offset)] +# → create artificial one-point segment (fixes serif detection) +# glyph_name touch points yshift N @ ppems +# → shift points vertically at specific sizes (in 1/8 pixel units) +# glyph_name nodir points +# → remove points from segment detection +# +# Add entries below for glyphs with serif hinting issues. +# Use `ttfautohint --debug -l N -r N font.ttf out.ttf` to inspect +# segment/edge detection at a specific PPEM size.