mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Include themes and fonts in OSX app package. Standardize loading
resource files
This commit is contained in:
@@ -38,6 +38,7 @@ import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.gui.MainFrame;
|
||||
import org.diylc.swing.gui.TemplateDialog;
|
||||
import org.diylc.swingframework.FontChooserComboBox;
|
||||
import org.diylc.utils.ResourceLoader;
|
||||
|
||||
/**
|
||||
* Main class that runs DIYLC.
|
||||
@@ -97,23 +98,23 @@ public class DIYLCStarter {
|
||||
@Override
|
||||
public void run() {
|
||||
LOG.debug("Starting font pre-loading");
|
||||
|
||||
File dir = new File("fonts");
|
||||
File[] fonts = dir.listFiles();
|
||||
|
||||
File[] fonts = ResourceLoader.getFiles("fonts");
|
||||
|
||||
for (int i = 0; i < fonts.length; i++) {
|
||||
try {
|
||||
LOG.info("Dynamically loading font: " + fonts[i].getName());
|
||||
Font customFont = Font.createFont(Font.TRUETYPE_FONT, new File(fonts[i].getAbsolutePath())).deriveFont(12f);
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
// register the font
|
||||
ge.registerFont(customFont);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Could not load font", e);
|
||||
} catch (FontFormatException e) {
|
||||
LOG.error("Font format error", e);
|
||||
if (fonts != null)
|
||||
for (int i = 0; i < fonts.length; i++) {
|
||||
try {
|
||||
LOG.info("Dynamically loading font: " + fonts[i].getName());
|
||||
Font customFont = Font.createFont(Font.TRUETYPE_FONT, new File(fonts[i].getAbsolutePath())).deriveFont(12f);
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
// register the font
|
||||
ge.registerFont(customFont);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Could not load font", e);
|
||||
} catch (FontFormatException e) {
|
||||
LOG.error("Font format error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FontChooserComboBox box = new FontChooserComboBox();
|
||||
box.getPreferredSize();
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.diylc.core.Theme;
|
||||
import org.diylc.images.IconLoader;
|
||||
import org.diylc.swing.ActionFactory;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.utils.ResourceLoader;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
@@ -133,11 +134,11 @@ public class ConfigPlugin implements IPlugIn {
|
||||
ActionFactory.getInstance()
|
||||
.createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
|
||||
|
||||
File themeDir = new File("themes");
|
||||
if (themeDir.exists()) {
|
||||
File[] themeFiles = ResourceLoader.getFiles("themes");
|
||||
if (themeFiles != null && themeFiles.length > 0) {
|
||||
XStream xStream = new XStream(new DomDriver());
|
||||
swingUI.injectSubmenu(THEME_MENU, IconLoader.Pens.getIcon(), CONFIG_MENU);
|
||||
for (File file : themeDir.listFiles()) {
|
||||
for (File file : themeFiles) {
|
||||
if (file.getName().toLowerCase().endsWith(".xml")) {
|
||||
try {
|
||||
InputStream in = new FileInputStream(file);
|
||||
|
||||
Reference in New Issue
Block a user