about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/freetype
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/freetype')
-rw-r--r--nixpkgs/pkgs/development/libraries/freetype/default.nix109
-rw-r--r--nixpkgs/pkgs/development/libraries/freetype/enable-subpixel-rendering.patch12
-rw-r--r--nixpkgs/pkgs/development/libraries/freetype/enable-table-validation.patch20
3 files changed, 141 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/freetype/default.nix b/nixpkgs/pkgs/development/libraries/freetype/default.nix
new file mode 100644
index 000000000000..6e6989d9304e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/freetype/default.nix
@@ -0,0 +1,109 @@
+{ lib, stdenv, fetchurl
+, buildPackages, pkgsHostHost
+, pkg-config, which, makeWrapper
+, zlib, bzip2, brotli, libpng, gnumake, glib
+
+, # FreeType supports LCD filtering (colloquially referred to as sub-pixel rendering).
+  # LCD filtering is also known as ClearType and covered by several Microsoft patents.
+  # This option allows it to be disabled. See http://www.freetype.org/patents.html.
+  useEncumberedCode ? true
+
+# for passthru.tests
+, cairo
+, fontforge
+, ghostscript
+, graphicsmagick
+, gtk3
+, harfbuzz
+, imagemagick
+, pango
+, poppler
+, python3
+, qt5
+, texmacs
+, ttfautohint
+, testers
+}:
+
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "freetype";
+  version = "2.13.1";
+
+  src = let inherit (finalAttrs) pname version; in fetchurl {
+    url = "mirror://savannah/${pname}/${pname}-${version}.tar.xz";
+    sha256 = "sha256-6mfjsBmxEE0WZ6onT13DB9jL1gazmbwy3zCKd/GlZL8=";
+  };
+
+  propagatedBuildInputs = [ zlib bzip2 brotli libpng ]; # needed when linking against freetype
+
+  # dependence on harfbuzz is looser than the reverse dependence
+  nativeBuildInputs = [ pkg-config which ]
+    ++ lib.optional (!stdenv.hostPlatform.isWindows) makeWrapper
+    # FreeType requires GNU Make, which is not part of stdenv on FreeBSD.
+    ++ lib.optional (!stdenv.isLinux) gnumake;
+
+  patches = [
+    ./enable-table-validation.patch
+  ] ++ lib.optional useEncumberedCode ./enable-subpixel-rendering.patch;
+
+  outputs = [ "out" "dev" ];
+
+  configureFlags = [ "--bindir=$(dev)/bin" "--enable-freetype-config" ];
+
+  # native compiler to generate building tool
+  CC_BUILD = "${buildPackages.stdenv.cc}/bin/cc";
+
+  # The asm for armel is written with the 'asm' keyword.
+  CFLAGS = lib.optionalString stdenv.isAarch32 "-std=gnu99"
+    + lib.optionalString stdenv.hostPlatform.is32bit " -D_FILE_OFFSET_BITS=64";
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  postInstall = glib.flattenInclude
+    # pkgsCross.mingwW64.pkg-config doesn't build
+    # makeWrapper doesn't cross-compile to windows #120726
+    + lib.optionalString (!stdenv.hostPlatform.isMinGW) ''
+    substituteInPlace $dev/bin/freetype-config \
+      --replace ${buildPackages.pkg-config} ${pkgsHostHost.pkg-config}
+
+    wrapProgram "$dev/bin/freetype-config" \
+      --set PKG_CONFIG_PATH "$PKG_CONFIG_PATH:$dev/lib/pkgconfig"
+  '';
+
+  passthru.tests = {
+    inherit
+      cairo
+      fontforge
+      ghostscript
+      graphicsmagick
+      gtk3
+      harfbuzz
+      imagemagick
+      pango
+      poppler
+      texmacs
+      ttfautohint;
+    inherit (python3.pkgs) freetype-py;
+    inherit (qt5) qtbase;
+    pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
+  };
+
+  meta = with lib; {
+    description = "A font rendering engine";
+    longDescription = ''
+      FreeType is a portable and efficient library for rendering fonts. It
+      supports TrueType, Type 1, CFF fonts, and WOFF, PCF, FNT, BDF and PFR
+      fonts. It has a bytecode interpreter and has an automatic hinter called
+      autofit which can be used instead of hinting instructions included in
+      fonts.
+    '';
+    homepage = "https://www.freetype.org/";
+    license = licenses.gpl2Plus; # or the FreeType License (BSD + advertising clause)
+    platforms = platforms.all;
+    pkgConfigModules = [ "freetype2" ];
+    maintainers = with maintainers; [ ttuegel ];
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/freetype/enable-subpixel-rendering.patch b/nixpkgs/pkgs/development/libraries/freetype/enable-subpixel-rendering.patch
new file mode 100644
index 000000000000..6b3577eb4f02
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/freetype/enable-subpixel-rendering.patch
@@ -0,0 +1,12 @@
+Index: freetype-2.10.0/include/freetype/config/ftoption.h
+--- a/include/freetype/config/ftoption.h
++++ b/include/freetype/config/ftoption.h
+@@ -126,7 +126,7 @@ FT_BEGIN_HEADER
+    * macro is not defined, FreeType offers alternative LCD rendering
+    * technology that produces excellent output without LCD filtering.
+    */
+-/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
++#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
+ 
+ 
+   /**************************************************************************
diff --git a/nixpkgs/pkgs/development/libraries/freetype/enable-table-validation.patch b/nixpkgs/pkgs/development/libraries/freetype/enable-table-validation.patch
new file mode 100644
index 000000000000..bd964c3342d8
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/freetype/enable-table-validation.patch
@@ -0,0 +1,20 @@
+Index: freetype-2.10.0/modules.cfg
+===================================================================
+--- freetype-2.10.0.orig/modules.cfg
++++ freetype-2.10.0/modules.cfg
+@@ -120,6 +120,6 @@ AUX_MODULES += cache
+ # TrueType GX/AAT table validation.  Needs ftgxval.c below.
+ #
+-# AUX_MODULES += gxvalid
++AUX_MODULES += gxvalid
+ 
+ # Support for streams compressed with gzip (files with suffix .gz).
+ #
+@@ -143,6 +143,6 @@ AUX_MODULES += bzip2
+ # OpenType table validation.  Needs ftotval.c below.
+ #
+-# AUX_MODULES += otvalid
++AUX_MODULES += otvalid
+ 
+ # Auxiliary PostScript driver component to share common code.
+ #