diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.form b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.form index d6bfb1549..e86595324 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.form +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.form @@ -57,6 +57,21 @@ + + + + + + + + + + + + + + + diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.java b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.java index 312d52c6d..b87bccad3 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.java +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontVisualPanel2.java @@ -4,6 +4,7 @@ */ package com.jme3.gde.angelfont; +import java.awt.Font; import javax.swing.ImageIcon; import javax.swing.JPanel; @@ -12,10 +13,15 @@ public final class AngelFontVisualPanel2 extends JPanel { String fontName = ""; int fontSize = 16; int imageSize = 256; + int style = Font.PLAIN; /** Creates new form AngelFontVisualPanel2 */ public AngelFontVisualPanel2() { initComponents(); + jComboBox1.removeAllItems(); + jComboBox1.addItem("PLAIN"); + jComboBox1.addItem("ITALIC"); + jComboBox1.addItem("BOLD"); } @Override @@ -29,7 +35,7 @@ public final class AngelFontVisualPanel2 extends JPanel { } private void updateFont() { - jLabel3.setIcon(new ImageIcon(FontCreator.buildFont(fontName, imageSize, fontSize, true).getImage())); + jLabel3.setIcon(new ImageIcon(FontCreator.buildFont(fontName, imageSize, fontSize, style, true).getImage())); jLabel3.repaint(); jPanel1.repaint(); } @@ -45,6 +51,7 @@ public final class AngelFontVisualPanel2 extends JPanel { jPanel1 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); jToolBar1 = new javax.swing.JToolBar(); + jComboBox1 = new javax.swing.JComboBox(); jLabel1 = new javax.swing.JLabel(); jSpinner1 = new javax.swing.JSpinner(); jLabel2 = new javax.swing.JLabel(); @@ -59,6 +66,14 @@ public final class AngelFontVisualPanel2 extends JPanel { jToolBar1.setFloatable(false); jToolBar1.setRollover(true); + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + jComboBox1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jComboBox1ActionPerformed(evt); + } + }); + jToolBar1.add(jComboBox1); + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(AngelFontVisualPanel2.class, "AngelFontVisualPanel2.jLabel1.text")); // NOI18N jToolBar1.add(jLabel1); @@ -106,7 +121,19 @@ public final class AngelFontVisualPanel2 extends JPanel { imageSize = (Integer) jSpinner2.getValue(); updateFont(); }//GEN-LAST:event_updateImageSize + + private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed + if ("PLAIN".equals(jComboBox1.getSelectedItem())) { + style = Font.PLAIN; + } else if ("BOLD".equals(jComboBox1.getSelectedItem())) { + style = Font.BOLD; + } else if ("ITALIC".equals(jComboBox1.getSelectedItem())) { + style = Font.ITALIC; + } + updateFont(); + }//GEN-LAST:event_jComboBox1ActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox jComboBox1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardIterator.java b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardIterator.java index 85cee53da..918609787 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardIterator.java +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardIterator.java @@ -12,8 +12,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.nio.ByteBuffer; import java.util.Collections; -import java.util.Iterator; -import java.util.Map.Entry; +import java.util.HashSet; import java.util.NoSuchElementException; import java.util.Set; import java.util.logging.Level; @@ -75,13 +74,14 @@ public final class AngelFontWizardIterator implements WizardDescriptor.Instantia String name = (String) wizard.getProperty("font_name"); int fontSize = (Integer) wizard.getProperty("font_size"); int imageSize = (Integer) wizard.getProperty("image_size"); + int style = (Integer) wizard.getProperty("font_style"); Project project = (Project) wizard.getProperty("project"); ProjectAssetManager pm = project.getLookup().lookup(ProjectAssetManager.class); if (pm == null) { Logger.getLogger(AngelFontWizardIterator.class.getName()).log(Level.WARNING, "No ProjectAssetManager found!"); return Collections.EMPTY_SET; } - AngelFont font = FontCreator.buildFont(name, imageSize, fontSize); + AngelFont font = FontCreator.buildFont(name, imageSize, fontSize, style); BufferedImage fontImage = font.getImage(); ByteBuffer scratch = ByteBuffer.allocateDirect(4 * fontImage.getWidth() * fontImage.getHeight()); byte[] data = (byte[]) fontImage.getRaster().getDataElements(0, 0, @@ -91,6 +91,7 @@ public final class AngelFontWizardIterator implements WizardDescriptor.Instantia scratch.rewind(); name = name.replaceAll(" ", ""); File outputFile; + FileObject object; try { if (pm.getAssetFolder().getFileObject("Interface") == null) { pm.getAssetFolder().createFolder("Interface"); @@ -105,7 +106,7 @@ public final class AngelFontWizardIterator implements WizardDescriptor.Instantia // write png file ImageIO.write(fontImage, "PNG", outputFile); - FileObject object = pm.getAssetFolder().getFileObject("Interface/Fonts/" + name, "fnt"); + object = pm.getAssetFolder().getFileObject("Interface/Fonts/" + name, "fnt"); if (object == null) { object = pm.getAssetFolder().getFileObject("Interface/Fonts").createData(name, "fnt"); } @@ -116,7 +117,10 @@ public final class AngelFontWizardIterator implements WizardDescriptor.Instantia Exceptions.printStackTrace(e); return Collections.EMPTY_SET; } - return Collections.singleton(FileUtil.toFileObject(outputFile)); + Set set = new HashSet(); + set.add(FileUtil.toFileObject(outputFile)); + set.add(object); + return set; } public void initialize(WizardDescriptor wizard) { diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardPanel2.java b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardPanel2.java index 9c80245b0..a9e9df2e8 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardPanel2.java +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/AngelFontWizardPanel2.java @@ -83,6 +83,7 @@ public class AngelFontWizardPanel2 implements WizardDescriptor.Panel { } public void storeSettings(Object settings) { + ((WizardDescriptor)settings).putProperty("font_style", component.style); ((WizardDescriptor)settings).putProperty("font_size", component.fontSize); ((WizardDescriptor)settings).putProperty("image_size", component.imageSize); } diff --git a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/FontCreator.java b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/FontCreator.java index 25dbf5be7..a743d17ad 100644 --- a/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/FontCreator.java +++ b/sdk/jme3-angelfont/src/com/jme3/gde/angelfont/FontCreator.java @@ -25,24 +25,28 @@ public abstract class FontCreator { } public static AngelFont buildFont(String fontName) { - return buildFont(fontName, 512); + return buildFont(fontName, 256); } public static AngelFont buildFont(String fontName, int bitmapSize) { - return buildFont(fontName, bitmapSize, 16, false); + return buildFont(fontName, bitmapSize, 16); } public static AngelFont buildFont(String fontName, int bitmapSize, int fontSize) { - return buildFont(fontName, bitmapSize, fontSize, false); + return buildFont(fontName, bitmapSize, fontSize, Font.PLAIN); } - public static AngelFont buildFont(String fontName, int bitmapSize, int fontSize, boolean debug) { + public static AngelFont buildFont(String fontName, int bitmapSize, int fontSize, int style) { + return buildFont(fontName, bitmapSize, fontSize, Font.PLAIN, false); + } + + public static AngelFont buildFont(String fontName, int bitmapSize, int fontSize, int style, boolean debug) { BufferedImage fontImage; Font font; String charLocs = ""; - font = new Font(fontName, Font.BOLD, fontSize); // Font Name + font = new Font(fontName, style, fontSize); // Font Name // use BufferedImage.TYPE_4BYTE_ABGR to allow alpha blending fontImage = new BufferedImage(bitmapSize, bitmapSize, BufferedImage.TYPE_4BYTE_ABGR);