summary refs log tree commit diff
path: root/pkgs/data/fonts/gohufont/default.nix
blob: b331edf7aa1e31f1431785ef65a7248af2a2adac (plain) (blame)
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
{ stdenv, fetchurl, fetchFromGitHub
, mkfontscale, bdf2psf, bdftopcf
, fonttosfnt, libfaketime
}:

stdenv.mkDerivation rec {
  pname = "gohufont";
  version = "2.1";

  src = fetchFromGitHub {
    owner  = "hchargois";
    repo   = "gohufont";
    rev    = "cc36b8c9fed7141763e55dcee0a97abffcf08224";
    sha256 = "1hmp11mrr01b29phw0xyj4h9b92qz19cf56ssf6c47c5j2c4xmbv";
  };

  nativeBuildInputs =
    [ mkfontscale bdf2psf bdftopcf
      fonttosfnt libfaketime
    ];

  buildPhase = ''
    # convert bdf fonts to psf
    build=$(pwd)
    mkdir psf
    cd ${bdf2psf}/share/bdf2psf
    for i in $src/*.bdf; do
      name=$(basename $i .bdf)
      bdf2psf \
        --fb "$i" standard.equivalents \
        ascii.set+useful.set+linux.set 512 \
        "$build/psf/$name.psf"
    done
    cd $build

    # convert bdf fonts to pcf
    for i in *.bdf $src/hidpi/*.bdf; do
        name=$(basename $i .bdf)
        bdftopcf -o "$name.pcf" "$i"
    done

    # convert unicode bdf fonts to otb
    for i in *-uni*.bdf $src/hidpi/*-uni*.bdf; do
        name=$(basename $i .bdf)
        faketime -f "1970-01-01 00:00:01" \
        fonttosfnt -v -o "$name.otb" "$i"
    done
  '';

  installPhase = ''
    # install the psf fonts (for the virtual console)
    fontDir="$out/share/consolefonts"
    install -D -m 644 -t "$fontDir" psf/*.psf

    # install the pcf fonts (for xorg applications)
    fontDir="$out/share/fonts/misc"
    install -D -m 644 -t "$fontDir" *.pcf
    mkfontdir "$fontDir"

    # install the otb fonts (for gtk applications)
    fontDir="$otb/share/fonts/misc"
    install -D -m 644 -t "$fontDir" *.otb
    mkfontdir "$fontDir"
  '';

  outputs = [ "out" "otb" ];

  meta = with stdenv.lib; {
    description = ''
      A monospace bitmap font well suited for programming and terminal use
    '';
    homepage    = https://font.gohu.org/;
    license     = licenses.wtfpl;
    maintainers = with maintainers; [ epitrochoid rnhmjoj ];
  };
}