Font size, dpi and text crispness (snapping to pixels)
Jeff Martin
jeff at reportmill.com
Thu Apr 16 23:17:46 UTC 2015
I should have included a smiley when I suggested a 5k Retina monitor as a “workaround”. :-)
Also, I should have mentioned that I was able to improve my text rendering significantly with:
myText.setFontSmoothingType(FontSmoothingType.LCD)
It isn’t as crisp as Eclipse, but I believe the text rendering is as good as Xcode, which renders text with antialiasing.
jeff
On Apr 16, 2015, at 5:24 PM, Matthieu BROUILLARD <matthieu at brouillard.fr> wrote:
> In my company at least in the business (healthcare in hospitals) we target JavaFX for (as a replacement of old app in Swing) we for sure cannot ask our clients to change their computers/screen to have HiDPI... so having 5K screens, yes in 2045 perhaps.
>
>
> On Thu, Apr 16, 2015 at 7:12 PM, Jeff Martin <jeff at reportmill.com> wrote:
> I’m surprised about the font size problem - If I create a font with new Font(“Monaco”, 10), text shows up the same size as it does in Eclipse.
>
> I don’t think there is a solution for the blurry problem, however, because there is no way to disable Antialiasing. In Swing, I was able to get crisp rendering identical to eclipse by checking for very specific fonts/sizes and disabling TEXT_ANTIALIASING.
>
> The only solution in JavaFX may be to get a Retina monitor. This didn’t seem to be a terrible proposition to me last year, when it seemed like almost everything from phones to tablets to laptops had gone HiDPI. It’s taking forever for the desktop world to catch on, though. Apple is taking it’s time. Dell apparently has a nice 5k external, but it needs two mini display ports to drive it.
>
> jeff
>
>
> On Apr 16, 2015, at 9:28 AM, Damien Dudouit <ddudouit at clio.ch> wrote:
>
> > 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());
> > }
> > }
>
>
More information about the openjfx-dev
mailing list