Diamond Block
Diamond Block

Reputation: 159

How to enable anti-aliasing for JavaFX TextField text?

I have a TextField and a Text object. Both use the exact same font, but for the Text object there is a method that can be used to smooth the font: .setFontSmoothingType(). However, no such method exists for TextField.

As Shaw pointed out, Text objects by default smooth the font, but this is not the case for TextFields.

This difference is unfortunately noticeable as seen in this screenshot:

enter image description here

The top is the TextField and the bottom is the Text with smoothing. So how would I smooth the font for the TextField?

Any help is appreciated, thanks!

Upvotes: 4

Views: 610

Answers (1)

Diamond Block
Diamond Block

Reputation: 159

I was finally able to solve this problem! Using Scene Builder's CSS Analyzer, I was able to find a property called -fx-font-smoothing-type under .text-field .text. By changing the value to gray, the text in the TextField will become smoothed!

Here's an updated screenshot.

Upvotes: 3

Related Questions