summaryrefslogtreecommitdiffstats
path: root/pkgs/data/fonts/liberation-fonts/default.nix
blob: 6a13ca68258667c03b6effdb4c7e5a23a4df139a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{
  lib,
  stdenv,
  fetchFromGitHub,
  fontforge,
  installFonts,
  python3,
}:
let
  inherit (python3.pkgs) fonttools;

  commonNativeBuildInputs = [
    fontforge
    installFonts
    python3
  ];
  common =
    {
      version,
      repo,
      sha256,
      docsToInstall,
      nativeBuildInputs,
      postPatch ? null,
    }:
    stdenv.mkDerivation rec {
      pname = "liberation-fonts";
      inherit version;

      src = fetchFromGitHub {
        owner = "liberationfonts";
        rev = version;
        inherit repo sha256;
      };

      inherit nativeBuildInputs postPatch;

      installPhase = ''
        runHook preInstall

        for i in ${toString docsToInstall}; do
          # not all docs exist in all versions
          install -m444 -Dt $out/share/doc/${pname}-${version} $i || true
        done

        runHook postInstall
      '';

      meta = {
        description = "Liberation Fonts, replacements for Times New Roman, Arial, and Courier New";
        longDescription = ''
          The Liberation Fonts are intended to be replacements for the three most
          commonly used fonts on Microsoft systems: Times New Roman, Arial, and
          Courier New. Since 2012 they are based on croscore fonts.

          There are three sets: Sans (a substitute for Arial, Albany, Helvetica,
          Nimbus Sans L, and Bitstream Vera Sans), Serif (a substitute for Times
          New Roman, Thorndale, Nimbus Roman, and Bitstream Vera Serif) and Mono
          (a substitute for Courier New, Cumberland, Courier, Nimbus Mono L, and
          Bitstream Vera Sans Mono).
        '';

        license = lib.licenses.ofl;
        homepage = "https://github.com/liberationfonts";
        maintainers = with lib.maintainers; [ raskin ];
      };
    };
in
{
  liberation_ttf_v1 = common {
    repo = "liberation-1.7-fonts";
    version = "1.07.5";
    docsToInstall = [
      "AUTHORS"
      "ChangeLog"
      "COPYING"
      "License.txt"
      "README"
    ];
    nativeBuildInputs = commonNativeBuildInputs;
    sha256 = "1ffl10mf78hx598sy9qr5m6q2b8n3mpnsj73bwixnd4985gsz56v";
  };
  liberation_ttf_v2 = common {
    repo = "liberation-fonts";
    version = "2.1.5";
    docsToInstall = [
      "AUTHORS"
      "ChangeLog"
      "LICENSE"
      "README.md"
    ];
    nativeBuildInputs = commonNativeBuildInputs ++ [ fonttools ];
    postPatch = ''
      substituteInPlace scripts/setisFixedPitch-fonttools.py --replace \
        'font = ttLib.TTFont(fontfile)' \
        'font = ttLib.TTFont(fontfile, recalcTimestamp=False)'
    '';
    sha256 = "Wg1uoD2k/69Wn6XU+7wHqf2KO/bt4y7pwgmG7+IUh4Q=";
  };
}