src/Pure/System/isabelle_font.scala
author wenzelm
Mon Jul 15 10:25:35 2013 +0200 (2013-07-15 ago)
changeset 52655 3b2b1ef13979
parent 51614 22d1dd43f089
child 55618 995162143ef4
permissions -rw-r--r--
more careful termination of removed execs, leaving running execs undisturbed;
     1 /*  Title:      Pure/System/isabelle_font.scala
     2     Author:     Makarius
     3 
     4 Isabelle font support.
     5 */
     6 
     7 package isabelle
     8 
     9 import java.awt.{GraphicsEnvironment, Font}
    10 import java.io.{FileInputStream, BufferedInputStream}
    11 import javafx.scene.text.{Font => JFX_Font}
    12 
    13 
    14 object Isabelle_Font
    15 {
    16   def apply(family: String = "IsabelleText", size: Int = 1, bold: Boolean = false): Font =
    17     new Font(family, if (bold) Font.BOLD else Font.PLAIN, size)
    18 
    19   def install_fonts()
    20   {
    21     val ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
    22     for (font <- Path.split(Isabelle_System.getenv_strict("ISABELLE_FONTS")))
    23       ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, font.file))
    24   }
    25 
    26   def install_fonts_jfx()
    27   {
    28     for (font <- Path.split(Isabelle_System.getenv_strict("ISABELLE_FONTS"))) {
    29       val stream = new BufferedInputStream(new FileInputStream(font.file))
    30       try { JFX_Font.loadFont(stream, 1.0) }
    31       finally { stream.close }
    32     }
    33   }
    34 }
    35