author | haftmann |
Mon, 16 Jun 2025 15:25:38 +0200 | |
changeset 82730 | 3b98b1b57435 |
parent 81674 | 70d2f72098df |
permissions | -rw-r--r-- |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
1 |
/* Title: Pure/Admin/component_fonts.scala |
69330 | 2 |
Author: Makarius |
3 |
||
69354 | 4 |
Build standard Isabelle fonts: DejaVu base + Isabelle symbols. |
69330 | 5 |
*/ |
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
10 |
object Component_Fonts { |
69330 | 11 |
/* relevant codepoint ranges */ |
12 |
||
75393 | 13 |
object Range { |
69336 | 14 |
def base_font: Seq[Int] = |
69330 | 15 |
(0x0020 to 0x007e) ++ // ASCII |
16 |
(0x00a0 to 0x024f) ++ // Latin Extended-A/B |
|
17 |
(0x0400 to 0x04ff) ++ // Cyrillic |
|
18 |
(0x0600 to 0x06ff) ++ // Arabic |
|
19 |
Seq( |
|
69796 | 20 |
0x02dd, // hungarumlaut |
69330 | 21 |
0x2018, // single quote |
22 |
0x2019, // single quote |
|
23 |
0x201a, // single quote |
|
24 |
0x201c, // double quote |
|
25 |
0x201d, // double quote |
|
26 |
0x201e, // double quote |
|
81674
70d2f72098df
proper bullet symbols for GUI text -- in contrast to Isabelle \<bullet> 0x002219;
wenzelm
parents:
77566
diff
changeset
|
27 |
0x2022, // regular bullet |
70d2f72098df
proper bullet symbols for GUI text -- in contrast to Isabelle \<bullet> 0x002219;
wenzelm
parents:
77566
diff
changeset
|
28 |
0x2023, // triangular bullet |
69330 | 29 |
0x2039, // single guillemet |
30 |
0x203a, // single guillemet |
|
69331 | 31 |
0x204b, // FOOTNOTE |
69330 | 32 |
0x20ac, // Euro |
69885 | 33 |
0x2710, // pencil |
69330 | 34 |
0xfb01, // ligature fi |
35 |
0xfb02, // ligature fl |
|
36 |
0xfffd, // replacement character |
|
37 |
) |
|
38 |
||
69336 | 39 |
def isabelle_font: Seq[Int] = |
69330 | 40 |
Seq( |
41 |
0x05, // X |
|
42 |
0x06, // Y |
|
43 |
0x07, // EOF |
|
44 |
0x7f, // DEL |
|
69341
6aa24ccd8049
proper superscript "-1", based on "Deja Vu Sans Condensed" U+207b/U+00b9, with bold version via "Change Weight / Embolden by 80 em units";
wenzelm
parents:
69339
diff
changeset
|
45 |
0xaf, // INVERSE |
69330 | 46 |
0xac, // logicalnot |
47 |
0xb0, // degree |
|
48 |
0xb1, // plusminus |
|
49 |
0xb7, // periodcentered |
|
50 |
0xd7, // multiply |
|
51 |
0xf7, // divide |
|
52 |
) ++ |
|
53 |
(0x0370 to 0x03ff) ++ // Greek (pseudo math) |
|
69336 | 54 |
(0x0590 to 0x05ff) ++ // Hebrew (non-mono) |
69330 | 55 |
Seq( |
56 |
0x2010, // hyphen |
|
57 |
0x2013, // dash |
|
58 |
0x2014, // dash |
|
59 |
0x2015, // dash |
|
74433
ec1774613824
support symbol \<Parallel>, based on \bigparallel from stdmaryd (stmary10.pfb: move y=1100, scale 222%, embolden by 40 units, adjust spacing);
wenzelm
parents:
73649
diff
changeset
|
60 |
0x2016, // big parallel |
69330 | 61 |
0x2020, // dagger |
62 |
0x2021, // double dagger |
|
63 |
0x2026, // ellipsis |
|
64 |
0x2030, // perthousand |
|
65 |
0x2032, // minute |
|
66 |
0x2033, // second |
|
67 |
0x2038, // caret |
|
73446
d1c4c2395650
more Isabelle symbol definitions for Z Notation, based on https://github.com/isabelle-utp/Z_Toolkit 998c9f7880d3 by Simon Foster;
wenzelm
parents:
73444
diff
changeset
|
68 |
0x2040, // sequence concatenation |
69330 | 69 |
0x20cd, // currency symbol |
70 |
) ++ |
|
71 |
(0x2100 to 0x214f) ++ // Letterlike Symbols |
|
72 |
(0x2190 to 0x21ff) ++ // Arrows |
|
73 |
(0x2200 to 0x22ff) ++ // Mathematical Operators |
|
74 |
(0x2300 to 0x23ff) ++ // Miscellaneous Technical |
|
75 |
Seq( |
|
76 |
0x2423, // graphic for space |
|
77 |
0x2500, // box drawing |
|
78 |
0x2501, // box drawing |
|
79 |
0x2508, // box drawing |
|
80 |
0x2509, // box drawing |
|
81 |
0x2550, // box drawing |
|
82 |
) ++ |
|
83 |
(0x25a0 to 0x25ff) ++ // Geometric Shapes |
|
84 |
Seq( |
|
69331 | 85 |
0x261b, // ACTION |
69330 | 86 |
0x2660, // spade suit |
87 |
0x2661, // heart suit |
|
88 |
0x2662, // diamond suit |
|
89 |
0x2663, // club suit |
|
90 |
0x266d, // musical flat |
|
91 |
0x266e, // musical natural |
|
92 |
0x266f, // musical sharp |
|
73467
090add96f5f9
more glyphs proposed by Simon Foster: 0x002713, 0x002717, 0x002af4, 0x002afb, 0x002afd;
wenzelm
parents:
73446
diff
changeset
|
93 |
0x2713, // check mark |
090add96f5f9
more glyphs proposed by Simon Foster: 0x002713, 0x002717, 0x002af4, 0x002afb, 0x002afd;
wenzelm
parents:
73446
diff
changeset
|
94 |
0x2717, // ballot X |
69330 | 95 |
0x2756, // UNDEFINED |
96 |
0x2759, // BOLD |
|
97 |
0x27a7, // DESCR |
|
98 |
0x27e6, // left white square bracket |
|
99 |
0x27e7, // right white square bracket |
|
100 |
0x27e8, // left angle bracket |
|
101 |
0x27e9, // right angle bracket |
|
70371 | 102 |
0x27ea, // left double angle bracket |
103 |
0x27eb, // right double angle bracket |
|
69330 | 104 |
) ++ |
105 |
(0x27f0 to 0x27ff) ++ // Supplemental Arrows-A |
|
106 |
(0x2900 to 0x297f) ++ // Supplemental Arrows-B |
|
107 |
(0x2980 to 0x29ff) ++ // Miscellaneous Mathematical Symbols-B |
|
108 |
(0x2a00 to 0x2aff) ++ // Supplemental Mathematical Operators |
|
109 |
Seq(0x2b1a) ++ // VERBATIM |
|
110 |
(0x1d400 to 0x1d7ff) ++ // Mathematical Alphanumeric Symbols |
|
111 |
Seq( |
|
69331 | 112 |
0x1f310, // globe with meridians (Symbola font) |
113 |
0x1f4d3, // notebook (Symbola font) |
|
114 |
0x1f5c0, // folder (Symbola font) |
|
115 |
0x1f5cf, // page (Symbola font) |
|
69330 | 116 |
) |
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
117 |
|
69437
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
118 |
def isabelle_math_font: Seq[Int] = |
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
119 |
(0x21 to 0x2f) ++ // bang .. slash |
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
120 |
(0x3a to 0x40) ++ // colon .. atsign |
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
121 |
(0x5b to 0x5f) ++ // leftbracket .. underscore |
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
122 |
(0x7b to 0x7e) ++ // leftbrace .. tilde |
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
123 |
Seq( |
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
124 |
0xa9, // copyright |
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
125 |
0xae, // registered |
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
126 |
) |
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
127 |
|
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
128 |
val vacuous_font: Seq[Int] = |
1b64f82aaf76
more mathematical glyphs from Isabelle2009-1/lib/fonts/IsabelleMono.sfd (still unused);
wenzelm
parents:
69436
diff
changeset
|
129 |
Seq(0x3c) // "<" as template |
69330 | 130 |
} |
131 |
||
132 |
||
133 |
/* font families */ |
|
134 |
||
69332 | 135 |
sealed case class Family( |
136 |
plain: String = "", |
|
137 |
bold: String = "", |
|
138 |
italic: String = "", |
|
75393 | 139 |
bold_italic: String = "" |
140 |
) { |
|
69336 | 141 |
val fonts: List[String] = |
142 |
proper_string(plain).toList ::: |
|
143 |
proper_string(bold).toList ::: |
|
144 |
proper_string(italic).toList ::: |
|
145 |
proper_string(bold_italic).toList |
|
146 |
||
147 |
def get(index: Int): String = fonts(index % fonts.length) |
|
148 |
} |
|
69330 | 149 |
|
75393 | 150 |
object Family { |
69436 | 151 |
def isabelle_symbols: Family = |
69336 | 152 |
Family( |
69436 | 153 |
plain = "IsabelleSymbols.sfd", |
154 |
bold = "IsabelleSymbolsBold.sfd") |
|
69336 | 155 |
|
69332 | 156 |
def deja_vu_sans_mono: Family = |
69330 | 157 |
Family( |
69332 | 158 |
plain = "DejaVuSansMono.ttf", |
159 |
bold = "DejaVuSansMono-Bold.ttf", |
|
160 |
italic = "DejaVuSansMono-Oblique.ttf", |
|
69336 | 161 |
bold_italic = "DejaVuSansMono-BoldOblique.ttf") |
69330 | 162 |
|
69332 | 163 |
def deja_vu_sans: Family = |
69330 | 164 |
Family( |
69332 | 165 |
plain = "DejaVuSans.ttf", |
166 |
bold = "DejaVuSans-Bold.ttf", |
|
167 |
italic = "DejaVuSans-Oblique.ttf", |
|
168 |
bold_italic = "DejaVuSans-BoldOblique.ttf") |
|
69330 | 169 |
|
69332 | 170 |
def deja_vu_serif: Family = |
69330 | 171 |
Family( |
69332 | 172 |
plain = "DejaVuSerif.ttf", |
173 |
bold = "DejaVuSerif-Bold.ttf", |
|
174 |
italic = "DejaVuSerif-Italic.ttf", |
|
175 |
bold_italic = "DejaVuSerif-BoldItalic.ttf") |
|
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
176 |
|
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
177 |
def vacuous: Family = Family(plain = "Vacuous.sfd") |
69330 | 178 |
} |
69336 | 179 |
|
180 |
||
70072 | 181 |
/* hinting */ |
182 |
||
69795
4791988fcbc4
auto-hinting of original DejaVu fonts, but not Isabelle symbols;
wenzelm
parents:
69437
diff
changeset
|
183 |
// see https://www.freetype.org/ttfautohint/doc/ttfautohint.html |
75393 | 184 |
private def auto_hint(source: Path, target: Path): Unit = { |
69795
4791988fcbc4
auto-hinting of original DejaVu fonts, but not Isabelle symbols;
wenzelm
parents:
69437
diff
changeset
|
185 |
Isabelle_System.bash("ttfautohint -i " + |
4791988fcbc4
auto-hinting of original DejaVu fonts, but not Isabelle symbols;
wenzelm
parents:
69437
diff
changeset
|
186 |
File.bash_path(source) + " " + File.bash_path(target)).check |
4791988fcbc4
auto-hinting of original DejaVu fonts, but not Isabelle symbols;
wenzelm
parents:
69437
diff
changeset
|
187 |
} |
4791988fcbc4
auto-hinting of original DejaVu fonts, but not Isabelle symbols;
wenzelm
parents:
69437
diff
changeset
|
188 |
|
76531 | 189 |
private def make_path(hinted: Boolean = false): Path = |
70072 | 190 |
if (hinted) Path.basic("ttf-hinted") else Path.basic("ttf") |
191 |
||
192 |
private val hinting = List(false, true) |
|
69795
4791988fcbc4
auto-hinting of original DejaVu fonts, but not Isabelle symbols;
wenzelm
parents:
69437
diff
changeset
|
193 |
|
4791988fcbc4
auto-hinting of original DejaVu fonts, but not Isabelle symbols;
wenzelm
parents:
69437
diff
changeset
|
194 |
|
69336 | 195 |
/* build fonts */ |
196 |
||
75393 | 197 |
private def find_file(dirs: List[Path], name: String): Path = { |
69336 | 198 |
val path = Path.explode(name) |
199 |
dirs.collectFirst({ case dir if (dir + path).is_file => dir + path }) match { |
|
200 |
case Some(file) => file |
|
201 |
case None => |
|
202 |
error(cat_lines( |
|
203 |
("Failed to find font file " + path + " in directories:") :: |
|
204 |
dirs.map(dir => " " + dir.toString))) |
|
205 |
} |
|
206 |
} |
|
207 |
||
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
208 |
val default_download_url = |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
209 |
"https://github.com/dejavu-fonts/dejavu-fonts/releases/download/version_2_37/dejavu-fonts-ttf-2.37.zip" |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
210 |
|
69336 | 211 |
val default_sources: List[Family] = |
212 |
List(Family.deja_vu_sans_mono, Family.deja_vu_sans, Family.deja_vu_serif) |
|
213 |
||
214 |
def build_fonts( |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
215 |
download_url: String = default_download_url, |
76531 | 216 |
target_dir: Path = Path.current, |
217 |
target_prefix: String = "Isabelle", |
|
69336 | 218 |
sources: List[Family] = default_sources, |
75393 | 219 |
progress: Progress = new Progress |
220 |
): Unit = { |
|
73444 | 221 |
Isabelle_System.require_command("ttfautohint") |
222 |
||
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
223 |
Isabelle_System.with_tmp_file("download", ext = "zip") { download_file => |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
224 |
Isabelle_System.with_tmp_dir("download") { download_dir => |
76531 | 225 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
226 |
|
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
227 |
/* download */ |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
228 |
|
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
229 |
Isabelle_System.download_file(download_url, download_file, progress = progress) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
230 |
Isabelle_System.extract(download_file, download_dir) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
231 |
|
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
232 |
val dejavu_dir = File.get_dir(download_dir, title = download_url) + Path.basic("ttf") |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
233 |
|
76531 | 234 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
235 |
/* component */ |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
236 |
|
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
237 |
val component_date = Date.Format.alt_date(Date.now()) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
238 |
val component_name = "isabelle_fonts-" + component_date |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
239 |
val component_dir = |
76547 | 240 |
Components.Directory(target_dir + Path.basic(component_name)).create(progress = progress) |
76531 | 241 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
242 |
for (hinted <- hinting) { |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
243 |
Isabelle_System.make_directory(component_dir.path + make_path(hinted = hinted)) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
244 |
} |
69336 | 245 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
246 |
val font_dirs = List(dejavu_dir, Path.explode("~~/Admin/isabelle_fonts")) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
247 |
for (dir <- font_dirs if !dir.is_dir) error("Bad source directory: " + dir) |
69336 | 248 |
|
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
249 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
250 |
// Isabelle fonts |
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
251 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
252 |
val fonts = |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
253 |
for { source <- sources; (source_font, index) <- source.fonts.zipWithIndex } |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
254 |
yield { |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
255 |
val isabelle_file = find_file(font_dirs, Family.isabelle_symbols.get(index)) |
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
256 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
257 |
val source_file = find_file(font_dirs, source_font) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
258 |
val source_names = Fontforge.font_names(source_file) |
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
259 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
260 |
val font_names = source_names.update(prefix = target_prefix, version = component_date) |
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
261 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
262 |
Isabelle_System.with_tmp_file("font", "ttf") { tmp_file => |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
263 |
for (hinted <- hinting) { |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
264 |
val font_file = component_dir.path + make_path(hinted = hinted) + font_names.ttf |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
265 |
progress.echo("Font " + font_file + " ...") |
69795
4791988fcbc4
auto-hinting of original DejaVu fonts, but not Isabelle symbols;
wenzelm
parents:
69437
diff
changeset
|
266 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
267 |
if (hinted) auto_hint(source_file, tmp_file) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
268 |
else Isabelle_System.copy_file(source_file, tmp_file) |
69336 | 269 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
270 |
Fontforge.execute( |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
271 |
Fontforge.commands( |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
272 |
Fontforge.open(isabelle_file), |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
273 |
Fontforge.select(Range.isabelle_font), |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
274 |
Fontforge.copy, |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
275 |
Fontforge.close, |
69336 | 276 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
277 |
Fontforge.open(tmp_file), |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
278 |
Fontforge.select(Range.base_font), |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
279 |
Fontforge.select_invert, |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
280 |
Fontforge.clear, |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
281 |
Fontforge.select(Range.isabelle_font), |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
282 |
Fontforge.paste, |
70072 | 283 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
284 |
font_names.set, |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
285 |
Fontforge.generate(font_file), |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
286 |
Fontforge.close) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
287 |
).check |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
288 |
} |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
289 |
} |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
290 |
|
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
291 |
(font_names.ttf, index) |
70072 | 292 |
} |
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
293 |
|
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
294 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
295 |
// Vacuous font |
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
296 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
297 |
{ |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
298 |
val vacuous_file = find_file(font_dirs, Family.vacuous.get(0)) |
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
299 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
300 |
val font_dir = component_dir.path + make_path() |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
301 |
val font_names = Fontforge.font_names(vacuous_file) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
302 |
val font_file = font_dir + font_names.ttf |
69336 | 303 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
304 |
progress.echo("Font " + font_file + " ...") |
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
305 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
306 |
val domain = |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
307 |
(for ((name, index) <- fonts if index == 0) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
308 |
yield Fontforge.font_domain(font_dir + name)) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
309 |
.flatten.distinct.sorted |
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
310 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
311 |
Fontforge.execute( |
69371
3539767d5c61
generate Vacuous font from domain of Isabelle fonts;
wenzelm
parents:
69354
diff
changeset
|
312 |
Fontforge.commands( |
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
313 |
Fontforge.open(vacuous_file), |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
314 |
Fontforge.select(Range.vacuous_font), |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
315 |
Fontforge.copy) + |
69336 | 316 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
317 |
domain.map(code => |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
318 |
Fontforge.commands( |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
319 |
Fontforge.select(Seq(code)), |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
320 |
Fontforge.paste)) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
321 |
.mkString("\n", "\n", "\n") + |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
322 |
|
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
323 |
Fontforge.commands( |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
324 |
Fontforge.generate(font_file), |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
325 |
Fontforge.close) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
326 |
).check |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
327 |
} |
69373 | 328 |
|
329 |
||
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
330 |
/* settings */ |
70072 | 331 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
332 |
def make_settings(hinted: Boolean = false): String = |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
333 |
"\n isabelle_fonts \\\n" + |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
334 |
(for ((ttf, _) <- fonts) yield |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
335 |
""" "$COMPONENT/""" + make_path(hinted = hinted).file_name + "/" + ttf.file_name + "\"") |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
336 |
.mkString(" \\\n") |
70072 | 337 |
|
76548 | 338 |
component_dir.write_settings(""" |
70084
f9d8f78ef687
proper treatment of isabelle_fonts_hinted in etc/preferences (i.e. a change of the default option);
wenzelm
parents:
70072
diff
changeset
|
339 |
if grep "isabelle_fonts_hinted.*=.*false" "$ISABELLE_HOME_USER/etc/preferences" >/dev/null 2>/dev/null |
76531 | 340 |
then""" + make_settings() + """ |
341 |
else""" + make_settings(hinted = true) + """ |
|
70072 | 342 |
fi |
343 |
||
76531 | 344 |
isabelle_fonts_hidden "$COMPONENT/""" + make_path().file_name + """/Vacuous.ttf" |
69373 | 345 |
""") |
346 |
||
347 |
||
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
348 |
/* README */ |
76531 | 349 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
350 |
Isabelle_System.copy_file( |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
351 |
Path.explode("~~/Admin/isabelle_fonts/README"), component_dir.README) |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
352 |
} |
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
353 |
} |
69336 | 354 |
} |
69337 | 355 |
|
356 |
||
357 |
/* Isabelle tool wrapper */ |
|
358 |
||
359 |
val isabelle_tool = |
|
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
360 |
Isabelle_Tool("component_fonts", "construct Isabelle fonts", Scala_Project.here, |
75394 | 361 |
{ args => |
76531 | 362 |
var target_dir = Path.current |
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
363 |
var download_url = default_download_url |
69337 | 364 |
|
75394 | 365 |
val getopts = Getopts(""" |
77566
2a99fcb283ee
renamed administrative tools to build Isabelle components (unrelated to "isabelle build");
wenzelm
parents:
76548
diff
changeset
|
366 |
Usage: isabelle component_fonts [OPTIONS] |
69337 | 367 |
|
368 |
Options are: |
|
76531 | 369 |
-D DIR target directory (default ".") |
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
370 |
-U URL download URL (default: """" + default_download_url + """") |
69337 | 371 |
|
69343
395c4fb15ea2
use "Isabelle DejaVu" fonts uniformly: Text Area, GUI elements, HTML output etc.;
wenzelm
parents:
69341
diff
changeset
|
372 |
Construct Isabelle fonts from DejaVu font families and Isabelle symbols. |
69337 | 373 |
""", |
76531 | 374 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
375 |
"U:" -> (arg => download_url = arg)) |
69337 | 376 |
|
75394 | 377 |
val more_args = getopts(args) |
378 |
if (more_args.nonEmpty) getopts.usage() |
|
69337 | 379 |
|
75394 | 380 |
val progress = new Console_Progress |
69337 | 381 |
|
76532
c9e1276f0268
proper download, instead of assuming local directory;
wenzelm
parents:
76531
diff
changeset
|
382 |
build_fonts(download_url = download_url, target_dir = target_dir, progress = progress) |
75394 | 383 |
}) |
69330 | 384 |
} |