openjdk-jfx
openjdk-jfx copied to clipboard
JDK-8211294: [windows] TextArea content is blurry with 125% scaling

Test Code: import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.layout.VBox; import javafx.stage.Stage;
public class HelloFX extends Application {
@Override
public void start(Stage stage) {
String javaVersion = System.getProperty("java.version");
String javafxVersion = System.getProperty("javafx.version");
Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
TextArea ta = new TextArea();
TextField tf = new TextField();
VBox root = new VBox();
root.getChildren().add(ta);
root.getChildren().add(tf);
Scene scene = new Scene(root, 640, 480);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
Environment: win 10 scale :125% oracle jdk11
By the way, how can I chang the cursor(I) style and make font rendering better?
I can reproduce this on my Win 7 machine with 125% scaling, too.
Filed in JBS as JDK-8211294. I slightly modified the test case so that the label is rendered and so the TextField and TextArea are initially populated with text.
I encountered the same Problem on Windows 10 1803 Enterprise and Windows 10 1809 Pro using openjfx 11.0.2 and 12-ea+12.
The blurring is not limited to labels but can also be seen with images and not only happens on 125% but everyhting else than 100% (so 125%, 150%, 175%).
What I also found is that creating a scene with a fixed size of pixels is not the same for different scales, I don't know if this is intended behaviour or part of the same bug?
For example with the following you get different results with 100%, 125%, 150%, 175%, where it only actually creates an 1800 by 900 pixel frame on 100% scaling.
primaryStage.setScene(new Scene(root, 1800, 900));
This can be fixed by scaling the width and heigth of the scene by Screen.getPrimary().getOutputScaleX() and Screen.getPrimary().getOutputScaleY() respectively. I now ask myself if this scaling has to be done manually for each pixel value of each object in the scene?
Interestingly using Oracle's Java 1.8 I seem to only have scaling issues on 150% and 175% but it works fine on 100% and 125%.
Interestingly using Oracle's Java 1.8 I seem to only have scaling issues on 150% and 175% but it works fine on 100% and 125%.
That's because the threshold for using Hi-DPI on JDK 8 is 150% (versus 125% on JDK 9 and later).
Ah, ok. So is the perceived bluriness and scene scaling a bug or intended beahviour?
Workaround for this issue:
Add css:
.text-area > .scroll-pane {
-fx-skin: "MyScrollPaneSkin"
}
Add java code:
public class MyScrollPaneSkin extends ScrollPaneSkin {
public MyScrollPaneSkin(final ScrollPane scrollpane) {
super(scrollpane);
try {
Field viewRectField = ScrollPaneSkin.class.getDeclaredField("viewRect");
viewRectField.setAccessible(true);
StackPane viewRect = (StackPane) viewRectField.get(this);
viewRect.setCache(false);
} catch (Exception e) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "failed to disable scroll pane cache", e);
}
}
}
@thomas-andres Thank you. It's a great solution. How did you thought the wonderfual soluation?
I ran into a similar issue last year, where Font's where blurred inside a scroll pane and found this post: https://stackoverflow.com/questions/26098295/scrollpane-content-becomes-blurry-after-dragging Now I ran into this issue and since the text area also contains a scroll pane I thought it might be the same problem. Happy to see it helps someone else :)
Note that this GitHub issue tracker is not actively tracked or managed.
Workarounds should not be necessary with versions newer than openjfx16 anymore according to https://bugs.openjdk.java.net/browse/JDK-8211294