1{
2 lib,
3 stdenv,
4 # Enables some expensive tests, useful for verifying an update
5 afdko,
6 antlr4_9,
7 booleanoperations,
8 buildPythonPackage,
9 cmake,
10 defcon,
11 fetchFromGitHub,
12 fontmath,
13 fontpens,
14 fonttools,
15 libxml2,
16 mutatormath,
17 ninja,
18 pytestCheckHook,
19 pythonOlder,
20 runAllTests ? false,
21 scikit-build,
22 setuptools-scm,
23 tqdm,
24 ufonormalizer,
25 ufoprocessor,
26}:
27
28buildPythonPackage rec {
29 pname = "afdko";
30 version = "4.0.1";
31 pyproject = true;
32
33 disabled = pythonOlder "3.8";
34
35 src = fetchFromGitHub {
36 owner = "adobe-type-tools";
37 repo = "afdko";
38 rev = "refs/tags/${version}";
39 hash = "sha256-I5GKPkbyQX8QNSZgNB3wPKdWwpx8Xkklesu1M7nhgp8=";
40 };
41
42 build-system = [ setuptools-scm ];
43
44 nativeBuildInputs = [
45 scikit-build
46 cmake
47 ninja
48 ];
49
50 buildInputs = [
51 antlr4_9.runtime.cpp
52 libxml2.dev
53 ];
54
55 patches = [
56 # Don't try to install cmake and ninja using pip
57 ./no-pypi-build-tools.patch
58
59 # Use antlr4 runtime from nixpkgs and link it dynamically
60 ./use-dynamic-system-antlr4-runtime.patch
61 ];
62
63 # Happy new year
64 postPatch = ''
65 substituteInPlace tests/tx_data/expected_output/alt-missing-glif.pfb --replace 2023 2024
66 '';
67
68 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang (toString [
69 "-Wno-error=incompatible-function-pointer-types"
70 "-Wno-error=int-conversion"
71 ]);
72
73 # setup.py will always (re-)execute cmake in buildPhase
74 dontConfigure = true;
75
76 dependencies =
77 [
78 booleanoperations
79 defcon
80 fontmath
81 fontpens
82 fonttools
83 mutatormath
84 tqdm
85 ufonormalizer
86 ufoprocessor
87 ]
88 ++ defcon.optional-dependencies.lxml
89 ++ fonttools.optional-dependencies.lxml
90 ++ fonttools.optional-dependencies.ufo
91 ++ fonttools.optional-dependencies.unicode
92 ++ fonttools.optional-dependencies.woff;
93
94 # Use system libxml2
95 FORCE_SYSTEM_LIBXML2 = true;
96
97 nativeCheckInputs = [ pytestCheckHook ];
98
99 preCheck = ''
100 export PATH=$PATH:$out/bin
101
102 # Remove build artifacts to prevent them from messing with the tests
103 rm -rf _skbuild
104 '';
105
106 disabledTests =
107 [
108 # broke in the fontforge 4.51 -> 4.53 update
109 "test_glyphs_2_7"
110 "test_hinting_data"
111 "test_waterfallplot"
112 ]
113 ++ lib.optionals (stdenv.cc.isGNU) [
114 # broke in the gcc 13 -> 14 update
115 "test_dump"
116 "test_input_formats"
117 "test_other_input_formats"
118 ]
119 ++ lib.optionals (!runAllTests) [
120 # Disable slow tests, reduces test time ~25 %
121 "test_report"
122 "test_post_overflow"
123 "test_cjk"
124 "test_extrapolate"
125 "test_filename_without_dir"
126 "test_overwrite"
127 "test_options"
128 ]
129 ++ lib.optionals (stdenv.hostPlatform.isAarch || stdenv.hostPlatform.isRiscV) [
130 # unknown reason so far
131 # https://github.com/adobe-type-tools/afdko/issues/1425
132 "test_spec"
133 ]
134 ++ lib.optionals (stdenv.hostPlatform.isi686) [
135 "test_dump_option"
136 "test_type1mm_inputs"
137 ];
138
139 passthru.tests = {
140 fullTestsuite = afdko.override { runAllTests = true; };
141 };
142
143 meta = with lib; {
144 description = "Adobe Font Development Kit for OpenType";
145 changelog = "https://github.com/adobe-type-tools/afdko/blob/${version}/NEWS.md";
146 homepage = "https://adobe-type-tools.github.io/afdko";
147 license = licenses.asl20;
148 maintainers = with maintainers; [ sternenseemann ];
149 };
150}