lol

google-fonts: add font selection parameter (#201556)

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>

authored by

laalsaas
Sandro
and committed by
GitHub
c3f650c3 ef66a16e

+29 -8
+29 -8
pkgs/data/fonts/google-fonts/default.nix
··· 1 - { lib, stdenvNoCC, fetchFromGitHub }: 1 + { lib 2 + , stdenvNoCC 3 + , fetchFromGitHub 4 + , fonts ? [] 5 + }: 2 6 3 7 stdenvNoCC.mkDerivation { 4 8 pname = "google-fonts"; 5 - version = "unstable-2022-02-26"; 9 + version = "unstable-2022-11-14"; 6 10 11 + # Adobe Blank is split out in a seperate output, 12 + # because it causes crashes with `libfontconfig`. 13 + # It has an absurd number of symbols 7 14 outputs = [ "out" "adobeBlank" ]; 8 15 9 16 src = fetchFromGitHub { 10 17 owner = "google"; 11 18 repo = "fonts"; 12 - rev = "2fba0d68602b7eb3374d030c1c34939de56023f9"; 13 - sha256 = "sha256-IFkKwRRyZeOXD8/9n8UDrruUKK6oQK4BD9wYN2dmSAc="; 19 + rev = "83e116a566eda04a2469a11ee562cef1d7b33e4f"; 20 + sha256 = "sha256-sSabk+VWkoXj1Nzv9ufgIU/nkfKf4XkZU1SO+j+eSPA="; 14 21 }; 15 22 16 - patchPhase = '' 23 + postPatch = '' 17 24 # These directories need to be removed because they contain 18 25 # older or duplicate versions of fonts also present in other 19 26 # directories. This causes non-determinism in the install since 20 27 # the installation order of font files with the same name is not 21 28 # fixed. 22 29 rm -rv ofl/cabincondensed \ 23 - ofl/signikanegative \ 24 - ofl/signikanegativesc 30 + ofl/signikanegative \ 31 + ofl/signikanegativesc \ 32 + axisregistry/tests/data 25 33 26 34 if find . -name "*.ttf" | sed 's|.*/||' | sort | uniq -c | sort -n | grep -v '^.*1 '; then 27 35 echo "error: duplicate font names" ··· 31 39 32 40 dontBuild = true; 33 41 42 + # The font files are in the fonts directory and use two naming schemes: 43 + # FamilyName-StyleName.ttf and FamilyName[param1,param2,...].ttf 44 + # This installs all fonts if fonts is empty and otherwise only 45 + # the specified fonts by FamilyName. To do this, it invokes 46 + # `find` 2 times for every font, anyone is free to do this 47 + # in a more efficient way. 48 + fonts = map (font: builtins.replaceStrings [" "] [""] font) fonts; 34 49 installPhase = '' 35 50 adobeBlankDest=$adobeBlank/share/fonts/truetype 36 51 install -m 444 -Dt $adobeBlankDest ofl/adobeblank/AdobeBlank-Regular.ttf 37 52 rm -r ofl/adobeblank 38 53 dest=$out/share/fonts/truetype 54 + '' + (if fonts == [] then '' 39 55 find . -name '*.ttf' -exec install -m 444 -Dt $dest '{}' + 40 - ''; 56 + '' else '' 57 + for font in $fonts; do 58 + find . -name "$font-*.ttf" -exec install -m 444 -Dt $dest '{}' + 59 + find . -name "$font[*.ttf" -exec install -m 444 -Dt $dest '{}' + 60 + done 61 + ''); 41 62 42 63 meta = with lib; { 43 64 homepage = "https://fonts.google.com";