src/Pure/System/isabelle_font.scala
changeset 51614 22d1dd43f089
child 55618 995162143ef4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/System/isabelle_font.scala	Thu Apr 04 17:33:04 2013 +0200
@@ -0,0 +1,35 @@
+/*  Title:      Pure/System/isabelle_font.scala
+    Author:     Makarius
+
+Isabelle font support.
+*/
+
+package isabelle
+
+import java.awt.{GraphicsEnvironment, Font}
+import java.io.{FileInputStream, BufferedInputStream}
+import javafx.scene.text.{Font => JFX_Font}
+
+
+object Isabelle_Font
+{
+  def apply(family: String = "IsabelleText", size: Int = 1, bold: Boolean = false): Font =
+    new Font(family, if (bold) Font.BOLD else Font.PLAIN, size)
+
+  def install_fonts()
+  {
+    val ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
+    for (font <- Path.split(Isabelle_System.getenv_strict("ISABELLE_FONTS")))
+      ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, font.file))
+  }
+
+  def install_fonts_jfx()
+  {
+    for (font <- Path.split(Isabelle_System.getenv_strict("ISABELLE_FONTS"))) {
+      val stream = new BufferedInputStream(new FileInputStream(font.file))
+      try { JFX_Font.loadFont(stream, 1.0) }
+      finally { stream.close }
+    }
+  }
+}
+