Skip to content

Commit 19e915f

Browse files
Revert to natural hinting w/ control instructions
1 parent ef39ce4 commit 19e915f

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

build.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@
9494
# (gray) is the one that matters. n=natural, q=quantized, s=strong.
9595
# - Remaining two chars are for GDI and DirectWrite (not used on Kobo).
9696
# - Other options are left at ttfautohint defaults; uncomment to override.
97+
AUTOHINT_CTRL = os.path.join(SRC_DIR, "ttfautohint-ctrl.txt")
9798
AUTOHINT_OPTS = [
9899
"--no-info",
99-
"--stem-width-mode=qss",
100+
"--stem-width-mode=nss",
100101
# "--hinting-range-min=8",
101102
# "--hinting-range-max=50",
102103
# "--hinting-limit=200",
@@ -772,8 +773,11 @@ def autohint_ttf(ttf_path):
772773
return
773774

774775
tmp_path = ttf_path + ".autohint.tmp"
776+
opts = list(AUTOHINT_OPTS)
777+
if os.path.isfile(AUTOHINT_CTRL) and os.path.getsize(AUTOHINT_CTRL) > 0:
778+
opts += [f"--control-file={AUTOHINT_CTRL}"]
775779
result = subprocess.run(
776-
["ttfautohint"] + AUTOHINT_OPTS + [ttf_path, tmp_path],
780+
["ttfautohint"] + opts + [ttf_path, tmp_path],
777781
capture_output=True, text=True,
778782
)
779783
if result.returncode != 0:

src/ttfautohint-ctrl.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ttfautohint control instructions for Readerly
2+
# See: https://freetype.org/ttfautohint/doc/ttfautohint.html
3+
#
4+
# Syntax reference:
5+
# glyph_name left|right point_idx [(left_offset, right_offset)]
6+
# → create artificial one-point segment (fixes serif detection)
7+
# glyph_name touch points yshift N @ ppems
8+
# → shift points vertically at specific sizes (in 1/8 pixel units)
9+
# glyph_name nodir points
10+
# → remove points from segment detection
11+
#
12+
# Add entries below for glyphs with serif hinting issues.
13+
# Use `ttfautohint --debug -l N -r N font.ttf out.ttf` to inspect
14+
# segment/edge detection at a specific PPEM size.

0 commit comments

Comments
 (0)