9 |
9 |
10 |
10 |
11 import java.awt.{Font, GraphicsEnvironment} |
11 import java.awt.{Font, GraphicsEnvironment} |
12 |
12 |
13 |
13 |
14 object Isabelle_Fonts |
14 object Isabelle_Fonts { |
15 { |
|
16 /* standard names */ |
15 /* standard names */ |
17 |
16 |
18 val mono: String = "Isabelle DejaVu Sans Mono" |
17 val mono: String = "Isabelle DejaVu Sans Mono" |
19 val sans: String = "Isabelle DejaVu Sans" |
18 val sans: String = "Isabelle DejaVu Sans" |
20 val serif: String = "Isabelle DejaVu Serif" |
19 val serif: String = "Isabelle DejaVu Serif" |
21 |
20 |
22 |
21 |
23 /* environment entries */ |
22 /* environment entries */ |
24 |
23 |
25 object Entry |
24 object Entry { |
26 { |
25 object Ordering extends scala.math.Ordering[Entry] { |
27 object Ordering extends scala.math.Ordering[Entry] |
|
28 { |
|
29 def compare(entry1: Entry, entry2: Entry): Int = |
26 def compare(entry1: Entry, entry2: Entry): Int = |
30 entry1.family compare entry2.family match { |
27 entry1.family compare entry2.family match { |
31 case 0 => entry1.style compare entry2.style |
28 case 0 => entry1.style compare entry2.style |
32 case ord => ord |
29 case ord => ord |
33 } |
30 } |
34 } |
31 } |
35 } |
32 } |
36 |
33 |
37 sealed case class Entry(path: Path, hidden: Boolean = false) |
34 sealed case class Entry(path: Path, hidden: Boolean = false) { |
38 { |
|
39 lazy val bytes: Bytes = Bytes.read(path) |
35 lazy val bytes: Bytes = Bytes.read(path) |
40 lazy val font: Font = Font.createFont(Font.TRUETYPE_FONT, path.file) |
36 lazy val font: Font = Font.createFont(Font.TRUETYPE_FONT, path.file) |
41 |
37 |
42 def family: String = font.getFamily |
38 def family: String = font.getFamily |
43 def name: String = font.getFontName |
39 def name: String = font.getFontName |
54 name_lowercase.containsSlice("oblique") |
50 name_lowercase.containsSlice("oblique") |
55 } |
51 } |
56 |
52 |
57 def make_entries( |
53 def make_entries( |
58 getenv: String => String = Isabelle_System.getenv_strict(_), |
54 getenv: String => String = Isabelle_System.getenv_strict(_), |
59 hidden: Boolean = false): List[Entry] = |
55 hidden: Boolean = false |
60 { |
56 ): List[Entry] = { |
61 Path.split(getenv("ISABELLE_FONTS")).map(Entry(_)) ::: |
57 Path.split(getenv("ISABELLE_FONTS")).map(Entry(_)) ::: |
62 (if (hidden) Path.split(getenv("ISABELLE_FONTS_HIDDEN")).map(Entry(_, hidden = true)) else Nil) |
58 (if (hidden) Path.split(getenv("ISABELLE_FONTS_HIDDEN")).map(Entry(_, hidden = true)) else Nil) |
63 } |
59 } |
64 |
60 |
65 private lazy val all_fonts: List[Entry] = |
61 private lazy val all_fonts: List[Entry] = |