Skip to content

Commit 6b89bd3

Browse files
committed
Apply on-the-fly setFontSize to Console
Fixes #7022
1 parent edfc8a2 commit 6b89bd3

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

Diff for: app/src/cc/arduino/ConsoleOutputStream.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
*/
5353
public class ConsoleOutputStream extends ByteArrayOutputStream {
5454

55-
private final SimpleAttributeSet attributes;
55+
private SimpleAttributeSet attributes;
5656
private final PrintStream printStream;
5757
private final Timer timer;
5858

@@ -73,6 +73,10 @@ public ConsoleOutputStream(SimpleAttributeSet attributes, PrintStream printStrea
7373
timer.setRepeats(false);
7474
}
7575

76+
public void setAttibutes(SimpleAttributeSet attributes) {
77+
this.attributes = attributes;
78+
}
79+
7680
public void setCurrentEditorConsole(EditorConsole console) {
7781
this.editorConsole = console;
7882
}

Diff for: app/src/processing/app/Editor.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,10 @@ public void applyPreferences() {
480480
boolean external = PreferencesData.getBoolean("editor.external");
481481
saveMenuItem.setEnabled(!external);
482482
saveAsMenuItem.setEnabled(!external);
483-
for (EditorTab tab: tabs)
483+
for (EditorTab tab: tabs) {
484484
tab.applyPreferences();
485+
}
486+
console.applyPreferences();
485487
}
486488

487489

Diff for: app/src/processing/app/EditorConsole.java

+17-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public static void setCurrentEditorConsole(EditorConsole console) {
5858
private final DefaultStyledDocument document;
5959
private final JTextPane consoleTextPane;
6060

61+
private SimpleAttributeSet stdOutStyle;
62+
private SimpleAttributeSet stdErrStyle;
63+
6164
public EditorConsole() {
6265
document = new DefaultStyledDocument();
6366

@@ -74,7 +77,7 @@ public EditorConsole() {
7477
Font editorFont = PreferencesData.getFont("editor.font");
7578
Font actualFont = new Font(consoleFont.getName(), consoleFont.getStyle(), scale(editorFont.getSize()));
7679

77-
SimpleAttributeSet stdOutStyle = new SimpleAttributeSet();
80+
stdOutStyle = new SimpleAttributeSet();
7881
StyleConstants.setForeground(stdOutStyle, Theme.getColor("console.output.color"));
7982
StyleConstants.setBackground(stdOutStyle, backgroundColour);
8083
StyleConstants.setFontSize(stdOutStyle, actualFont.getSize());
@@ -84,7 +87,7 @@ public EditorConsole() {
8487

8588
consoleTextPane.setParagraphAttributes(stdOutStyle, true);
8689

87-
SimpleAttributeSet stdErrStyle = new SimpleAttributeSet();
90+
stdErrStyle = new SimpleAttributeSet();
8891
StyleConstants.setForeground(stdErrStyle, Theme.getColor("console.error.color"));
8992
StyleConstants.setBackground(stdErrStyle, backgroundColour);
9093
StyleConstants.setFontSize(stdErrStyle, actualFont.getSize());
@@ -109,6 +112,18 @@ public EditorConsole() {
109112
EditorConsole.init(stdOutStyle, System.out, stdErrStyle, System.err);
110113
}
111114

115+
public void applyPreferences() {
116+
Font consoleFont = Theme.getFont("console.font");
117+
Font editorFont = PreferencesData.getFont("editor.font");
118+
Font actualFont = new Font(consoleFont.getName(), consoleFont.getStyle(), scale(editorFont.getSize()));
119+
120+
StyleConstants.setFontSize(stdOutStyle, actualFont.getSize());
121+
StyleConstants.setFontSize(stdErrStyle, actualFont.getSize());
122+
123+
out.setAttibutes(stdOutStyle);
124+
err.setAttibutes(stdErrStyle);
125+
}
126+
112127
public void clear() {
113128
try {
114129
document.remove(0, document.getLength());

0 commit comments

Comments
 (0)