2019-03-26 21:22:03 +00:00
|
|
|
{ stdenv, fetchurl, lib
|
2020-07-29 03:21:36 +00:00
|
|
|
, fetchpatch
|
2020-06-05 21:40:35 +00:00
|
|
|
, cmake, perl, uthash, pkgconfig, gettext
|
2019-03-26 21:22:03 +00:00
|
|
|
, python, freetype, zlib, glib, libungif, libpng, libjpeg, libtiff, libxml2, cairo, pango
|
2020-01-13 14:59:01 +00:00
|
|
|
, readline, woff2, zeromq, libuninameslist
|
2017-02-01 13:59:35 +00:00
|
|
|
, withSpiro ? false, libspiro
|
2020-06-05 21:40:35 +00:00
|
|
|
, withGTK ? false, gtk3
|
2020-06-06 00:03:38 +00:00
|
|
|
, withGUI ? withGTK
|
2016-06-10 22:41:44 +00:00
|
|
|
, withPython ? true
|
2019-03-26 21:22:03 +00:00
|
|
|
, withExtras ? true
|
2016-08-12 03:19:25 +00:00
|
|
|
, Carbon ? null, Cocoa ? null
|
2007-08-21 12:31:33 +00:00
|
|
|
}:
|
|
|
|
|
2020-06-06 00:03:38 +00:00
|
|
|
assert withGTK -> withGUI;
|
|
|
|
|
2016-06-10 22:41:44 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2019-03-26 21:22:03 +00:00
|
|
|
pname = "fontforge";
|
2020-06-05 21:40:35 +00:00
|
|
|
version = "20200314";
|
2017-08-12 14:22:45 +00:00
|
|
|
|
2019-03-26 21:22:03 +00:00
|
|
|
src = fetchurl {
|
2020-06-05 21:40:35 +00:00
|
|
|
url = "https://github.com/${pname}/${pname}/releases/download/${version}/${pname}-${version}.tar.xz";
|
|
|
|
sha256 = "0qf88wd6riycq56d24brybyc93ns74s0nyyavm43zp2kfcihn6fd";
|
2007-08-21 12:31:33 +00:00
|
|
|
};
|
2012-02-06 05:49:27 +00:00
|
|
|
|
2020-07-29 03:21:36 +00:00
|
|
|
patches = [
|
|
|
|
# Unreleased fix for https://github.com/fontforge/fontforge/issues/4229
|
|
|
|
# which is required to fix an uninterposated `${CMAKE_INSTALL_PREFIX}/lib`, see
|
|
|
|
# see https://github.com/nh2/static-haskell-nix/pull/98#issuecomment-665395399
|
|
|
|
# TODO: Remove https://github.com/fontforge/fontforge/pull/4232 is in a release.
|
|
|
|
(fetchpatch {
|
|
|
|
name = "fontforge-cmake-set-rpath-to-the-configure-time-CMAKE_INSTALL_PREFIX";
|
|
|
|
url = "https://github.com/fontforge/fontforge/commit/297ee9b5d6db5970ca17ebe5305189e79a1520a1.patch";
|
|
|
|
sha256 = "14qfp8pwh0vzzib4hq2nc6xhn8lc1cal1sb0lqwb2q5dijqx5kqk";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2019-03-26 21:22:03 +00:00
|
|
|
# use $SOURCE_DATE_EPOCH instead of non-deterministic timestamps
|
2017-08-15 18:41:56 +00: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
|
|
|
|
'';
|
2017-08-12 14:22:45 +00:00
|
|
|
|
|
|
|
# do not use x87's 80-bit arithmetic, rouding errors result in very different font binaries
|
2019-10-29 23:53:51 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isi686 "-msse2 -mfpmath=sse";
|
2015-01-12 12:17:28 +00:00
|
|
|
|
2020-06-05 21:40:35 +00:00
|
|
|
nativeBuildInputs = [ pkgconfig cmake ];
|
2015-01-12 12:17:28 +00:00
|
|
|
buildInputs = [
|
2020-01-13 14:59:01 +00:00
|
|
|
readline uthash woff2 zeromq libuninameslist
|
2015-01-12 12:17:28 +00:00
|
|
|
python freetype zlib glib libungif libpng libjpeg libtiff libxml2
|
|
|
|
]
|
2017-02-01 13:59:35 +00:00
|
|
|
++ lib.optionals withSpiro [libspiro]
|
2020-06-06 00:03:38 +00:00
|
|
|
++ lib.optionals withGUI [ gtk3 cairo pango ]
|
2016-09-04 03:38:23 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
|
2015-01-12 12:17:28 +00:00
|
|
|
|
2020-06-05 21:40:35 +00:00
|
|
|
cmakeFlags = [ "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" ]
|
|
|
|
++ lib.optional (!withSpiro) "-DENABLE_LIBSPIRO=OFF"
|
2020-06-06 00:03:38 +00:00
|
|
|
++ lib.optional (!withGUI) "-DENABLE_GUI=OFF"
|
|
|
|
++ lib.optional (!withGTK) "-DENABLE_X11=ON"
|
2020-06-05 21:40:35 +00:00
|
|
|
++ lib.optional withExtras "-DENABLE_FONTFORGE_EXTRAS=ON";
|
2012-02-06 05:49:27 +00:00
|
|
|
|
2016-10-05 17:04:03 +00:00
|
|
|
# work-around: git isn't really used, but configuration fails without it
|
2015-01-12 12:17:28 +00:00
|
|
|
preConfigure = ''
|
2017-08-12 22:53:29 +00:00
|
|
|
# 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)
|
2008-03-26 12:57:30 +00:00
|
|
|
'';
|
2007-08-21 12:31:33 +00:00
|
|
|
|
2015-01-12 12:17:28 +00:00
|
|
|
postInstall =
|
|
|
|
# get rid of the runtime dependency on python
|
|
|
|
lib.optionalString (!withPython) ''
|
|
|
|
rm -r "$out/share/fontforge/python"
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "A font editor";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "http://fontforge.github.io";
|
2015-01-12 12:17:28 +00:00
|
|
|
platforms = stdenv.lib.platforms.all;
|
2017-03-23 14:10:34 +00:00
|
|
|
license = stdenv.lib.licenses.bsd3;
|
2020-01-13 14:59:01 +00:00
|
|
|
maintainers = [ stdenv.lib.maintainers.erictapen ];
|
2015-01-12 12:17:28 +00:00
|
|
|
};
|
2007-08-21 12:31:33 +00:00
|
|
|
}
|