Skip to content

Commit 90457bd

Browse files
authored
python3Packages.afdko: fix otfautohint variable-font hinting regression (#536673)
2 parents a02f0a6 + aade3eb commit 90457bd

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From dc35a26c5b38bad40dd44d67609b6a89ee0d7774 Mon Sep 17 00:00:00 2001
2+
From: Philip Taron <philip.taron@gmail.com>
3+
Date: Mon, 29 Jun 2026 13:48:41 +0000
4+
Subject: [PATCH] Fix spurious assertion when a high ghost stem is a glyph's
5+
first stem
6+
7+
In calcInstanceStems() the per-stem loop initializes lo = None and
8+
hi = None, then computes one or both locations per stem. For a 'high'
9+
ghost stem (a hint anchored only at the top edge) only hi is computed;
10+
lo is then unconditionally overwritten by hi on the next line, so its
11+
incoming value is dead.
12+
13+
The 'high' branch nonetheless asserted lo is not None. When a high ghost
14+
is the glyph's first stem -- exactly the case for small diagonal accents
15+
-- lo is still None from its initialization, so the assertion fired and
16+
aborted hinting of the whole font.
17+
18+
Drop the dead lo operand from the assertion, because hi is the only
19+
value actually read.
20+
---
21+
python/afdko/otfautohint/hinter.py | 2 +-
22+
1 file changed, 1 insertion(+), 1 deletion(-)
23+
24+
diff --git a/python/afdko/otfautohint/hinter.py b/python/afdko/otfautohint/hinter.py
25+
index 354d92f2f..1cea13a88 100644
26+
--- a/python/afdko/otfautohint/hinter.py
27+
+++ b/python/afdko/otfautohint/hinter.py
28+
@@ -2007,7 +2007,7 @@ def calcInstanceStems(self, glidx) -> None:
29+
lo = lo + 21
30+
hi = lo - 21
31+
elif isG == 'high':
32+
- assert lo is not None and hi is not None
33+
+ assert hi is not None
34+
lo = hi
35+
hi = lo - 20
36+
else:
37+
--
38+
2.49.0

pkgs/development/python-modules/afdko/default.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ buildPythonPackage (finalAttrs: {
7373
# integer underflow causes incorrect behavior
7474
# patch submitted upstream as https://github.com/adobe-type-tools/afdko/pull/1843
7575
./0001-addfeatures-hmtx-avoid-unsigned-integer-underflow.patch
76+
77+
# spurious assertion when a high ghost stem is a glyph's first stem aborts
78+
# variable-font hinting (e.g. cantarell-fonts, NixOS/nixpkgs#535887)
79+
# patch submitted upstream as https://github.com/adobe-type-tools/afdko/pull/1844
80+
./0002-otfautohint-fix-assertion-high-ghost-first-stem.patch
7681
];
7782

7883
env = {

0 commit comments

Comments
 (0)