Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8038076

Browse filesBrowse files
committed
emergency change for font not working properly across platforms
1 parent a93c09c commit 8038076
Copy full SHA for 8038076

File tree

Expand file treeCollapse file tree

1 file changed

+47
-14
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+47
-14
lines changed
Open diff view settings
Collapse file

‎app/src/processing/app/syntax/SyntaxStyle.java‎

Copy file name to clipboardExpand all lines: app/src/processing/app/syntax/SyntaxStyle.java
+47-14Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.awt.*;
1313
import javax.swing.JComponent;
1414

15+
import processing.app.Preferences;
16+
1517

1618
/**
1719
* A simple text style class. It can specify the color, italic flag,
@@ -82,7 +84,7 @@ public Font getStyledFont(Font font)
8284
// (bold ? Font.BOLD : 0)
8385
// | (italic ? Font.ITALIC : 0),
8486
// font.getSize());
85-
lastStyledFont =
87+
lastStyledFont =
8688
findFont(font.getFamily(), bold ? Font.BOLD : Font.PLAIN, font.getSize());
8789
return lastStyledFont;
8890
}
@@ -102,35 +104,66 @@ public FontMetrics getFontMetrics(Font font, JComponent comp) {
102104
// (bold ? Font.BOLD : 0)
103105
// | (italic ? Font.ITALIC : 0),
104106
// font.getSize());
105-
lastStyledFont =
107+
lastStyledFont =
106108
findFont(font.getFamily(), bold ? Font.BOLD : Font.PLAIN, font.getSize());
107109

108110
//fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(lastStyledFont);
109111
fontMetrics = comp.getFontMetrics(lastStyledFont);
110112
return fontMetrics;
111113
}
112-
113-
private String monoFontFamily;
114-
114+
115+
/*
116+
on Windows (and I presume Linux) we get something like this:
117+
118+
mono family Source Code Pro
119+
mono fontname Source Code Pro
120+
mono name Source Code Pro
121+
mono psname SourceCodePro-Regular
122+
123+
mono family Source Code Pro Semibold
124+
mono fontname Source Code Pro Semibold
125+
mono name Source Code Pro Semibold
126+
mono psname SourceCodePro-Semibold
127+
128+
...which means that 'family' is not a usable method.
129+
*/
130+
//private String monoFontFamily;
131+
115132
private Font findFont(String familyName, int style, int size) {
133+
// getFamily() is too unreliable across platforms
134+
if (Preferences.get("editor.font").startsWith("processing.mono")) {
135+
return processing.app.Toolkit.getMonoFont(size, style);
136+
} else {
137+
return new Font(familyName, style, size);
138+
}
139+
/*
116140
if (monoFontFamily == null) {
141+
// This should be more reliable across platforms than the
142+
// family name, which only seems to work correctly on OS X.
143+
// (Or perhaps only when it's installed locally.)
144+
String psName =
145+
processing.app.Toolkit.getMonoFont(size, style).getPSName();
146+
int dash = psName.indexOf('-');
147+
monoFontFamily = psName.substring(0, dash);
148+
117149
// Just get the font family name for comparison
118-
monoFontFamily =
119-
processing.app.Toolkit.getMonoFont(size, style).getFamily();
150+
//monoFontFamily =
151+
//processing.app.Toolkit.getMonoFont(size, style).getFamily();
120152
//processing.app.Toolkit.getMonoFont(size, style).getFamily();
121-
// Font mono = processing.app.Toolkit.getMonoFont(size, style);
122-
// System.out.println("mono family " + mono.getFamily());
123-
// System.out.println("mono fontname " + mono.getFontName());
124-
// System.out.println("mono name " + mono.getName());
125-
// System.out.println("mono psname " + mono.getPSName());
153+
Font mono = processing.app.Toolkit.getMonoFont(size, style);
154+
System.out.println("mono family " + mono.getFamily());
155+
System.out.println("mono fontname " + mono.getFontName());
156+
System.out.println("mono name " + mono.getName());
157+
System.out.println("mono psname " + mono.getPSName());
126158
}
127159
if (familyName.equals(monoFontFamily)) {
128-
// System.out.println("getting style bold? " + (style == Font.BOLD));
160+
System.out.println("getting style bold? " + (style == Font.BOLD));
129161
return processing.app.Toolkit.getMonoFont(size, style);
130162
} else {
131-
// System.out.println("name is " + name + " mono name is " + monoFontName + " " + style);
163+
//System.out.println("name is " + name + " mono name is " + monoFontName + " " + style);
132164
return new Font(familyName, style, size);
133165
}
166+
*/
134167
}
135168

136169
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.