1{
2 lib,
3 stdenv,
4 fetchurl,
5 cabextract,
6}:
7
8let
9 fonts = [
10 {
11 name = "andale";
12 hash = "sha256-BST+QpUa3Dp+uHDjLwkgMTxx8XDIWbX3cNgrTuER6XA=";
13 }
14 {
15 name = "arial";
16 hash = "sha256-hSl6TRRunIesb3SCJzS97l9LKnItfqpYS38sv3b0ePY=";
17 }
18 {
19 name = "arialb";
20 hash = "sha256-pCXw/7ahpe3luXntYXf09PT972rnwwKnt3IO8zL+wKg=";
21 }
22 {
23 name = "comic";
24 hash = "sha256-nG3z/u/eJtTkHUpP5dsqifkSOncllNf1mv0GJiXNIE4=";
25 }
26 {
27 name = "courie";
28 hash = "sha256-u1EdhhZV3eh5rlUuuGsTTW+uZ8tYUC5v9z7F2RUfM4Q=";
29 }
30 {
31 name = "georgi";
32 hash = "sha256-LCx9zaZgbqXPCJGPt80/M1np6EM43GkAE/IM1C6TAwE=";
33 }
34 {
35 name = "impact";
36 hash = "sha256-YGHvO3QB2WQvXf218rN2qhRmP2J15gpRIHrU+s8vzPs=";
37 }
38 {
39 name = "times";
40 hash = "sha256-21ZZXsbvXT3lwkmU8AHwOyoT43zuJ7wlxY9vQ+j4B6s=";
41 }
42 {
43 name = "trebuc";
44 hash = "sha256-WmkNm7hRC+G4tP5J8fIxllH+UbvlR3Xd3djvC9B/2sk=";
45 }
46 {
47 name = "webdin";
48 hash = "sha256-ZFlbWrwQgPuoYQxcNPq1hjQI6Aaq/oRlPKhXW+0X11o=";
49 }
50 {
51 name = "verdan";
52 hash = "sha256-wcthJV42MWZ5TkdmTi8hr446JstjRuuNKuL6hd1arZY=";
53 }
54 {
55 name = "wd97vwr";
56 hash = "sha256-9hEmptF7LRJqfzGxQlBNzkk095icVfHBPGR3s/6As9I=";
57 }
58 ];
59
60 eula = fetchurl {
61 url = "https://corefonts.sourceforge.net/eula.htm";
62 hash = "sha256-LOgNEsM+dANEreP2LsFi+pAnBNDMFB9Pg+KJAahlC6s=";
63 };
64in
65stdenv.mkDerivation {
66 pname = "corefonts";
67 version = "1";
68
69 exes = map (
70 { name, hash }:
71 fetchurl {
72 url = "mirror://sourceforge/corefonts/the%20fonts/final/${name}32.exe";
73 inherit hash;
74 }
75 ) fonts;
76
77 nativeBuildInputs = [ cabextract ];
78
79 buildCommand = ''
80 for i in $exes; do
81 cabextract --lowercase $i
82 done
83 cabextract --lowercase viewer1.cab
84
85 # rename to more standard names
86 # handle broken macOS file-system
87 mv andalemo.ttf Andale_Mono.ttf
88 mv ariblk.ttf Arial_Black.ttf
89 mv arial.ttf Arial.ttf.tmp
90 mv Arial.ttf.tmp Arial.ttf
91 mv arialbd.ttf Arial_Bold.ttf
92 mv arialbi.ttf Arial_Bold_Italic.ttf
93 mv ariali.ttf Arial_Italic.ttf
94 mv comic.ttf Comic_Sans_MS.ttf
95 mv comicbd.ttf Comic_Sans_MS_Bold.ttf
96 mv cour.ttf Courier_New.ttf
97 mv courbd.ttf Courier_New_Bold.ttf
98 mv couri.ttf Courier_New_Italic.ttf
99 mv courbi.ttf Courier_New_Bold_Italic.ttf
100 mv georgia.ttf Georgia.ttf.tmp
101 mv Georgia.ttf.tmp Georgia.ttf
102 mv georgiab.ttf Georgia_Bold.ttf
103 mv georgiai.ttf Georgia_Italic.ttf
104 mv georgiaz.ttf Georgia_Bold_Italic.ttf
105 mv impact.ttf Impact.ttf.tmp
106 mv Impact.ttf.tmp Impact.ttf
107 mv tahoma.ttf Tahoma.ttf.tmp
108 mv Tahoma.ttf.tmp Tahoma.ttf
109 mv times.ttf Times_New_Roman.ttf
110 mv timesbd.ttf Times_New_Roman_Bold.ttf
111 mv timesbi.ttf Times_New_Roman_Bold_Italic.ttf
112 mv timesi.ttf Times_New_Roman_Italic.ttf
113 mv trebuc.ttf Trebuchet_MS.ttf
114 mv trebucbd.ttf Trebuchet_MS_Bold.ttf
115 mv trebucit.ttf Trebuchet_MS_Italic.ttf
116 mv trebucbi.ttf Trebuchet_MS_Italic.ttf
117 mv verdana.ttf Verdana.ttf.tmp
118 mv Verdana.ttf.tmp Verdana.ttf
119 mv verdanab.ttf Verdana_Bold.ttf
120 mv verdanai.ttf Verdana_Italic.ttf
121 mv verdanaz.ttf Verdana_Bold_Italic.ttf
122 mv webdings.ttf Webdings.ttf.tmp
123 mv Webdings.ttf.tmp Webdings.ttf
124
125 install -m444 -Dt $out/share/fonts/truetype *.ttf
126
127 # Also put the EULA there to be on the safe side.
128 cp ${eula} $out/share/fonts/truetype/eula.html
129
130 # Set up no-op font configs to override any aliases set up by other packages.
131 mkdir -p $out/etc/fonts/conf.d
132 for name in Andale-Mono Arial-Black Arial Comic-Sans-MS \
133 Courier-New Georgia Impact Times-New-Roman \
134 Trebuchet Verdana Webdings ; do
135 substitute ${./no-op.conf} $out/etc/fonts/conf.d/30-''${name,,}.conf \
136 --subst-var-by fontname "''${name//-/ }"
137 done
138 '';
139
140 meta = with lib; {
141 homepage = "https://corefonts.sourceforge.net/";
142 description = "Microsoft's TrueType core fonts for the Web";
143 platforms = platforms.all;
144 license = licenses.unfreeRedistributable;
145 # Set a non-zero priority to allow easy overriding of the
146 # fontconfig configuration files.
147 priority = 5;
148 };
149}