use Isabelle fonts for all GUI look-and-feels;
authorwenzelm
Fri Nov 30 14:46:00 2018 +0100 (11 months ago)
changeset 6937781ae5893c556
parent 69376 53194e2a969d
child 69378 429426640596
use Isabelle fonts for all GUI look-and-feels;
NEWS
src/Pure/GUI/gui.scala
src/Tools/jEdit/src/isabelle_sidekick.scala
src/Tools/jEdit/src/plugin.scala
     1.1 --- a/NEWS	Fri Nov 30 14:21:28 2018 +0100
     1.2 +++ b/NEWS	Fri Nov 30 14:46:00 2018 +0100
     1.3 @@ -36,11 +36,10 @@
     1.4  
     1.5  * Fonts for the text area, gutter, GUI elements etc. use the "Isabelle
     1.6  DejaVu" collection by default, which provides uniform rendering quality
     1.7 -with the usual Isabelle symbols. For Java/Swing GUI elements this
     1.8 -requires the Metal look-and-feel: it is the default on Linux, but not
     1.9 -macOS nor Windows. Line spacing no longer needs to be adjusted:
    1.10 -properties for the old IsabelleText font had "Global Options / Text Area
    1.11 -/ Extra vertical line spacing (in pixels): -2", now it defaults to 0.
    1.12 +with the usual Isabelle symbols. Line spacing no longer needs to be
    1.13 +adjusted: properties for the old IsabelleText font had "Global Options /
    1.14 +Text Area / Extra vertical line spacing (in pixels): -2", now it
    1.15 +defaults to 0.
    1.16  
    1.17  * Improved sub-pixel font rendering (especially on Linux), thanks to
    1.18  OpenJDK 11.
     2.1 --- a/src/Pure/GUI/gui.scala	Fri Nov 30 14:21:28 2018 +0100
     2.2 +++ b/src/Pure/GUI/gui.scala	Fri Nov 30 14:46:00 2018 +0100
     2.3 @@ -11,7 +11,7 @@
     2.4  import java.awt.font.{TextAttribute, TransformAttribute, FontRenderContext, LineMetrics}
     2.5  import java.awt.geom.AffineTransform
     2.6  import javax.swing.{ImageIcon, JOptionPane, UIManager, JLayeredPane, JFrame, JWindow, JDialog,
     2.7 -  JButton, JTextField}
     2.8 +  JButton, JTextField, JLabel}
     2.9  
    2.10  import scala.swing.{ComboBox, TextArea, ScrollPane}
    2.11  import scala.swing.event.SelectionChanged
    2.12 @@ -224,6 +224,8 @@
    2.13    def font(family: String = Isabelle_Fonts.sans, size: Int = 1, bold: Boolean = false): Font =
    2.14      new Font(family, if (bold) Font.BOLD else Font.PLAIN, size)
    2.15  
    2.16 +  def label_font(): Font = (new JLabel).getFont
    2.17 +
    2.18  
    2.19    /* Isabelle fonts */
    2.20  
    2.21 @@ -244,4 +246,15 @@
    2.22      val rel_size = line_metrics(font).getHeight.toDouble / line_metrics(font1).getHeight
    2.23      "font-family: " + family + "; font-size: " + (scale * rel_size * 100).toInt + "%;"
    2.24    }
    2.25 +
    2.26 +  def use_isabelle_fonts()
    2.27 +  {
    2.28 +    val default_font = label_font()
    2.29 +    val ui = UIManager.getDefaults
    2.30 +    for (prop <- List("Label.font", "TextArea.font", "TextPane.font", "Tooltip.font", "Tree.font"))
    2.31 +    {
    2.32 +      val font = ui.get(prop) match { case font: Font => font case _ => default_font }
    2.33 +      ui.put(prop, GUI.imitate_font(font))
    2.34 +    }
    2.35 +  }
    2.36  }
     3.1 --- a/src/Tools/jEdit/src/isabelle_sidekick.scala	Fri Nov 30 14:21:28 2018 +0100
     3.2 +++ b/src/Tools/jEdit/src/isabelle_sidekick.scala	Fri Nov 30 14:46:00 2018 +0100
     3.3 @@ -32,7 +32,7 @@
     3.4  
     3.5    class Keyword_Asset(keyword: String, text: String, range: Text.Range) extends IAsset
     3.6    {
     3.7 -    private val css = GUI.imitate_font_css((new JLabel).getFont)
     3.8 +    private val css = GUI.imitate_font_css(GUI.label_font())
     3.9  
    3.10      protected var _name = text
    3.11      protected var _start = int_to_pos(range.start)
     4.1 --- a/src/Tools/jEdit/src/plugin.scala	Fri Nov 30 14:21:28 2018 +0100
     4.2 +++ b/src/Tools/jEdit/src/plugin.scala	Fri Nov 30 14:46:00 2018 +0100
     4.3 @@ -399,6 +399,8 @@
     4.4              if (buffer != null && text_area != null) init_view(buffer, text_area)
     4.5            }
     4.6  
     4.7 +          GUI.use_isabelle_fonts()
     4.8 +
     4.9            spell_checker.update(options.value)
    4.10            session.update_options(options.value)
    4.11