Hello,

I'm experimenting with Java FX on a Windows 7 machine, using Java 1.8.0_40.

The *javafx.scene.text.*Font javadoc says :

*The size of a Font is described as being specified in points which are a
real world measurement of approximately 1/72 inch. *

*[...] Note that the real world distances specified by the default
coordinate system only approximate point sizes as a rule of thumb and are
typically defaulted to screen pixels for most displays. *

Java FX behaves as if the display dpi is 72 while in my case for instance
its about 96. 96/72 = 1.3333.

So for instance if I set Font.font("Consolas", FontPosture.REGULAR, 10) as
a font on a javafx.scene.control.TextArea, text appears a lot smaller than
in my eclipse editor configured with the same font.
Obviously, I get about the same visual size if I use a font size of 13 in
Java FX while using the same font in size 10 in Eclipse.

I guess I could set scaling somehow in my Java FX code. But using scaling,
I imagine that text has little chance to display as crisp as it should.

In fact, trying to compare the pixel output of Eclipse with font size 10
and Java FX in font size 13 (or 13.333), the Java FX one is slightly blurry.

What can be done in Java FX when an application needs text as clear as
possible, for instance if the application is a text editor ?

What is the correct approach in a Java FX app so that it respect the
default font size configured at the OS level ?


Thanks a lot in advance,

Damien


public final class MyApplication extends Application {

  public static void main(String[] args) {
    launch(args);
  }

  @Override
  public void start(Stage primaryStage) {
    TextArea editor = new TextArea();

    editor.setFont(Font.font("Consolas", FontPosture.REGULAR, 10));

    primaryStage.setScene(new Scene(editor));
    primaryStage.show();

    System.out.println(Toolkit.getDefaultToolkit().getScreenResolution());
  }
}

Reply via email to