nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 78 lines 2.3 kB view raw
1{ lib, stdenv, fetchzip, fontforge 2, bdftopcf, xorg 3}: 4 5stdenv.mkDerivation { 6 pname = "dina-font"; 7 version = "2.92"; 8 9 outputs = [ "out" "bdf" ]; 10 11 src = fetchzip { 12 url = "https://www.dcmembers.com/jibsen/download/61/?wpdmdl=61"; 13 hash = "sha256-JK+vnOyhAbwT825S+WKbQuWgRrfZZHfyhaMQ/6ljO8s="; 14 extension = "zip"; 15 stripRoot = false; 16 }; 17 18 nativeBuildInputs = 19 [ fontforge bdftopcf xorg.mkfontscale xorg.fonttosfnt ]; 20 21 buildPhase = '' 22 runHook preBuild 23 24 newName() { 25 local name=''${1##*/} 26 test "''${name:5:1}" = i && _it=Italic || _it= 27 case ''${name:6:3} in 28 400) _weight=Medium ;; 29 700) _weight=Bold ;; 30 esac 31 _pt=''${1%.bdf} 32 _pt=''${_pt#*-} 33 echo "Dina$_weight$_it$_pt" 34 } 35 36 # Re-encode the provided BDF files from CP1252 to Unicode as fonttosfnt does 37 # not support the former. 38 # We could generate the PCF and OTB files with fontforge directly, but that 39 # results in incorrect spacing in various places. 40 for f in BDF/*.bdf; do 41 basename=''${f##*/} basename=''${basename%.*} 42 fontforge -lang=ff -c "Open(\"$f\"); Reencode(\"win\", 1); Reencode(\"unicode\"); Generate(\"$basename.bdf\")" 43 mv "$basename"-*.bdf "$basename".bdf # remove the superfluous added size suffix 44 done 45 46 for f in *.bdf; do 47 name=$(newName "$f") 48 bdftopcf -t -o "$name.pcf" "$f" 49 fonttosfnt -v -o "$name.otb" "$f" 50 done 51 gzip -n -9 *.pcf 52 53 runHook postBuild 54 ''; 55 56 installPhase = '' 57 runHook preInstall 58 59 install -D -m 644 -t "$out/share/fonts/misc" *.pcf.gz *.otb 60 install -D -m 644 -t "$bdf/share/fonts/misc" *.bdf 61 mkfontdir "$out/share/fonts/misc" 62 mkfontdir "$bdf/share/fonts/misc" 63 64 runHook postInstall 65 ''; 66 67 meta = with lib; { 68 description = "A monospace bitmap font aimed at programmers"; 69 longDescription = '' 70 Dina is a monospace bitmap font, primarily aimed at programmers. It is 71 relatively compact to allow a lot of code on screen, while (hopefully) 72 clear enough to remain readable even at high resolutions. 73 ''; 74 homepage = "https://www.dcmembers.com/jibsen/download/61/"; 75 license = licenses.free; 76 maintainers = with maintainers; [ prikhi ncfavier ]; 77 }; 78}