jfreechart
jfreechart copied to clipboard
Fix subpixel text anti-aliasing
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.
Which version of JFreeChart and Java are you using?
I've tested with the version 1.5.1 and the head of the master branch.
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'
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.
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.
This is with buffering enabled:
and this is with buffering disabled (or TRANSLUCENT removed):