jfreechart icon indicating copy to clipboard operation
jfreechart copied to clipboard

Fix subpixel text anti-aliasing

Open ebourg opened this issue 3 years ago • 6 comments

Hi,

I noticed that subpixel text anti-aliasing doesn't work when the hint is set on the chart:

chart.setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);

With this hint the title and the values on the axis are anti-aliased with shades of gray and look blurry.

A workaround is to disable the buffering of the ChartPanel.

Another solution is to remove the Transparency.TRANSLUCENT parameter when creating the buffer, this is what this PR suggests.

ebourg avatar Nov 09 '20 22:11 ebourg

Which version of JFreeChart and Java are you using?

jfree avatar Nov 10 '20 05:11 jfree

I've tested with the version 1.5.1 and the head of the master branch.

ebourg avatar Nov 10 '20 08:11 ebourg

Just for information. If you are using HiDPI resolutions like 4k. The problem is not about text aliasing, similar disabling of chart buffering is very bad solution. In mainly, if you are using java11. The problem is in the swing directly. The best solution which I found is old swing configuration which still works! Place this to the JVM environment (for example to /etc/environment) _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true'

raven2cz avatar Nov 10 '20 08:11 raven2cz

I tried with Java 8 and 11 on Windows 10 with a standard 1920x1080, non scaled display. There was no difference with -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true, the subpixel anti-aliasing still doesn't work.

ebourg avatar Nov 10 '20 09:11 ebourg

Can you email me ([email protected]) a screenshot of what you see? Meanwhile I'm trying to figure out the original purpose of the translucent setting - it was useful in some context, but I don't recall exactly what.

jfree avatar Nov 10 '20 09:11 jfree

This is with buffering enabled:

image

and this is with buffering disabled (or TRANSLUCENT removed):

image

ebourg avatar Nov 10 '20 10:11 ebourg