1
0

Revert to natural hinting w/ control instructions

This commit is contained in:
2026-03-28 18:59:53 +01:00
parent ef39ce4046
commit 19e915f4e1
2 changed files with 20 additions and 2 deletions

View File

@@ -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:

14
src/ttfautohint-ctrl.txt Normal file
View File

@@ -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.