1{
2 stdenv,
3 lib,
4 fetchFromGitea,
5 pkg-config,
6 meson,
7 ninja,
8 scdoc,
9 freetype,
10 fontconfig,
11 nanosvg,
12 pixman,
13 tllist,
14 check,
15 # Text shaping methods to enable, empty list disables all text shaping.
16 # See `availableShapingTypes` or upstream meson_options.txt for available types.
17 withShapingTypes ? [
18 "grapheme"
19 "run"
20 ],
21 harfbuzz,
22 utf8proc,
23 fcft, # for passthru.tests
24}:
25
26let
27 # Needs to be reflect upstream meson_options.txt
28 availableShapingTypes = [
29 "grapheme"
30 "run"
31 ];
32in
33
34stdenv.mkDerivation rec {
35 pname = "fcft";
36 version = "3.3.2";
37
38 src = fetchFromGitea {
39 domain = "codeberg.org";
40 owner = "dnkl";
41 repo = "fcft";
42 rev = version;
43 hash = "sha256-a+lELkEjMtqeBYGj6yl+OoQ+I6neyJt6a1T83B2KWOk=";
44 };
45
46 depsBuildBuild = [ pkg-config ];
47 nativeBuildInputs = [
48 pkg-config
49 meson
50 ninja
51 scdoc
52 ];
53 buildInputs = [
54 freetype
55 fontconfig
56 nanosvg
57 pixman
58 tllist
59 ]
60 ++ lib.optionals (withShapingTypes != [ ]) [ harfbuzz ]
61 ++ lib.optionals (builtins.elem "run" withShapingTypes) [ utf8proc ];
62 nativeCheckInputs = [ check ];
63
64 mesonBuildType = "release";
65 mesonFlags = [
66 (lib.mesonEnable "system-nanosvg" true)
67 ]
68 ++ builtins.map (
69 t: lib.mesonEnable "${t}-shaping" (lib.elem t withShapingTypes)
70 ) availableShapingTypes;
71
72 doCheck = true;
73
74 outputs = [
75 "out"
76 "doc"
77 "man"
78 ];
79
80 passthru.tests = {
81 noShaping = fcft.override { withShapingTypes = [ ]; };
82 onlyGraphemeShaping = fcft.override { withShapingTypes = [ "grapheme" ]; };
83 };
84
85 meta = {
86 homepage = "https://codeberg.org/dnkl/fcft";
87 changelog = "https://codeberg.org/dnkl/fcft/releases/tag/${version}";
88 description = "Simple library for font loading and glyph rasterization";
89 maintainers = with lib.maintainers; [
90 fionera
91 sternenseemann
92 ];
93 license = with lib.licenses; [
94 mit
95 zlib
96 ];
97 platforms = with lib.platforms; linux;
98 };
99}