dina-font: fix encoding

The provided BDF files are encoded as CP1252, but they claim to be
ISO8859-1. This causes a few glyphs (like `œ`) to be unused.

Use fontforge to re-encode from CP1252 to Unicode, but keep doing the
conversion with other tools because fontforge introduces spacing issues.

+28 -20
+28 -20
pkgs/data/fonts/dina/default.nix
··· 1 - { lib, stdenv, fetchurl, unzip 1 + { lib, stdenv, fetchzip, fontforge 2 2 , bdftopcf, xorg 3 3 }: 4 4 ··· 8 8 9 9 outputs = [ "out" "bdf" ]; 10 10 11 - src = fetchurl { 12 - url = "http://www.donationcoder.com/Software/Jibz/Dina/downloads/Dina.zip"; 13 - sha256 = "1kq86lbxxgik82aywwhawmj80vsbz3hfhdyhicnlv9km7yjvnl8z"; 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; 14 16 }; 15 17 16 18 nativeBuildInputs = 17 - [ unzip bdftopcf xorg.mkfontscale xorg.fonttosfnt ]; 18 - 19 - postPatch = '' 20 - sed -i 's/microsoft-cp1252/ISO8859-1/' *.bdf 21 - ''; 19 + [ fontforge bdftopcf xorg.mkfontscale xorg.fonttosfnt ]; 22 20 23 21 buildPhase = '' 24 22 runHook preBuild 25 23 26 24 newName() { 27 - test "''${1:5:1}" = i && _it=Italic || _it= 28 - case ''${1:6:3} in 29 - 400) test -z $it && _weight=Medium ;; 30 - 700) _weight=Bold ;; 31 - esac 32 - _pt=''${1%.bdf} 33 - _pt=''${_pt#*-} 34 - echo "Dina$_weight$_it$_pt" 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" 35 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 36 45 37 46 for f in *.bdf; do 38 47 name=$(newName "$f") ··· 62 71 relatively compact to allow a lot of code on screen, while (hopefully) 63 72 clear enough to remain readable even at high resolutions. 64 73 ''; 65 - homepage = "https://www.donationcoder.com/Software/Jibz/Dina/"; 66 - downloadPage = "https://www.donationcoder.com/Software/Jibz/Dina/"; 74 + homepage = "https://www.dcmembers.com/jibsen/download/61/"; 67 75 license = licenses.free; 68 - maintainers = [ maintainers.prikhi ]; 76 + maintainers = with maintainers; [ prikhi ncfavier ]; 69 77 }; 70 78 }