diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index f45a6523b..0efa9c72e 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -959,9 +959,10 @@ public abstract class Mode { s = st.nextToken(); boolean bold = (s.indexOf("bold") != -1); - boolean italic = (s.indexOf("italic") != -1); +// boolean italic = (s.indexOf("italic") != -1); - return new SyntaxStyle(color, italic, bold); +// return new SyntaxStyle(color, italic, bold); + return new SyntaxStyle(color, bold); } diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 518013d9f..9f460fa94 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -1162,9 +1162,10 @@ public class Preferences { s = st.nextToken(); boolean bold = (s.indexOf("bold") != -1); //$NON-NLS-1$ - boolean italic = (s.indexOf("italic") != -1); //$NON-NLS-1$ +// boolean italic = (s.indexOf("italic") != -1); //$NON-NLS-1$ //System.out.println(what + " = " + str + " " + bold + " " + italic); - return new SyntaxStyle(color, italic, bold); +// return new SyntaxStyle(color, italic, bold); + return new SyntaxStyle(color, bold); } } diff --git a/app/src/processing/app/syntax/PdeTextAreaDefaults.java b/app/src/processing/app/syntax/PdeTextAreaDefaults.java index 16ba8a876..0ffe9072e 100644 --- a/app/src/processing/app/syntax/PdeTextAreaDefaults.java +++ b/app/src/processing/app/syntax/PdeTextAreaDefaults.java @@ -24,6 +24,8 @@ package processing.app.syntax; +import java.awt.Font; + import processing.app.*; @@ -194,7 +196,10 @@ public class PdeTextAreaDefaults extends TextAreaDefaults { // http://code.google.com/p/processing/issues/detail?id=1275 rows = 5; - font = Preferences.getFont("editor.font"); + //font = Preferences.getFont("editor.font"); + font = new Font(Preferences.get("editor.font.family"), + Font.PLAIN, Preferences.getInteger("editor.font.size")); + System.out.println("font is " + font.getFamily() + " / " + font.getName() + " / " + font.getFontName() + " / " + font.getPSName()); antialias = Preferences.getBoolean("editor.antialias"); styles = new SyntaxStyle[Token.ID_COUNT]; diff --git a/app/src/processing/app/syntax/SyntaxStyle.java b/app/src/processing/app/syntax/SyntaxStyle.java index 674bbdc78..3d5d19425 100644 --- a/app/src/processing/app/syntax/SyntaxStyle.java +++ b/app/src/processing/app/syntax/SyntaxStyle.java @@ -12,8 +12,6 @@ package processing.app.syntax; import java.awt.*; import javax.swing.JComponent; -import processing.app.Preferences; - /** * A simple text style class. It can specify the color, italic flag, @@ -21,81 +19,76 @@ import processing.app.Preferences; * @author Slava Pestov * @version $Id$ */ -public class SyntaxStyle -{ +public class SyntaxStyle { + private Color color; +// private boolean italic; + private boolean bold; + private Font lastFont; + private Font lastStyledFont; + private FontMetrics fontMetrics; + /** * Creates a new SyntaxStyle. * @param color The text color * @param italic True if the text should be italics * @param bold True if the text should be bold */ - public SyntaxStyle(Color color, boolean italic, boolean bold) - { +// public SyntaxStyle(Color color, boolean italic, boolean bold) { + public SyntaxStyle(Color color, boolean bold) { this.color = color; - this.italic = italic; +// this.italic = italic; this.bold = bold; } - /** - * Returns the color specified in this style. - */ - public Color getColor() - { + + /** Returns the color specified in this style. */ + public Color getColor() { return color; } - /** - * Returns true if no font styles are enabled. - */ - public boolean isPlain() - { - return !(bold || italic); - } + +// /** +// * Returns true if no font styles are enabled. +// */ +// public boolean isPlain() { +// return !(bold || italic); +// } - /** - * Returns true if italics is enabled for this style. - */ - public boolean isItalic() - { - return italic; - } +// /** +// * Returns true if italics is enabled for this style. +// */ +// public boolean isItalic() { +// return italic; +// } - /** - * Returns true if boldface is enabled for this style. - */ - public boolean isBold() - { + + /** Returns true if boldface is enabled for this style. */ + public boolean isBold() { return bold; } + /** - * Returns the specified font, but with the style's bold and - * italic flags applied. + * Returns the specified font, but with the style's bold flags applied. */ - public Font getStyledFont(Font font) - { - if(font == null) - throw new NullPointerException("font param must not" - + " be null"); - if(font.equals(lastFont)) + public Font getStyledFont(Font font) { + if (font.equals(lastFont)) { return lastStyledFont; + } lastFont = font; -// lastStyledFont = new Font(font.getFamily(), -// (bold ? Font.BOLD : 0) -// | (italic ? Font.ITALIC : 0), -// font.getSize()); lastStyledFont = findFont(font.getFamily(), bold ? Font.BOLD : Font.PLAIN, font.getSize()); return lastStyledFont; } + /** * Returns the font metrics for the styled font. */ public FontMetrics getFontMetrics(Font font, JComponent comp) { - if (font == null) { - throw new NullPointerException("font param must not be null"); - } +// if (font == null) { +// throw new NullPointerException("font param must not be null"); +// } if (font.equals(lastFont) && fontMetrics != null) { return fontMetrics; } @@ -112,6 +105,7 @@ public class SyntaxStyle return fontMetrics; } + /* on Windows (and I presume Linux) we get something like this: @@ -130,12 +124,14 @@ public class SyntaxStyle //private String monoFontFamily; private Font findFont(String familyName, int style, int size) { - // getFamily() is too unreliable across platforms - if (Preferences.get("editor.font").startsWith("processing.mono")) { - return processing.app.Toolkit.getMonoFont(size, style); - } else { - return new Font(familyName, style, size); - } +// // getFamily() is too unreliable across platforms +// if (Preferences.get("editor.font").startsWith("processing.mono")) { +// return processing.app.Toolkit.getMonoFont(size, style); +// } else { + System.out.println("creating new font for " + familyName); + return new Font(familyName, style, size); +// } + /* if (monoFontFamily == null) { // This should be more reliable across platforms than the @@ -166,34 +162,26 @@ public class SyntaxStyle */ } + /** * Sets the foreground color and font of the specified graphics * context to that specified in this style. * @param gfx The graphics context * @param font The font to add the styles to */ - public void setGraphicsFlags(Graphics gfx, Font font) - { + public void setGraphicsFlags(Graphics gfx, Font font) { Font _font = getStyledFont(font); gfx.setFont(_font); gfx.setColor(color); } + /** * Returns a string representation of this object. */ - public String toString() - { + public String toString() { return getClass().getName() + "[color=" + color + - (italic ? ",italic" : "") + +// (italic ? ",italic" : "") + (bold ? ",bold" : "") + "]"; } - - // private members - private Color color; - private boolean italic; - private boolean bold; - private Font lastFont; - private Font lastStyledFont; - private FontMetrics fontMetrics; } diff --git a/app/src/processing/app/syntax/TextAreaPainter.java b/app/src/processing/app/syntax/TextAreaPainter.java index 4f23686ce..2cef5962a 100644 --- a/app/src/processing/app/syntax/TextAreaPainter.java +++ b/app/src/processing/app/syntax/TextAreaPainter.java @@ -55,6 +55,7 @@ implements TabExpander, Printable { // unfortunately probably can't just do setDefaults() since things aren't quite set up setFont(defaults.font); +// System.out.println("defaults font is " + defaults.font); setForeground(defaults.fgcolor); setBackground(defaults.bgcolor); @@ -75,6 +76,7 @@ implements TabExpander, Printable { } + /* public void setDefaults(TextAreaDefaults defaults) { setFont(defaults.font); setForeground(defaults.fgcolor); @@ -96,6 +98,7 @@ implements TabExpander, Printable { cols = defaults.cols; rows = defaults.rows; } + */ /**