3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/tools/misc/fontforge/default.nix

79 lines
3.2 KiB
Nix
Raw Normal View History

{ stdenv, fetchurl, lib
, autoconf, automake, gnum4, libtool, perl, gnulib, uthash, pkgconfig, gettext
, python, freetype, zlib, glib, libungif, libpng, libjpeg, libtiff, libxml2, cairo, pango
, readline, woff2, zeromq
, withSpiro ? false, libspiro
, withGTK ? false, gtk2
2016-06-10 23:41:44 +01:00
, withPython ? true
, withExtras ? true
2016-08-12 04:19:25 +01:00
, Carbon ? null, Cocoa ? null
}:
2016-06-10 23:41:44 +01:00
stdenv.mkDerivation rec {
pname = "fontforge";
version = "20190413";
src = fetchurl {
url = "https://github.com/${pname}/${pname}/releases/download/${version}/${pname}-${version}.tar.gz";
sha256 = "05v640mnk4fy4jzmxb6c4n4qm800x7hy4sl5gcdgzmm3md2s0qk7";
};
2017-08-15 19:41:56 +01:00
patches = [ ./fontforge-20140813-use-system-uthash.patch ];
# use $SOURCE_DATE_EPOCH instead of non-deterministic timestamps
2017-08-15 19:41:56 +01:00
postPatch = ''
find . -type f -name '*.c' -exec sed -r -i 's#\btime\(&(.+)\)#if (getenv("SOURCE_DATE_EPOCH")) \1=atol(getenv("SOURCE_DATE_EPOCH")); else &#g' {} \;
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
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
sed -r -i 's#^\s*ttf_fftm_dump#if (!getenv("SOURCE_DATE_EPOCH")) ttf_fftm_dump#g' fontforge/tottf.c
sed -r -i 's#sprintf\(.+ author \);#if (!getenv("SOURCE_DATE_EPOCH")) &#g' fontforgeexe/fontinfo.c
'';
# do not use x87's 80-bit arithmetic, rouding errors result in very different font binaries
NIX_CFLAGS_COMPILE = lib.optionals stdenv.isi686 [ "-msse2" "-mfpmath=sse" ];
nativeBuildInputs = [ pkgconfig autoconf automake gnum4 libtool perl gettext ];
buildInputs = [
readline uthash woff2 zeromq
python freetype zlib glib libungif libpng libjpeg libtiff libxml2
]
++ lib.optionals withSpiro [libspiro]
++ lib.optionals withGTK [ gtk2 cairo pango ]
++ lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
configureFlags = [ "--enable-woff2" ]
++ lib.optionals (!withPython) [ "--disable-python-scripting" "--disable-python-extension" ]
++ lib.optional withGTK "--enable-gtk2-use"
++ lib.optional (!withGTK) "--without-x"
++ lib.optional withExtras "--enable-fontforge-extras";
# work-around: git isn't really used, but configuration fails without it
preConfigure = ''
# The way $version propagates to $version of .pe-scripts (https://github.com/dejavu-fonts/dejavu-fonts/blob/358190f/scripts/generate.pe#L19)
export SOURCE_DATE_EPOCH=$(date -d ${version} +%s)
export GIT="$(type -P true)"
cp -r "${gnulib}" ./gnulib
chmod +w -R ./gnulib
./bootstrap --skip-git --gnulib-srcdir=./gnulib --force
'';
doCheck = false; # tries to wget some fonts
doInstallCheck = doCheck;
postInstall =
# get rid of the runtime dependency on python
lib.optionalString (!withPython) ''
rm -r "$out/share/fontforge/python"
'';
enableParallelBuilding = true;
meta = {
description = "A font editor";
homepage = http://fontforge.github.io;
platforms = stdenv.lib.platforms.all;
2017-03-23 14:10:34 +00:00
license = stdenv.lib.licenses.bsd3;
};
}