vista-fonts: Remove the embedded bitmaps from Calibri and Cambria because they have very low resolutions

+27 -4
+27 -4
pkgs/by-name/vi/vista-fonts/package.nix
··· 3 3 stdenvNoCC, 4 4 fetchurl, 5 5 cabextract, 6 + fontforge, 6 7 }: 7 8 8 9 stdenvNoCC.mkDerivation { ··· 14 15 hash = "sha256-xOdTVI0wkv/X3ThJEF4KJtm1oa/kbm5mf+fGiHiTcB8="; 15 16 }; 16 17 17 - nativeBuildInputs = [ cabextract ]; 18 + nativeBuildInputs = [ 19 + cabextract 20 + fontforge 21 + ]; 18 22 19 23 unpackPhase = '' 20 24 runHook preUnpack ··· 30 34 runHook preInstall 31 35 32 36 mkdir -p $out/share/fonts/truetype 33 - cp *.ttf *.ttc $out/share/fonts/truetype 37 + 38 + # Remove the embedded bitmaps from Calibri and Cambria because they have very low resolutions. 39 + fontforge -c " 40 + import fontforge 41 + import sys 42 + 43 + def removeBitmaps(font): 44 + for table in ('EBDT', 'EBLC', 'EBSC'): 45 + font.setTableData(table, None) 46 + 47 + for path in sys.argv[1:]: 48 + fonts = [fontforge.open(f'{path}({font})') for font in fontforge.fontsInFile(path)] 49 + for font in fonts: 50 + removeBitmaps(font) 51 + if len(fonts) > 1: 52 + fonts[0].generateTtc(f'$out/share/fonts/truetype/{path}', fonts[1:], layer=fonts[0].activeLayer) 53 + else: 54 + fonts[0].generate(f'$out/share/fonts/truetype/{path}') 55 + " calibri* cambria* 56 + 57 + cp -n *.ttf *.ttc $out/share/fonts/truetype 34 58 35 - # Set up no-op font configs to override any aliases set up by 36 - # other packages. 59 + # Set up no-op font configs to override any aliases set up by other packages. 37 60 mkdir -p $out/etc/fonts/conf.d 38 61 for name in Calibri Cambria Candara Consolas Constantia Corbel ; do 39 62 substitute ${./no-op.conf} $out/etc/fonts/conf.d/30-''${name,,}.conf \