9 import java.lang.{ClassLoader, ClassNotFoundException, NoSuchMethodException} |
9 import java.lang.{ClassLoader, ClassNotFoundException, NoSuchMethodException} |
10 import java.awt.{Image, Component, Container, Toolkit, Window, Font, KeyboardFocusManager} |
10 import java.awt.{Image, Component, Container, Toolkit, Window, Font, KeyboardFocusManager} |
11 import java.awt.font.{TextAttribute, TransformAttribute, FontRenderContext, LineMetrics} |
11 import java.awt.font.{TextAttribute, TransformAttribute, FontRenderContext, LineMetrics} |
12 import java.awt.geom.AffineTransform |
12 import java.awt.geom.AffineTransform |
13 import javax.swing.{ImageIcon, JOptionPane, UIManager, JLayeredPane, JFrame, JWindow, JDialog, |
13 import javax.swing.{ImageIcon, JOptionPane, UIManager, JLayeredPane, JFrame, JWindow, JDialog, |
14 JButton, JTextField} |
14 JButton, JTextField, JLabel} |
15 |
15 |
16 import scala.swing.{ComboBox, TextArea, ScrollPane} |
16 import scala.swing.{ComboBox, TextArea, ScrollPane} |
17 import scala.swing.event.SelectionChanged |
17 import scala.swing.event.SelectionChanged |
18 |
18 |
19 |
19 |
222 } |
222 } |
223 |
223 |
224 def font(family: String = Isabelle_Fonts.sans, size: Int = 1, bold: Boolean = false): Font = |
224 def font(family: String = Isabelle_Fonts.sans, size: Int = 1, bold: Boolean = false): Font = |
225 new Font(family, if (bold) Font.BOLD else Font.PLAIN, size) |
225 new Font(family, if (bold) Font.BOLD else Font.PLAIN, size) |
226 |
226 |
|
227 def label_font(): Font = (new JLabel).getFont |
|
228 |
227 |
229 |
228 /* Isabelle fonts */ |
230 /* Isabelle fonts */ |
229 |
231 |
230 def imitate_font(font: Font, |
232 def imitate_font(font: Font, |
231 family: String = Isabelle_Fonts.sans, |
233 family: String = Isabelle_Fonts.sans, |
242 { |
244 { |
243 val font1 = new Font(family, font.getStyle, font.getSize) |
245 val font1 = new Font(family, font.getStyle, font.getSize) |
244 val rel_size = line_metrics(font).getHeight.toDouble / line_metrics(font1).getHeight |
246 val rel_size = line_metrics(font).getHeight.toDouble / line_metrics(font1).getHeight |
245 "font-family: " + family + "; font-size: " + (scale * rel_size * 100).toInt + "%;" |
247 "font-family: " + family + "; font-size: " + (scale * rel_size * 100).toInt + "%;" |
246 } |
248 } |
|
249 |
|
250 def use_isabelle_fonts() |
|
251 { |
|
252 val default_font = label_font() |
|
253 val ui = UIManager.getDefaults |
|
254 for (prop <- List("Label.font", "TextArea.font", "TextPane.font", "Tooltip.font", "Tree.font")) |
|
255 { |
|
256 val font = ui.get(prop) match { case font: Font => font case _ => default_font } |
|
257 ui.put(prop, GUI.imitate_font(font)) |
|
258 } |
|
259 } |
247 } |
260 } |