Skip to content

Commit 4659c6f

Browse files
committed
Auto-scale editor and console fonts as well
1 parent 59ec660 commit 4659c6f

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

app/src/processing/app/Editor.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -503,10 +503,9 @@ public void applyPreferences() {
503503
}
504504

505505
// apply changes to the font size for the editor
506-
//TextAreaPainter painter = textarea.getPainter();
507-
textarea.setFont(PreferencesData.getFont("editor.font"));
508-
//Font font = painter.getFont();
509-
//textarea.getPainter().setFont(new Font("Courier", Font.PLAIN, 36));
506+
Font editorFont = scale(PreferencesData.getFont("editor.font"));
507+
textarea.setFont(editorFont);
508+
scrollPane.getGutter().setLineNumberFont(editorFont);
510509

511510
// in case tab expansion stuff has changed
512511
// listener.applyPreferences();

app/src/processing/app/EditorConsole.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.awt.*;
2929
import java.io.PrintStream;
3030

31+
import static processing.app.Theme.scale;
32+
3133
/**
3234
* Message console that sits below the editing area.
3335
*/
@@ -70,7 +72,7 @@ public EditorConsole() {
7072

7173
Font consoleFont = Theme.getFont("console.font");
7274
Font editorFont = PreferencesData.getFont("editor.font");
73-
Font actualFont = new Font(consoleFont.getName(), consoleFont.getStyle(), editorFont.getSize());
75+
Font actualFont = new Font(consoleFont.getName(), consoleFont.getStyle(), scale(editorFont.getSize()));
7476

7577
SimpleAttributeSet stdOutStyle = new SimpleAttributeSet();
7678
StyleConstants.setForeground(stdOutStyle, Theme.getColor("console.output.color"));

app/src/processing/app/Theme.java

+8
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ static public Dimension scale(Dimension dim) {
133133
return new Dimension(scale(dim.width), scale(dim.height));
134134
}
135135

136+
static public Font scale(Font font) {
137+
float size = scale(font.getSize());
138+
// size must be float to call the correct Font.deriveFont(float)
139+
// method that is different from Font.deriveFont(int)!
140+
Font scaled = font.deriveFont(size);
141+
return scaled;
142+
}
143+
136144
static public Rectangle scale(Rectangle rect) {
137145
Rectangle res = new Rectangle(rect);
138146
res.x = scale(res.x);

0 commit comments

Comments
 (0)