···33 stdenvNoCC,
44 fetchurl,
55 cabextract,
66+ fontforge,
67}:
7889stdenvNoCC.mkDerivation {
···1415 hash = "sha256-xOdTVI0wkv/X3ThJEF4KJtm1oa/kbm5mf+fGiHiTcB8=";
1516 };
16171717- nativeBuildInputs = [ cabextract ];
1818+ nativeBuildInputs = [
1919+ cabextract
2020+ fontforge
2121+ ];
18221923 unpackPhase = ''
2024 runHook preUnpack
···3034 runHook preInstall
31353236 mkdir -p $out/share/fonts/truetype
3333- cp *.ttf *.ttc $out/share/fonts/truetype
3737+3838+ # Remove the embedded bitmaps from Calibri and Cambria because they have very low resolutions.
3939+ fontforge -c "
4040+ import fontforge
4141+ import sys
4242+4343+ def removeBitmaps(font):
4444+ for table in ('EBDT', 'EBLC', 'EBSC'):
4545+ font.setTableData(table, None)
4646+4747+ for path in sys.argv[1:]:
4848+ fonts = [fontforge.open(f'{path}({font})') for font in fontforge.fontsInFile(path)]
4949+ for font in fonts:
5050+ removeBitmaps(font)
5151+ if len(fonts) > 1:
5252+ fonts[0].generateTtc(f'$out/share/fonts/truetype/{path}', fonts[1:], layer=fonts[0].activeLayer)
5353+ else:
5454+ fonts[0].generate(f'$out/share/fonts/truetype/{path}')
5555+ " calibri* cambria*
5656+5757+ cp -n *.ttf *.ttc $out/share/fonts/truetype
34583535- # Set up no-op font configs to override any aliases set up by
3636- # other packages.
5959+ # Set up no-op font configs to override any aliases set up by other packages.
3760 mkdir -p $out/etc/fonts/conf.d
3861 for name in Calibri Cambria Candara Consolas Constantia Corbel ; do
3962 substitute ${./no-op.conf} $out/etc/fonts/conf.d/30-''${name,,}.conf \