at 22.05-pre 87 lines 3.7 kB view raw
1{ stdenv, fetchpatch, fetchFromGitHub, lib 2, cmake, perl, uthash, pkg-config, gettext 3, python, freetype, zlib, glib, giflib, libpng, libjpeg, libtiff, libxml2, cairo, pango 4, readline, woff2, zeromq, libuninameslist 5, withSpiro ? false, libspiro 6, withGTK ? false, gtk3 7, withGUI ? withGTK 8, withPython ? true 9, withExtras ? true 10, Carbon, Cocoa 11}: 12 13assert withGTK -> withGUI; 14 15stdenv.mkDerivation rec { 16 pname = "fontforge"; 17 version = "20201107"; 18 19 src = fetchFromGitHub { 20 owner = pname; 21 repo = pname; 22 rev = version; 23 sha256 = "sha256-Rl/5lbXaPgIndANaD0IakaDus6T53FjiBb45FIuGrvc="; 24 }; 25 26 patches = [ 27 # Allow installing contrib files (e.g. extras and tools). 28 # Taken from https://salsa.debian.org/fonts-team/fontforge/-/blob/master/debian/patches/0001-add-extra-cmake-install-rules.patch 29 (fetchpatch { 30 url = "https://salsa.debian.org/fonts-team/fontforge/raw/76bffe6ccf8ab20a0c81476a80a87ad245e2fd1c/debian/patches/0001-add-extra-cmake-install-rules.patch"; 31 sha256 = "u3D9od2xLECNEHhZ+8dkuv9818tPkdP6y/Tvd9CADJg="; 32 }) 33 # Fix segmentation fault with some fonts. 34 # This is merged and should be present in the next release. 35 (fetchpatch { 36 url = "https://github.com/fontforge/fontforge/commit/69e263b2aff29ad22f97f13935cfa97a1eabf207.patch"; 37 sha256 = "06yyf90605aq6ppfiz83mqkdmnaq5418axp9jgsjyjq78b00xb29"; 38 }) 39 ]; 40 41 # use $SOURCE_DATE_EPOCH instead of non-deterministic timestamps 42 postPatch = '' 43 find . -type f -name '*.c' -exec sed -r -i 's#\btime\(&(.+)\)#if (getenv("SOURCE_DATE_EPOCH")) \1=atol(getenv("SOURCE_DATE_EPOCH")); else &#g' {} \; 44 sed -r -i 's#author\s*!=\s*NULL#& \&\& !getenv("SOURCE_DATE_EPOCH")#g' fontforge/cvexport.c fontforge/dumppfa.c fontforge/print.c fontforge/svg.c fontforge/splineutil2.c 45 sed -r -i 's#\bb.st_mtime#getenv("SOURCE_DATE_EPOCH") ? atol(getenv("SOURCE_DATE_EPOCH")) : &#g' fontforge/parsepfa.c fontforge/sfd.c fontforge/svg.c 46 sed -r -i 's#^\s*ttf_fftm_dump#if (!getenv("SOURCE_DATE_EPOCH")) ttf_fftm_dump#g' fontforge/tottf.c 47 sed -r -i 's#sprintf\(.+ author \);#if (!getenv("SOURCE_DATE_EPOCH")) &#g' fontforgeexe/fontinfo.c 48 ''; 49 50 # do not use x87's 80-bit arithmetic, rouding errors result in very different font binaries 51 NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isi686 "-msse2 -mfpmath=sse"; 52 53 nativeBuildInputs = [ pkg-config cmake ]; 54 buildInputs = [ 55 readline uthash woff2 zeromq libuninameslist 56 python freetype zlib glib giflib libpng libjpeg libtiff libxml2 57 ] 58 ++ lib.optionals withSpiro [ libspiro ] 59 ++ lib.optionals withGUI [ gtk3 cairo pango ] 60 ++ lib.optionals stdenv.isDarwin [ Carbon Cocoa ]; 61 62 cmakeFlags = [ "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" ] 63 ++ lib.optional (!withSpiro) "-DENABLE_LIBSPIRO=OFF" 64 ++ lib.optional (!withGUI) "-DENABLE_GUI=OFF" 65 ++ lib.optional (!withGTK) "-DENABLE_X11=ON" 66 ++ lib.optional withExtras "-DENABLE_FONTFORGE_EXTRAS=ON"; 67 68 # work-around: git isn't really used, but configuration fails without it 69 preConfigure = '' 70 # The way $version propagates to $version of .pe-scripts (https://github.com/dejavu-fonts/dejavu-fonts/blob/358190f/scripts/generate.pe#L19) 71 export SOURCE_DATE_EPOCH=$(date -d ${version} +%s) 72 ''; 73 74 postInstall = 75 # get rid of the runtime dependency on python 76 lib.optionalString (!withPython) '' 77 rm -r "$out/share/fontforge/python" 78 ''; 79 80 meta = with lib; { 81 description = "A font editor"; 82 homepage = "https://fontforge.github.io"; 83 platforms = platforms.all; 84 license = licenses.bsd3; 85 maintainers = [ maintainers.erictapen ]; 86 }; 87}