From d292dcc17dd63d84991b5f84f2a244c702a494e6 Mon Sep 17 00:00:00 2001 From: benfry Date: Wed, 10 Dec 2003 00:06:14 +0000 Subject: [PATCH] fixes to font builder --- processing/app/PdeFontBuilder.java | 67 ++++++++++++++++++++++++++---- processing/todo.txt | 10 +++-- 2 files changed, 65 insertions(+), 12 deletions(-) diff --git a/processing/app/PdeFontBuilder.java b/processing/app/PdeFontBuilder.java index 01a5d3bf1..cc1756100 100644 --- a/processing/app/PdeFontBuilder.java +++ b/processing/app/PdeFontBuilder.java @@ -42,9 +42,11 @@ public class PdeFontBuilder extends JFrame { JList fontSelector; JComboBox styleSelector; JTextField sizeSelector; + JCheckBox smoothBox; JTextArea sample; JButton okButton; JTextField filenameField; + boolean smooth = true; Font font; @@ -135,13 +137,17 @@ public class PdeFontBuilder extends JFrame { selection = fontSelector.getSelectedIndex(); okButton.setEnabled(true); + update(); + + /* int fontsize = 0; try { fontsize = Integer.parseInt(sizeSelector.getText().trim()); //System.out.println("'" + sizeSelector.getText() + "'"); } catch (NumberFormatException e2) { } - if (fontsize != 0) { + // if a deselect occurred, selection will be -1 + if ((fontsize != 0) && (selection != -1)) { font = new Font(list[selection], Font.PLAIN, fontsize); //System.out.println("setting font to " + font); sample.setFont(font); @@ -149,6 +155,7 @@ public class PdeFontBuilder extends JFrame { String filenameSuggestion = list[selection].replace(' ', '_'); filenameField.setText(filenameSuggestion); } + */ //filenameField.paintComponent(filenameField.getGraphics()); //getContentPane().repaint(); } @@ -167,14 +174,17 @@ public class PdeFontBuilder extends JFrame { }); */ + // see http://rinkworks.com/words/pangrams.shtml sample = new JTextArea("The quick brown fox blah blah.") { + //"Forsaking monastic tradition, twelve jovial friars gave up their vocation for a questionable existence on the flying trapeze.") { public void paintComponent(Graphics g) { + //System.out.println("disabling aa"); Graphics2D g2 = (Graphics2D) g; - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - true ? - RenderingHints.VALUE_ANTIALIAS_ON : - RenderingHints.VALUE_ANTIALIAS_OFF); - super.paintComponent(g); + g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + smooth ? + RenderingHints.VALUE_TEXT_ANTIALIAS_ON : + RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); + super.paintComponent(g2); } }; @@ -212,17 +222,35 @@ public class PdeFontBuilder extends JFrame { JPanel panel = new JPanel(); panel.add(new JLabel("Size:")); sizeSelector = new JTextField("48 "); + sizeSelector.getDocument().addDocumentListener(new DocumentListener() { + public void insertUpdate(DocumentEvent e) { update(); } + public void removeUpdate(DocumentEvent e) { update(); } + public void changedUpdate(DocumentEvent e) { } + }); + panel.add(sizeSelector); JLabel rec = new JLabel("(Recommended size for 3D use is 48 points)"); if (PdeBase.platform == PdeBase.MACOSX) { rec.setFont(new Font("Dialog", Font.PLAIN, 10)); } panel.add(rec); + + smoothBox = new JCheckBox("Smooth"); + smoothBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //System.out.println(e); + smooth = smoothBox.isSelected(); + System.out.println(smooth); + } + }); + smoothBox.setSelected(smooth); + panel.add(smoothBox); + pain.add(panel); JPanel filestuff = new JPanel(); filestuff.add(new JLabel("Filename:")); - filestuff.add(filenameField = new JTextField(25)); + filestuff.add(filenameField = new JTextField(20)); filestuff.add(new JLabel(".vlw")); pain.add(filestuff); @@ -253,6 +281,10 @@ public class PdeFontBuilder extends JFrame { // do this after pack so it doesn't affect layout sample.setFont(new Font(list[0], Font.PLAIN, 48)); + fontSelector.setSelectedIndex(0); + //selection = 0; + //update(); // ?? + Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); Dimension size = getSize(); @@ -262,6 +294,25 @@ public class PdeFontBuilder extends JFrame { } + public void update() { + int fontsize = 0; + try { + fontsize = Integer.parseInt(sizeSelector.getText().trim()); + //System.out.println("'" + sizeSelector.getText() + "'"); + } catch (NumberFormatException e2) { } + + // if a deselect occurred, selection will be -1 + if ((fontsize != 0) && (fontsize < 256) && (selection != -1)) { + font = new Font(list[selection], Font.PLAIN, fontsize); + //System.out.println("setting font to " + font); + sample.setFont(font); + + String filenameSuggestion = list[selection].replace(' ', '_'); + filenameField.setText(filenameSuggestion); + } + } + + public void build() { int fontsize = 0; try { @@ -286,7 +337,7 @@ public class PdeFontBuilder extends JFrame { try { font = new Font(list[selection], Font.PLAIN, fontsize); - BFont f = new BFont(font, true); + BFont f = new BFont(font, smooth); // make sure the 'data' folder exists if (!targetFolder.exists()) targetFolder.mkdirs(); diff --git a/processing/todo.txt b/processing/todo.txt index 489b2c79a..0d9954795 100644 --- a/processing/todo.txt +++ b/processing/todo.txt @@ -9,6 +9,10 @@ X moved 'find in reference' to the help menu X eliminate the requirement for a 'data' folder X only create 'data' folder when it's needed/used X auto-create code and data folder via 'add files to sketch..' +X option to disable smoothing on font creator +X font builder should update when the size for the font is changed +X (so long as the size itself is valid) +X font builder bug, was cutting off parts of letters _ sketch.properties should go into user.home _ otherwise moving sketch folder will kill it @@ -85,6 +89,8 @@ _ add a method BApplet.setPath() or something like that bugsies +_ doesn't work when outside a function: +_ color bg_color = color(255,0,0); _ find/replace hangs when recapitalizing things _ if last line of code is a comment with no CR after it, _ an OutOfMemoryError ensues @@ -155,7 +161,6 @@ _ problems running external vm/vm is hanging _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1067867520;start=0 _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1067643186 -_ option to disable smoothing on font creator _ create font doesn't support umlauts _ fix up font code to generate unicode chars, at least for iso8859-1 charset _ http://proce55ing.net/discourse/yabb/YaBB.cgi?board=Programs;action=display;num=1067596427 @@ -189,7 +194,6 @@ _ dll and jnilib files have to be in the p5 folder (confirmed by amit) _ there should be other places that they work.. _ could even copy the dll to the p5 folder from the code folder -_ add something to font editor to enable/disable smoothing _ mac -> vlw (or sbit?) font converter _ need to add font metrics code @@ -790,8 +794,6 @@ dh 1 _ rename doesn't set focus to renamer area 1 _ add ESC to font builder, and find 1 _ font builder should open back up with the same selection 1 _ maybe just hide it, just like find - 1 _ font builder should update when the size for the font is changed - 1 _ (so long as the size itself is valid) 1 _ why aren't cursors working on the mac 1 _ clearing the text area on the mac