Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6302464

Allow programmatic enabling of subpixel anti-aliasing in Swing on ANY platform

XMLWordPrintable

    • b82
    • x86
    • windows_2000

        A DESCRIPTION OF THE REQUEST :
        I'm following up a forum discussion with Phil Race on java.net:
        http://forums.java.net/jive/thread.jspa?messageID=20097&tstart=0#20097

        ...and an article by Chet Haase on the same site:
        http://weblogs.java.net/blog/chet/archive/2005/06/phils_font_fixe.html

        Basically, subpixel anti-aliasing is now doable when drawing text using Java2D and the new RenderHints. It is also automatically used to render Sun's standard look-and-feels for Swing when the host operating system is using subpixel anti-aliasing (say Windows XP with ClearType enabled). However, despite Java2D being equally capable on other platforms, such as Windows 2000, which don't have this capability and hence an option to enable it for native applications, there's no way to force look-and-feels that are aware of this new feature to take advantage of it.

        JUSTIFICATION :
        Under Windows 2000, for example, I can't programmatically force the Windows SystemLookAndFeel to use it, which is a shame, as it would enhance the polish of Swing applications and make them more readable, and be an advantage over competing desktop toolkits. Windows 2000 is an example here, there are undoubtedly other platforms that could benefit.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        It should be possible to set a UIDefault or call some method to specify:

        a) that subpixel anti-aliasing should be used to render Swing components
        b) which TYPE of anti-aliasing should be used (given that Java2D specifies multiple options).

        Ideally, it should be possible to query some object (Font?) to find out what sort of font rendering hints the system applies, and not override them if the system natively supports it and if the user has expressed a preference, avoiding overriding user preferences. It should also be possible to detected (from the same API) to determine if the system actual has this capability (if it doesn't, the application could offer the user an option to enable it or just switch it on).

        Something like:

        java.awt.Font::getSystemTextAntiAliasingRenderingHint
        java.awt.Font::isSystemTextAntiAliasingRenderingHintSupported

        ...to query the desktop's native subpixel (or standard) text anti-aliasing before steamrollering them with the developer's personal antialiasing preference. Or just stick totally to the type of anti-aliasing keys/values already in the RenderingHints' classes' constants.

        Thereafter, use UIDefaults with RenderingHints to suggest to look-and-feels that this feature is sought. Older third-party look-and-feels could safely ignore it.
        ACTUAL -
        It's enabled or disabled internally by Swing, depending on the host machine's windowing system's preferences. The programmer doesn't appear to have any formally specified way of controlling this.

        CUSTOMER SUBMITTED WORKAROUND :
        Write your own look-and-feel...

              alexsch Alexandr Scherbatiy
              jssunw Jitender S (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: