You are not logged in.

#1 2011-03-28 13:28:11

Markus00000
Member
Registered: 2011-03-27
Posts: 323

[SOLVED] OpenJDK ignores anti-aliasing

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

#2 2011-03-28 14:13:58

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: [SOLVED] OpenJDK ignores anti-aliasing

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

#3 2011-03-28 14:24:59

Markus00000
Member
Registered: 2011-03-27
Posts: 323

Re: [SOLVED] OpenJDK ignores anti-aliasing

Thanks for the tip but it has no effect.

Offline

#4 2011-03-28 14:48:29

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [SOLVED] OpenJDK ignores anti-aliasing

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 sad

Offline

#5 2011-03-28 14:57:37

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,582

Re: [SOLVED] OpenJDK ignores anti-aliasing

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

#6 2011-03-28 15:10:41

Markus00000
Member
Registered: 2011-03-27
Posts: 323

Re: [SOLVED] OpenJDK ignores anti-aliasing

skunktrader, please forgive my ignorance, but what should this tell me?

Offline

#7 2011-03-28 15:25:42

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,582

Re: [SOLVED] OpenJDK ignores anti-aliasing

Paste that code into the start of your application, recompile it and see if the text displays as you expect.

Offline

#8 2011-03-28 15:44:46

Markus00000
Member
Registered: 2011-03-27
Posts: 323

Re: [SOLVED] OpenJDK ignores anti-aliasing

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

#9 2011-03-28 16:10:53

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,582

Re: [SOLVED] OpenJDK ignores anti-aliasing

Yes, that code is sun/oracle jdk specific

Offline

#10 2011-03-28 20:38:02

jwhendy
Member
Registered: 2010-04-01
Posts: 621

Re: [SOLVED] OpenJDK ignores anti-aliasing

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

#11 2011-04-05 11:55:40

Markus00000
Member
Registered: 2011-03-27
Posts: 323

Re: [SOLVED] OpenJDK ignores anti-aliasing

jwhendy, you are right. With identical settings (see first post) Sun's JDK has anti-aliasing while openjdk6 has not.

Offline

#12 2011-04-05 11:58:52

Arpione
Member
From: Pécs, Hungary
Registered: 2010-09-13
Posts: 31

Re: [SOLVED] OpenJDK ignores anti-aliasing

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

#13 2011-04-06 07:29:19

Markus00000
Member
Registered: 2011-03-27
Posts: 323

Re: [SOLVED] OpenJDK ignores anti-aliasing

Thanks, Arpione! I'll mark this topic as solved.

Offline

#14 2011-05-06 03:08:00

Haptic
Member
Registered: 2009-09-03
Posts: 149

Re: [SOLVED] OpenJDK ignores anti-aliasing

Arpione wrote:

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

Board footer

Powered by FluxBB