Windows UI scaling not respected

When using the default graphics renderer, UI scaling in Windows is respected but not when using FX2D. With any scale higher than 100% the canvas sizes incorrectly.

Unfortunately, for the graphics I am teaching, the default renderer is insufficient. FX2D is required for smooth curves.

The pixelDensity() and displayDensity() do not seem made for this problem. Meanwhile pixelWidth works identically to width so no help there.

Is there a solution, or is this a bug / feature request?

I don’t use the Windows operating system on a regular basis and therefore cannot answer your question. However, the demo below shows how to scale JavaFX drawing in case that could be a possible work around to the window scaling issue. The circles start out the same size, but only the first one is scaled up.

import javafx.stage.Stage;
import javafx.scene.layout.Pane;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.transform.Scale;

void setup() {
  size(1, 1, FX2D);
  Stage stage = new Stage();
  Pane pane = new Pane(); 
  
// Circles start out the same size.
  Circle circle1 = new Circle(200, 155, 50);
  circle1.setFill(Color.BLUE);
  pane.getChildren().add(circle1);
  
  Circle circle2 = new Circle(450, 155, 50);
  circle2.setFill(Color.RED);
  pane.getChildren().add(circle2);
  
// Only circle1 is scaled.
  Scale scale = new Scale();
  scale.setX(2.5);
  scale.setY(2.5);
  scale.setPivotX(200); // Same as original coordinates
  scale.setPivotY(155);
  circle1.getTransforms().addAll(scale);

  Scene scene = new Scene(pane, 600, 350);
  stage.setTitle("Scaling transformation example JavaFX");
  stage.setScene(scene);
  stage.show();
}

Output:

1 Like

Thanks! But using all new code is not a viable method of teaching cross-platform scripting.

FX2D should respect UI scaling on Windows as it does on macOS.