slightly more robust and less ambitious version of install_fonts;
authorwenzelm
Wed, 09 Dec 2009 21:25:07 +0100
changeset 34044 09afb1d49fe7
parent 34043 7129fab1fe4f
child 34045 bc71778a327d
slightly more robust and less ambitious version of install_fonts;
src/Pure/System/isabelle_system.scala
--- a/src/Pure/System/isabelle_system.scala	Wed Dec 09 16:28:49 2009 +0100
+++ b/src/Pure/System/isabelle_system.scala	Wed Dec 09 21:25:07 2009 +0100
@@ -338,14 +338,20 @@
 
   val font_family = "IsabelleText"
 
+  private def check_font(): Boolean =
+    new Font(font_family, Font.PLAIN, 1).getFamily == font_family
+
   private def create_font(name: String) =
     Font.createFont(Font.TRUETYPE_FONT, platform_file(name))
 
-  def register_fonts() {
-    val ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
-    val ok1 = ge.registerFont(create_font("~~/lib/fonts/IsabelleText.ttf"))
-    val ok2 = ge.registerFont(create_font("~~/lib/fonts/IsabelleTextBold.ttf"))
-    if (!(ok1 && ok2) && !ge.getAvailableFontFamilyNames.contains(font_family))
-      error("Font family " + font_family + " unavailable")
+  def install_fonts()
+  {
+    if (!check_font()) {
+      val ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
+      ge.registerFont(create_font("$ISABELLE_HOME/lib/fonts/IsabelleText.ttf"))
+      ge.registerFont(create_font("$ISABELLE_HOME/lib/fonts/IsabelleTextBold.ttf"))
+      if (!check_font())
+        error("Failed to install IsabelleText fonts")
+    }
   }
 }