This repository was archived by the owner on Jan 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJavaFxFontsReallySuckOnLinux.java
172 lines (153 loc) · 5.23 KB
/
JavaFxFontsReallySuckOnLinux.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Collectors;
public class JavaFxFontsReallySuckOnLinux extends Application {
public static void main(String[] args) {
launch(args);
// Swing fonts look normal by default.
//SwingFontsAreOK.main(args);
}
@Override
public void start(Stage stage) throws IOException {
// Look at this crap.
// Can't you make it nice by default?
// Are Linux defaults suppossed to be ugly?
defaultsMustSuck(stage);
/*
Let's try to fix that with well hidden know how.
System property "prism.text" can be set to "native" or to "t2k".
System property "prism.lcdtext" can be set to "true" or to "false".
The -fx-font-smoothing-type setting can be set to "lcd" or to "gray".
Let's try all 8 combinations of settings.
The CSS setting will be set via following style declaration:
* {
-fx-font-smoothing-type: gray;
}
*/
//try1(stage);
//try2(stage);
//try3(stage);
//try4(stage);
//try5(stage);
//try6(stage);
//try7(stage);
//try8(stage);
}
static void defaultsMustSuck(Stage stage) throws IOException {
Label lbl = new Label(getText());
StackPane root = new StackPane();
root.getChildren().add(lbl);
Scene scene = new Scene(root, 300, 250);
stage.setTitle("Defaults must suck");
stage.setScene(scene);
stage.show();
}
static void try1(Stage stage) throws IOException {
System.setProperty("prism.text", "native");
System.setProperty("prism.lcdtext", "true");
Label lbl = new Label(getText());
StackPane root = new StackPane();
root.getChildren().add(lbl);
Scene scene = new Scene(root, 300, 250);
scene.getStylesheets().add("style1.css"); // -fx-font-smoothing-type: lcd;
stage.setTitle("try1");
stage.setScene(scene);
stage.show();
}
static void try2(Stage stage) throws IOException {
System.setProperty("prism.text", "native");
System.setProperty("prism.lcdtext", "true");
Label lbl = new Label(getText());
StackPane root = new StackPane();
root.getChildren().add(lbl);
Scene scene = new Scene(root, 300, 250);
scene.getStylesheets().add("style2.css"); // -fx-font-smoothing-type: gray;
stage.setTitle("try2");
stage.setScene(scene);
stage.show();
}
static void try3(Stage stage) throws IOException {
System.setProperty("prism.text", "native");
System.setProperty("prism.lcdtext", "false");
Label lbl = new Label(getText());
StackPane root = new StackPane();
root.getChildren().add(lbl);
Scene scene = new Scene(root, 300, 250);
scene.getStylesheets().add("style1.css"); // -fx-font-smoothing-type: lcd;
stage.setTitle("try3");
stage.setScene(scene);
stage.show();
}
static void try4(Stage stage) throws IOException {
System.setProperty("prism.text", "native");
System.setProperty("prism.lcdtext", "false");
Label lbl = new Label(getText());
StackPane root = new StackPane();
root.getChildren().add(lbl);
Scene scene = new Scene(root, 300, 250);
scene.getStylesheets().add("style2.css"); // -fx-font-smoothing-type: gray;
stage.setTitle("try4");
stage.setScene(scene);
stage.show();
}
static void try5(Stage stage) throws IOException {
System.setProperty("prism.text", "t2k");
System.setProperty("prism.lcdtext", "true");
Label lbl = new Label(getText());
StackPane root = new StackPane();
root.getChildren().add(lbl);
Scene scene = new Scene(root, 300, 250);
scene.getStylesheets().add("style1.css"); // -fx-font-smoothing-type: lcd;
stage.setTitle("try5");
stage.setScene(scene);
stage.show();
}
static void try6(Stage stage) throws IOException {
System.setProperty("prism.text", "t2k");
System.setProperty("prism.lcdtext", "true");
Label lbl = new Label(getText());
StackPane root = new StackPane();
root.getChildren().add(lbl);
Scene scene = new Scene(root, 300, 250);
scene.getStylesheets().add("style2.css"); // -fx-font-smoothing-type: gray;
stage.setTitle("try6");
stage.setScene(scene);
stage.show();
}
static void try7(Stage stage) throws IOException {
System.setProperty("prism.text", "t2k");
System.setProperty("prism.lcdtext", "false");
Label lbl = new Label(getText());
StackPane root = new StackPane();
root.getChildren().add(lbl);
Scene scene = new Scene(root, 300, 250);
scene.getStylesheets().add("style1.css"); // -fx-font-smoothing-type: lcd;
stage.setTitle("try7");
stage.setScene(scene);
stage.show();
}
static void try8(Stage stage) throws IOException {
System.setProperty("prism.text", "t2k");
System.setProperty("prism.lcdtext", "false");
Label lbl = new Label(getText());
StackPane root = new StackPane();
root.getChildren().add(lbl);
Scene scene = new Scene(root, 300, 250);
scene.getStylesheets().add("style2.css"); // -fx-font-smoothing-type: gray;
stage.setTitle("try8");
stage.setScene(scene);
stage.show();
}
static String getText() throws IOException {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
JavaFxFontsReallySuckOnLinux.class.getResourceAsStream("text.txt"), "UTF-8"))) {
return reader.lines().collect(Collectors.joining("\n"));
}
}
}