diff --git a/build.xml b/build.xml index 6a13313..ddc19b6 100644 --- a/build.xml +++ b/build.xml @@ -287,11 +287,9 @@ - diff --git a/source/options.txt b/source/options.txt index 45c674d..bf799d1 100644 --- a/source/options.txt +++ b/source/options.txt @@ -43,6 +43,11 @@ thdl.Jskad.working.directory = # faster. thdl.rely.on.system.tmw.fonts = false +# Should the TibetanMachine fonts not be loaded from within the JAR? Set +# this to true if you can get away with it and want your THDL tools to load +# faster. Note that TibetanMachine is not the default font for Jskad. +thdl.rely.on.system.tm.fonts = false + # Sets the Tibetan keyboard that Jskad uses on startup. # Here are the acceptable values: # diff --git a/source/org/thdl/tib/input/ConverterGUI.java b/source/org/thdl/tib/input/ConverterGUI.java index 73d8a02..39dea92 100644 --- a/source/org/thdl/tib/input/ConverterGUI.java +++ b/source/org/thdl/tib/input/ConverterGUI.java @@ -37,7 +37,7 @@ public class ConverterGUI implements FontConversion, FontConverterConstants { public static void main(String[] args) { // No need for the TM or TMW fonts. System.setProperty("thdl.rely.on.system.tmw.fonts", "true"); - System.setProperty("thdl.do.not.rely.on.system.tm.fonts", "false"); + System.setProperty("thdl.rely.on.system.tm.fonts", "true"); System.exit(realMain(args, System.out, null)); } diff --git a/source/org/thdl/tib/input/TibetanConverter.java b/source/org/thdl/tib/input/TibetanConverter.java index 622bb14..147badd 100644 --- a/source/org/thdl/tib/input/TibetanConverter.java +++ b/source/org/thdl/tib/input/TibetanConverter.java @@ -47,7 +47,7 @@ public class TibetanConverter implements FontConverterConstants { static { // No need for the TM or TMW fonts. System.setProperty("thdl.rely.on.system.tmw.fonts", "true"); - System.setProperty("thdl.do.not.rely.on.system.tm.fonts", "false"); + System.setProperty("thdl.rely.on.system.tm.fonts", "true"); } /** diff --git a/source/org/thdl/tib/text/TibetanMachineWeb.java b/source/org/thdl/tib/text/TibetanMachineWeb.java index 7e6ecf2..0914265 100644 --- a/source/org/thdl/tib/text/TibetanMachineWeb.java +++ b/source/org/thdl/tib/text/TibetanMachineWeb.java @@ -41,7 +41,7 @@ import org.thdl.tib.text.tshegbar.UnicodeCodepointToThdlWylie; * both or neither. * *

In addition, this class optionally loads the TibetanMachineWeb -* fonts manually via {@link #readInFontFiles()}. +* fonts manually via {@link #readInTMWFontFiles()}. * @author Edward Garrett, Tibetan and Himalayan Digital Library * @version 1.0 */ @@ -195,40 +195,46 @@ public class TibetanMachineWeb implements THDLWylieConstants { setKeyboard(keyboard); } - /** Assumes that the TMW font files are resources associated with - * this class and loads those font files. - * @throws Error if that assumption does not hold */ - private static void readInFontFiles() { + /** If the TMW font files are resources associated with this + * class, those font files are loaded. This means that the user + * need not install the fonts on their system, but it does make + * the JAR bigger and takes time at startup. + * @return true upon successful loading, false otherwise */ + private static boolean readInTMWFontFiles() { /* Note the leading slashes on these paths: */ - readInFontFile("/Fonts/TibetanMachineWeb/timwn.ttf"); - readInFontFile("/Fonts/TibetanMachineWeb/timwn1.ttf"); - readInFontFile("/Fonts/TibetanMachineWeb/timwn2.ttf"); - readInFontFile("/Fonts/TibetanMachineWeb/timwn3.ttf"); - readInFontFile("/Fonts/TibetanMachineWeb/timwn4.ttf"); - readInFontFile("/Fonts/TibetanMachineWeb/timwn5.ttf"); - readInFontFile("/Fonts/TibetanMachineWeb/timwn6.ttf"); - readInFontFile("/Fonts/TibetanMachineWeb/timwn7.ttf"); - readInFontFile("/Fonts/TibetanMachineWeb/timwn8.ttf"); - readInFontFile("/Fonts/TibetanMachineWeb/timwn9.ttf"); + if (!readInFontFile("/Fonts/TibetanMachineWeb/timwn.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachineWeb/timwn1.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachineWeb/timwn2.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachineWeb/timwn3.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachineWeb/timwn4.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachineWeb/timwn5.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachineWeb/timwn6.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachineWeb/timwn7.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachineWeb/timwn8.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachineWeb/timwn9.ttf")) return false; + return true; } - /** Assumes that the TM font files are resources associated with - * this class and loads those font files. - * @throws Error if that assumption does not hold */ - private static void readInTMFontFiles() { + /** If the TM font files are resources associated with this + * class, those font files are loaded. This means that the user + * need not install the fonts on their system, but it does make + * the JAR bigger and takes time at startup. + * @return true upon successful loading, false otherwise */ + private static boolean readInTMFontFiles() { /* Note the leading slashes on these paths: */ - readInFontFile("/Fonts/TibetanMachine/Timn.ttf"); - readInFontFile("/Fonts/TibetanMachine/Tims1.ttf"); - readInFontFile("/Fonts/TibetanMachine/Tims2.ttf"); - readInFontFile("/Fonts/TibetanMachine/Tims3.ttf"); - readInFontFile("/Fonts/TibetanMachine/Tims4.ttf"); + if (!readInFontFile("/Fonts/TibetanMachine/Timn.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachine/Tims1.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachine/Tims2.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachine/Tims3.ttf")) return false; + if (!readInFontFile("/Fonts/TibetanMachine/Tims4.ttf")) return false; + return true; } - /** Assumes that the TMW font file at the given path is a resource - * associated with this class and loads that font file. + /** If the TMW font file at the given path is a resource + * associated with this class, that font file is loaded. * @param path a path within the JAR containing this class file - * @throws Error if that assumption does not hold */ - private static void readInFontFile(String path) { + * @return true upon successful loading, false otherwise */ + private static boolean readInFontFile(String path) { // Note that the TM and TMW fonts do not have hanging // baselines. They have Roman baselines. Tony Duff said this @@ -238,14 +244,15 @@ public class TibetanMachineWeb implements THDLWylieConstants { try { InputStream is = TibetanMachineWeb.class.getResourceAsStream(path); if (null == is) { - throw new Error("You selected the optional behavior of loading the TibetanMachineWeb font family manually, but the resource " - + path + " could not be found."); + return false; } Font.createFont(Font.TRUETYPE_FONT, is); } catch( Exception e ) { e.printStackTrace(); ThdlDebug.noteIffyCode(); + return false; } + return true; } /** Returns the next token in st with the first occurrence of @@ -272,14 +279,9 @@ public class TibetanMachineWeb implements THDLWylieConstants { */ private static void readData() { if (!ThdlOptions.getBooleanOption("thdl.rely.on.system.tmw.fonts")) { - readInFontFiles(); + readInTMWFontFiles(); } - - // DLC FIXME: include TM fonts with Jskad but not with other - // packages. Right now you can get them manually by editing - // build.xml and your options.txt or my_thdl_preferences.txt - // file. - if (ThdlOptions.getBooleanOption("thdl.do.not.rely.on.system.tm.fonts")) { + if (!ThdlOptions.getBooleanOption("thdl.rely.on.system.tm.fonts")) { readInTMFontFiles(); }