Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

JDK-8211294: [windows] TextArea content is blurry with 125% scaling #225

Open
lvxingtu opened this issue Sep 28, 2018 · 10 comments
Open

JDK-8211294: [windows] TextArea content is blurry with 125% scaling #225

lvxingtu opened this issue Sep 28, 2018 · 10 comments
Labels
bug Something isn't working

Comments

@lvxingtu
Copy link

image
image

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?

@eugener eugener added the bug Something isn't working label Sep 28, 2018
@kevinrushforth
Copy link
Collaborator

I can reproduce this on my Win 7 machine with 125% scaling, too.

@kevinrushforth kevinrushforth changed the title The TextArea‘s conent looks blur when scale setting is not 100% on windows 10. [windows] TextArea content is blurry with 125% scaling Sep 28, 2018
@kevinrushforth kevinrushforth changed the title [windows] TextArea content is blurry with 125% scaling JDK-8211294: [windows] TextArea content is blurry with 125% scaling Sep 28, 2018
@kevinrushforth
Copy link
Collaborator

kevinrushforth commented Sep 28, 2018

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.

@ghost
Copy link

ghost commented Feb 14, 2019

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%.

@kevinrushforth
Copy link
Collaborator

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).

@ghost
Copy link

ghost commented Feb 17, 2019

Ah, ok. So is the perceived bluriness and scene scaling a bug or intended beahviour?

@thomas-andres
Copy link

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);
		}
	}
}

@lvxingtu
Copy link
Author

lvxingtu commented Nov 7, 2019

@thomas-andres Thank you. It's a great solution. How did you thought the wonderfual soluation?

@thomas-andres
Copy link

thomas-andres commented Nov 7, 2019

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 :)

@kevinrushforth
Copy link
Collaborator

Note that this GitHub issue tracker is not actively tracked or managed.

@madmas
Copy link

madmas commented Feb 23, 2021

Workarounds should not be necessary with versions newer than openjfx16 anymore according to https://bugs.openjdk.java.net/browse/JDK-8211294

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants