How to Disable Subpixel Rendering?

colors, java, javafx, user-interface

Solution

The direct answer to your question is that there is a system property flag, you can set.

-Dprism.lcdtext=false

This should turn off subpixel rendering. The flag is not an officially documented or supported part of the platform, so it could change or be removed in the future.

Information on setting of system properties.

Subpixel rendering is a pretty subtle effect, so to really see the difference you may need to screenshot your application and use a tool like MS Paint and zoom in on the pixels to see their color change difference up close.

Also note that on some environments (like OS X), the JavaFX default configuration is to disable subpixel rendering because that is how the rest of the OS generally renders text. In general, JavaFX is usually trying to match the default OS text rendering pretty closely.

Adjusting font rendering hints is surprisingly complex and diverges far from a rational science. Know that even if you turn off subpixel rendering, the text will still have antialiasing and other adjustments applied. For example, under Windows 7 and Java 8, JavaFX will make use of OS specific text rendering systems such as ClearType, so making adjustments to the font rendering configuration in your OS can change how the fonts are rendered in JavaFX.

Problem

I recently asked a question about a color mismatch in JavaFX 8: Color Mismatch In JavaFX8 Labels This got me started on the right path, but I can't figure out how to disable the subpixel rendering. I've tried `-fx-font-smoothing-type: gray` and `-fx-font-smoothing-type: lcd` to no noticeable effect. I've done research on this topic, but I've come up with nothing.

Original source