add default fonts

This commit is contained in:
Branislav Stojkovic
2019-01-09 10:55:07 +01:00
parent beb6c4857d
commit a574eac4e6
4 changed files with 24 additions and 2 deletions
@@ -53,7 +53,7 @@ public class Project implements Serializable {
public static Size DEFAULT_WIDTH = new Size(29d, SizeUnit.cm);
public static Size DEFAULT_HEIGHT = new Size(21d, SizeUnit.cm);
public static Size DEFAULT_GRID_SPACING = new Size(0.1d, SizeUnit.in);
public static Font DEFAULT_FONT = new Font("Tahoma", Font.PLAIN, 14);
public static Font DEFAULT_FONT = new Font("Square721 BT", Font.PLAIN, 14);
private VersionNumber fileVersion;
Binary file not shown.
Binary file not shown.
@@ -18,11 +18,15 @@
package org.diylc;
import java.awt.AlphaComposite;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.SplashScreen;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
@@ -118,8 +122,26 @@ public class DIYLCStarter {
Thread fontThread = new Thread(new Runnable() {
@Override
public void run() {
public void run() {
LOG.debug("Starting font pre-loading");
File dir = new File("fonts");
File[] fonts = dir.listFiles();
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();
JPanel p = new JPanel();