From bf959d33312809ad956ff73309dc78d82fcfc160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A9clairevoyant?= <848000+eclairevoyant@users.noreply.github.com> Date: Fri, 26 Jun 2026 21:46:31 -0400 Subject: [PATCH] python3Packages.afdko: fix build on darwin --- ...mtx-avoid-unsigned-integer-underflow.patch | 34 +++++++++++++++++++ .../python-modules/afdko/default.nix | 4 +++ 2 files changed, 38 insertions(+) create mode 100644 pkgs/development/python-modules/afdko/0001-addfeatures-hmtx-avoid-unsigned-integer-underflow.patch diff --git a/pkgs/development/python-modules/afdko/0001-addfeatures-hmtx-avoid-unsigned-integer-underflow.patch b/pkgs/development/python-modules/afdko/0001-addfeatures-hmtx-avoid-unsigned-integer-underflow.patch new file mode 100644 index 000000000000..eb4a03e68647 --- /dev/null +++ b/pkgs/development/python-modules/afdko/0001-addfeatures-hmtx-avoid-unsigned-integer-underflow.patch @@ -0,0 +1,34 @@ +From 91833ab6c1a769f82f30dbf126362d079905bfc6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=A9clairevoyant?= + <848000+eclairevoyant@users.noreply.github.com> +Date: Fri, 26 Jun 2026 21:28:41 -0400 +Subject: [PATCH] addfeatures/hmtx: avoid unsigned integer underflow + +--- + c/addfeatures/hotconv/hmtx.cpp | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/c/addfeatures/hotconv/hmtx.cpp b/c/addfeatures/hotconv/hmtx.cpp +index 9336c986..2d8ca98e 100644 +--- a/c/addfeatures/hotconv/hmtx.cpp ++++ b/c/addfeatures/hotconv/hmtx.cpp +@@ -52,12 +52,12 @@ int hmtxFill(hotCtx g) { + /* Optimize metrics */ + FWord width = hmtx.advanceWidth.back(); + size_t i; +- for (i = hmtx.advanceWidth.size() - 2; i >= 0; i--) { +- if (hmtx.advanceWidth[i] != width) ++ for (i = hmtx.advanceWidth.size(); i >= 2; i--) { ++ if (hmtx.advanceWidth[i-2] != width) + break; + } +- if (i + 2 != hmtx.advanceWidth.size()) +- hmtx.advanceWidth.resize(i+2); ++ if (i != hmtx.advanceWidth.size()) ++ hmtx.advanceWidth.resize(i); + + return hmtx.Fill(); + } +-- +2.54.0 + diff --git a/pkgs/development/python-modules/afdko/default.nix b/pkgs/development/python-modules/afdko/default.nix index 1053d44c328f..70eb28a87de0 100644 --- a/pkgs/development/python-modules/afdko/default.nix +++ b/pkgs/development/python-modules/afdko/default.nix @@ -69,6 +69,10 @@ buildPythonPackage (finalAttrs: { # Use antlr4 runtime from nixpkgs and link it dynamically ./use-dynamic-system-antlr4-runtime.patch + + # integer underflow causes incorrect behavior + # patch submitted upstream as https://github.com/adobe-type-tools/afdko/pull/1843 + ./0001-addfeatures-hmtx-avoid-unsigned-integer-underflow.patch ]; env = {