You are not logged in.
I cannot get anti-aliasing to work using OpenJDK. I applied the wiki instructions for Sun's JRE: https://wiki.archlinux.org/index.php/Ja … _-_Sun_JRE
My ~/.bashrc contains:
export JAVA_FONTS=/usr/share/fonts/TTF
export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel'
When I run a Swing application like FreeMind I get:
Picked up _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel'
No errors. FreeMind launches and works fine. Except there is no anti-aliasing. I also tried a minimal HelloArch Swing application with the same result.
Non-Java apps like LXTerminal or Firefox have smooth fonts.
Any help appreciated!
Last edited by Markus00000 (2011-04-06 07:25:17)
Offline
For various reasons I don't like OpenJDK -- 'closed' Java does much better for me.
Try using
export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=lcd'
instead of the above settings, that's what I use and it works fine. (Again: with Sun/Oracle Java.)
:: Registered Linux User No. 223384
:: github
:: infinality-bundle+fonts: good looking fonts made easy
Offline
Thanks for the tip but it has no effect.
Offline
Note that Sun's java uses its own font renderer, rather than freetype2, so fonts won't look the same as in your non-java apps
Offline
If you look at the source for javax.swing.plaf.metal.MetalLookAndFeel you will see something similar to this:
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
boolean lafCond = SwingUtilities2.isLocalDisplay();
Object aaTextInfo = SwingUtilities2.AATextInfo.getAATextInfo(lafCond);
defaults.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo);
You will get compilation warnings though...
Offline
skunktrader, please forgive my ignorance, but what should this tell me?
Offline
Paste that code into the start of your application, recompile it and see if the text displays as you expect.
Offline
As a disclaimer, I am not into Java programming. Nevertheless, wouldn't your code require the following import statement:
import sun.swing.swingutilities2
For me this import fails with a "cannot find symbol" compiler error message. Maybe because I am using OpenJDK?
Offline
Yes, that code is sun/oracle jdk specific
Offline
I didn't think openjdk could make use of the two "export options ..." lines you posted. I looked into this just last weekend for Moneydance fonts and could get anti-aliasing to work for sun's jdk but not openjdk. I know that's confusing since you get the notice about having "picked up" the option... but I know that I saw the change with sun's and not with openjdk.
Perhaps someone has a different options line for openjdk that is equivalent?
Offline
jwhendy, you are right. With identical settings (see first post) Sun's JDK has anti-aliasing while openjdk6 has not.
Offline
This gave me a headache too a couple of weeks ago, but i managed to find a solution. I downloaded the sources with abs and found a patch file called aatext_by_default.diff. Without this patch the awt.useSystemAAFontSetting parameter will be effective again. Rebuild openjdk6 with this PKGBUILD wich ignores the patch. After that you can use the -Dawt.useSystemAAFontSetting=lcd parameter when running java to enable AA or export it as bohoomil suggested.
Offline
Thanks, Arpione! I'll mark this topic as solved.
Offline
This gave me a headache too a couple of weeks ago, but i managed to find a solution. I downloaded the sources with abs and found a patch file called aatext_by_default.diff. Without this patch the awt.useSystemAAFontSetting parameter will be effective again. Rebuild openjdk6 with this PKGBUILD wich ignores the patch. After that you can use the -Dawt.useSystemAAFontSetting=lcd parameter when running java to enable AA or export it as bohoomil suggested.
I'm aware this is solved, but I am having the same issue and have questions about the solution. Is it because of the extra dependencies that allow openjdk6 to ignore the patch? These extra packages are xalan-java, apache-ant, rhino, cpio.
edit: just ran into a failure in build() 10 minutes into compiling with the edited PKGBUILD...
edit2: just ran into another failure in build() around the same time with just a straight up copy and paste from the abs. What?
Here is the last little bit of the output:
>>>Recursively making version all @ Thu May 5 23:46:36 EDT 2011 ...
make[5]: Entering directory `/home/pak/abs/openjdk6/src/icedtea6-1.10.1/openjdk/jdk/make/java/version'
/bin/mkdir -p /home/pak/abs/openjdk6/src/icedtea6-1.10.1/openjdk.build/gensrc/sun/misc
rm -f /home/pak/abs/openjdk6/src/icedtea6-1.10.1/openjdk.build/gensrc/sun/misc/Version.java
rm -f /home/pak/abs/openjdk6/src/icedtea6-1.10.1/openjdk.build/gensrc/sun/misc/Version.java.temp
/bin/sed -e 's/@@launcher_name@@/java/g' \
-e 's/@@java_version@@/1.6.0_22/g' \
-e 's/@@java_runtime_version@@/1.6.0_22-b22/g' \
-e 's/@@jdk_derivative_name@@/IcedTea6 1.10.1/g' \
-e 's/@@distro_name@@/n/a/g' \
-e 's/@@distro_package_version@@/ArchLinux-6.b22_1.10.1-1-x86_64/g' \
-e 's/@@java_runtime_name@@/OpenJDK Runtime Environment/g' \
-e 's/@@jdk_revid@@//g' \
-e 's/@@hotspot_revid@@//g' \
../../../src/share/classes/sun/misc/Version-template.java > /home/pak/abs/openjdk6/src/icedtea6-1.10.1/openjdk.build/gensrc/sun/misc/Version.java.temp
/bin/sed: -e expression #5, char 21: unknown option to `s'
make[5]: *** [/home/pak/abs/openjdk6/src/icedtea6-1.10.1/openjdk.build/gensrc/sun/misc/Version.java] Error 1
make[5]: Leaving directory `/home/pak/abs/openjdk6/src/icedtea6-1.10.1/openjdk/jdk/make/java/version'
make[4]: *** [all] Error 1
make[4]: Leaving directory `/home/pak/abs/openjdk6/src/icedtea6-1.10.1/openjdk/jdk/make/java'
make[3]: *** [all] Error 1
make[3]: Leaving directory `/home/pak/abs/openjdk6/src/icedtea6-1.10.1/openjdk/jdk/make'
make[2]: *** [jdk-build] Error 2
make[2]: Leaving directory `/home/pak/abs/openjdk6/src/icedtea6-1.10.1/openjdk'
make[1]: *** [build_product_image] Error 2
make[1]: Leaving directory `/home/pak/abs/openjdk6/src/icedtea6-1.10.1/openjdk'
make: *** [stamps/icedtea.stamp] Error 2
==> ERROR: A failure occurred in build().
Aborting...
Last edited by Haptic (2011-05-06 03:48:45)
Offline