5151 * GUI tool for font creation heaven/hell.
5252 */
5353public class CreateFont extends JFrame implements Tool {
54- Editor editor ;
55- //Sketch sketch;
56-
57- // Dimension windowSize;
54+ Base base ;
5855
5956 JList <String > fontSelector ;
6057 JTextField sizeSelector ;
@@ -64,7 +61,7 @@ public class CreateFont extends JFrame implements Tool {
6461 JButton okButton ;
6562 JTextField filenameField ;
6663
67- HashMap <String ,Font > table ;
64+ Map <String ,Font > table ;
6865 boolean smooth = true ;
6966
7067 Font font ;
@@ -86,7 +83,7 @@ public String getMenuTitle() {
8683
8784
8885 public void init (Editor editor ) {
89- this . editor = editor ;
86+ base = editor . getBase () ;
9087
9188 Container paine = getContentPane ();
9289 paine .setLayout (new BorderLayout ()); //10, 10));
@@ -111,12 +108,12 @@ public void init(Editor editor) {
111108 // also ignore dialog, dialoginput, monospaced, serif, sansserif
112109
113110 // getFontList is deprecated in 1.4, so this has to be used
114- //long t = System.currentTimeMillis();
111+ //long t = System.currentTimeMillis();
115112 GraphicsEnvironment ge =
116113 GraphicsEnvironment .getLocalGraphicsEnvironment ();
117114 Font [] fonts = ge .getAllFonts ();
118115 //System.out.println("font startup took " + (System.currentTimeMillis() - t) + " ms");
119-
116+
120117 if (false ) {
121118 ArrayList <Font > fontList = new ArrayList <Font >();
122119 File folderList = new File ("/Users/fry/coconut/sys/fonts/web" );
@@ -136,7 +133,7 @@ public boolean accept(File dir, String name) {
136133 Font font = Font .createFont (Font .TRUETYPE_FONT , input );
137134 input .close ();
138135 fontList .add (font );
139-
136+
140137 } catch (Exception e ) {
141138 System .out .println ("Ignoring " + fontFile .getName ());
142139 }
@@ -348,30 +345,14 @@ public void build() {
348345 filename += ".vlw" ;
349346 }
350347
351- // Please implement me properly. The schematic is below, but not debugged.
352- // http://dev.processing.org/bugs/show_bug.cgi?id=1464
353-
354- // final String filename2 = filename;
355- // final int fontsize2 = fontsize;
356- // SwingUtilities.invokeLater(new Runnable() {
357- // public void run() {
358348 try {
359349 Font instance = table .get (list [selection ]);
360350 font = instance .deriveFont (Font .PLAIN , fontsize );
361351 //PFont f = new PFont(font, smooth, all ? null : PFont.CHARSET);
362352 PFont f = new PFont (font , smooth , charSelector .getCharacters ());
363353
364- // PFont f = new PFont(font, smooth, null);
365- // char[] charset = charSelector.getCharacters();
366- // ProgressMonitor progressMonitor = new ProgressMonitor(CreateFont.this,
367- // "Creating font", "", 0, charset.length);
368- // progressMonitor.setProgress(0);
369- // for (int i = 0; i < charset.length; i++) {
370- // System.out.println(charset[i]);
371- // f.index(charset[i]); // load this char
372- // progressMonitor.setProgress(i+1);
373- // }
374-
354+ // the editor may have changed while the window was open
355+ Editor editor = base .getActiveEditor ();
375356 // make sure the 'data' folder exists
376357 File folder = editor .getSketch ().prepareDataFolder ();
377358 f .save (new FileOutputStream (new File (folder , filename )));
@@ -383,8 +364,6 @@ public void build() {
383364 JOptionPane .WARNING_MESSAGE );
384365 e .printStackTrace ();
385366 }
386- // }
387- // });
388367
389368 setVisible (false );
390369 }
0 commit comments