2021-04-05 13:04:24 +02:00
|
|
|
{ stdenv, fetchpatch, fetchFromGitHub, lib
|
2021-01-17 04:51:22 +01:00
|
|
|
, cmake, perl, uthash, pkg-config, gettext
|
2021-02-12 22:15:48 +01:00
|
|
|
, python, freetype, zlib, glib, giflib, libpng, libjpeg, libtiff, libxml2, cairo, pango
|
2020-01-13 15:59:01 +01:00
|
|
|
, readline, woff2, zeromq, libuninameslist
|
2017-02-01 14:59:35 +01:00
|
|
|
, withSpiro ? false, libspiro
|
2020-06-05 23:40:35 +02:00
|
|
|
, withGTK ? false, gtk3
|
2020-06-06 02:03:38 +02:00
|
|
|
, withGUI ? withGTK
|
2016-06-11 00:41:44 +02:00
|
|
|
, withPython ? true
|
2019-03-26 22:22:03 +01:00
|
|
|
, withExtras ? true
|
2021-08-12 11:30:23 +02:00
|
|
|
, Carbon, Cocoa
|
2007-08-21 14:31:33 +02:00
|
|
|
}:
|
|
|
|
|
2020-06-06 02:03:38 +02:00
|
|
|
assert withGTK -> withGUI;
|
|
|
|
|
2016-06-11 00:41:44 +02:00
|
|
|
stdenv.mkDerivation rec {
|
2019-03-26 22:22:03 +01:00
|
|
|
pname = "fontforge";
|
2021-01-14 17:17:19 +01:00
|
|
|
version = "20201107";
|
2017-08-12 16:22:45 +02:00
|
|
|
|
2021-01-14 17:17:19 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
|
|
|
sha256 = "sha256-Rl/5lbXaPgIndANaD0IakaDus6T53FjiBb45FIuGrvc=";
|
2007-08-21 14:31:33 +02:00
|
|
|
};
|
2012-02-06 06:49:27 +01:00
|
|
|
|
2021-04-05 13:04:24 +02:00
|
|
|
patches = [
|
|
|
|
# Allow installing contrib files (e.g. extras and tools).
|
|
|
|
# Taken from https://salsa.debian.org/fonts-team/fontforge/-/blob/master/debian/patches/0001-add-extra-cmake-install-rules.patch
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://salsa.debian.org/fonts-team/fontforge/raw/76bffe6ccf8ab20a0c81476a80a87ad245e2fd1c/debian/patches/0001-add-extra-cmake-install-rules.patch";
|
|
|
|
sha256 = "u3D9od2xLECNEHhZ+8dkuv9818tPkdP6y/Tvd9CADJg=";
|
|
|
|
})
|
2021-08-11 00:26:52 +02:00
|
|
|
# Fix segmentation fault with some fonts.
|
|
|
|
# This is merged and should be present in the next release.
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/fontforge/fontforge/commit/69e263b2aff29ad22f97f13935cfa97a1eabf207.patch";
|
|
|
|
sha256 = "06yyf90605aq6ppfiz83mqkdmnaq5418axp9jgsjyjq78b00xb29";
|
|
|
|
})
|
2021-04-05 13:04:24 +02:00
|
|
|
];
|
|
|
|
|
2019-03-26 22:22:03 +01:00
|
|
|
# use $SOURCE_DATE_EPOCH instead of non-deterministic timestamps
|
2017-08-15 20:41:56 +02: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 16:22:45 +02:00
|
|
|
|
|
|
|
# do not use x87's 80-bit arithmetic, rouding errors result in very different font binaries
|
2019-10-30 00:53:51 +01:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isi686 "-msse2 -mfpmath=sse";
|
2015-01-12 13:17:28 +01:00
|
|
|
|
2021-01-17 04:51:22 +01:00
|
|
|
nativeBuildInputs = [ pkg-config cmake ];
|
2015-01-12 13:17:28 +01:00
|
|
|
buildInputs = [
|
2020-01-13 15:59:01 +01:00
|
|
|
readline uthash woff2 zeromq libuninameslist
|
2021-02-12 22:15:48 +01:00
|
|
|
python freetype zlib glib giflib libpng libjpeg libtiff libxml2
|
2015-01-12 13:17:28 +01:00
|
|
|
]
|
2021-08-12 11:30:23 +02:00
|
|
|
++ lib.optionals withSpiro [ libspiro ]
|
2020-06-06 02:03:38 +02:00
|
|
|
++ lib.optionals withGUI [ gtk3 cairo pango ]
|
2016-09-04 05:38:23 +02:00
|
|
|
++ lib.optionals stdenv.isDarwin [ Carbon Cocoa ];
|
2015-01-12 13:17:28 +01:00
|
|
|
|
2020-06-05 23:40:35 +02:00
|
|
|
cmakeFlags = [ "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" ]
|
|
|
|
++ lib.optional (!withSpiro) "-DENABLE_LIBSPIRO=OFF"
|
2020-06-06 02:03:38 +02:00
|
|
|
++ lib.optional (!withGUI) "-DENABLE_GUI=OFF"
|
|
|
|
++ lib.optional (!withGTK) "-DENABLE_X11=ON"
|
2020-06-05 23:40:35 +02:00
|
|
|
++ lib.optional withExtras "-DENABLE_FONTFORGE_EXTRAS=ON";
|
2012-02-06 06:49:27 +01:00
|
|
|
|
2016-10-05 19:04:03 +02:00
|
|
|
# work-around: git isn't really used, but configuration fails without it
|
2015-01-12 13:17:28 +01:00
|
|
|
preConfigure = ''
|
2017-08-13 00:53:29 +02: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 13:57:30 +01:00
|
|
|
'';
|
2007-08-21 14:31:33 +02:00
|
|
|
|
2015-01-12 13:17:28 +01:00
|
|
|
postInstall =
|
|
|
|
# get rid of the runtime dependency on python
|
|
|
|
lib.optionalString (!withPython) ''
|
|
|
|
rm -r "$out/share/fontforge/python"
|
|
|
|
'';
|
|
|
|
|
2021-08-12 11:30:23 +02:00
|
|
|
meta = with lib; {
|
2015-01-12 13:17:28 +01:00
|
|
|
description = "A font editor";
|
2021-08-12 11:30:23 +02:00
|
|
|
homepage = "https://fontforge.github.io";
|
|
|
|
platforms = platforms.all;
|
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = [ maintainers.erictapen ];
|
2015-01-12 13:17:28 +01:00
|
|
|
};
|
2007-08-21 14:31:33 +02:00
|
|
|
}
|