1 { lib, stdenv, fetchurl
2 , buildPackages, pkgsHostHost
3 , pkg-config, which, makeWrapper
4 , zlib, bzip2, brotli, libpng, gnumake, glib
6 , # FreeType supports LCD filtering (colloquially referred to as sub-pixel rendering).
7 # LCD filtering is also known as ClearType and covered by several Microsoft patents.
8 # This option allows it to be disabled. See http://www.freetype.org/patents.html.
9 useEncumberedCode ? true
29 stdenv.mkDerivation (finalAttrs: {
33 src = let inherit (finalAttrs) pname version; in fetchurl {
34 url = "mirror://savannah/${pname}/${pname}-${version}.tar.xz";
35 sha256 = "sha256-EpkcTlXFBt1/m3ZZM+Yv0r4uBtQhUF15UKEy5PG7SE0=";
38 propagatedBuildInputs = [ zlib bzip2 brotli libpng ]; # needed when linking against freetype
40 # dependence on harfbuzz is looser than the reverse dependence
41 nativeBuildInputs = [ pkg-config which ]
42 ++ lib.optional (!stdenv.hostPlatform.isWindows) makeWrapper
43 # FreeType requires GNU Make, which is not part of stdenv on FreeBSD.
44 ++ lib.optional (!stdenv.isLinux) gnumake;
47 ./enable-table-validation.patch
48 ] ++ lib.optional useEncumberedCode ./enable-subpixel-rendering.patch;
50 outputs = [ "out" "dev" ];
52 configureFlags = [ "--bindir=$(dev)/bin" "--enable-freetype-config" ];
54 # native compiler to generate building tool
55 CC_BUILD = "${buildPackages.stdenv.cc}/bin/cc";
57 # The asm for armel is written with the 'asm' keyword.
58 CFLAGS = lib.optionalString stdenv.isAarch32 "-std=gnu99"
59 + lib.optionalString stdenv.hostPlatform.is32bit " -D_FILE_OFFSET_BITS=64";
61 enableParallelBuilding = true;
65 postInstall = glib.flattenInclude
66 # pkgsCross.mingwW64.pkg-config doesn't build
67 # makeWrapper doesn't cross-compile to windows #120726
68 + lib.optionalString (!stdenv.hostPlatform.isMinGW) ''
69 substituteInPlace $dev/bin/freetype-config \
70 --replace ${buildPackages.pkg-config} ${pkgsHostHost.pkg-config}
72 wrapProgram "$dev/bin/freetype-config" \
73 --set PKG_CONFIG_PATH "$PKG_CONFIG_PATH:$dev/lib/pkgconfig"
89 inherit (python3.pkgs) freetype-py;
91 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
95 description = "A font rendering engine";
97 FreeType is a portable and efficient library for rendering fonts. It
98 supports TrueType, Type 1, CFF fonts, and WOFF, PCF, FNT, BDF and PFR
99 fonts. It has a bytecode interpreter and has an automatic hinter called
100 autofit which can be used instead of hinting instructions included in
103 homepage = "https://www.freetype.org/";
104 changelog = "https://gitlab.freedesktop.org/freetype/freetype/-/raw/VER-${builtins.replaceStrings ["."] ["-"] finalAttrs.version}/docs/CHANGES";
105 license = licenses.gpl2Plus; # or the FreeType License (BSD + advertising clause)
106 platforms = platforms.all;
107 pkgConfigModules = [ "freetype2" ];
108 maintainers = with maintainers; [ ttuegel ];