# HG changeset patch # User wenzelm # Date 1276011939 -7200 # Node ID 8680677265c9dac867878c4bf92b5227d6032e05 # Parent 5c6695de35baffb779353d3eb9b0ee17ff8489bf clarified font_family vs. font_family_default; install_fonts: refrain from any magic that does not really work on Mac OS, but introduces strange problems on other platforms; diff -r 5c6695de35ba -r 8680677265c9 src/Pure/System/isabelle_system.scala --- a/src/Pure/System/isabelle_system.scala Tue Jun 08 13:51:25 2010 +0200 +++ b/src/Pure/System/isabelle_system.scala Tue Jun 08 17:45:39 2010 +0200 @@ -12,6 +12,7 @@ BufferedInputStream, FileInputStream, BufferedReader, InputStreamReader, File, IOException} import java.awt.{GraphicsEnvironment, Font} +import java.awt.font.TextAttribute import scala.io.Source import scala.util.matching.Regex @@ -336,31 +337,23 @@ /* fonts */ val font_family = getenv_strict("ISABELLE_FONT_FAMILY") + val font_family_default = "IsabelleText" def get_font(size: Int = 1, bold: Boolean = false): Font = new Font(font_family, if (bold) Font.BOLD else Font.PLAIN, size) + def create_default_font(bold: Boolean = false): Font = + if (bold) + Font.createFont(Font.TRUETYPE_FONT, + platform_file("$ISABELLE_HOME/lib/fonts/IsabelleTextBold.ttf")) + else + Font.createFont(Font.TRUETYPE_FONT, + platform_file("$ISABELLE_HOME/lib/fonts/IsabelleText.ttf")) + def install_fonts() { - def create_font(bold: Boolean): Font = - { - val name = - if (bold) "$ISABELLE_HOME/lib/fonts/IsabelleTextBold.ttf" - else "$ISABELLE_HOME/lib/fonts/IsabelleText.ttf" - Font.createFont(Font.TRUETYPE_FONT, platform_file(name)) - } - def check_font() = get_font().getFamily == font_family - - if (!check_font()) { - val font = create_font(false) - val bold_font = create_font(true) - - val ge = GraphicsEnvironment.getLocalGraphicsEnvironment() - ge.registerFont(font) - // workaround strange problem with Apple's Java 1.6 font manager - // FIXME does not quite work!? - if (bold_font.getFamily == font_family) ge.registerFont(bold_font) - if (!check_font()) error("Failed to install IsabelleText fonts") - } + val ge = GraphicsEnvironment.getLocalGraphicsEnvironment() + ge.registerFont(create_default_font(bold = false)) + ge.registerFont(create_default_font(bold = true)) } }