On 21.08.15 16:12, Alexander Scherbatiy wrote:
On 8/21/2015 2:18 PM, Sergey Bylokhov wrote:
Hi, Alexander.
It seems this is only a part of the request. It does not cover some situations like java properties, which can be used to enable/set/disable anti-aliasing.
The awt.useSystemAAFontSettings property overrides the desktop font rendering hints which can be obtained from toolkit by awt.font.desktophints key.
Also it is unclear how and why our look and feels modify the desktop properties, this api seems private also.
I have filled an issue on it: JDK-8134146 Java L&Fs redefine Desktop Font Rendering Hints
      https://bugs.openjdk.java.net/browse/JDK-8134146
Looks fine.

  Thanks,
  Alexandr.


On 13.08.15 15:07, Alexander Scherbatiy wrote:

Hello,

Could you review the fix:
  bug: https://bugs.openjdk.java.net/browse/JDK-6302464
  webrev: http://cr.openjdk.java.net/~alexsch/6302464/webrev.00

Swing uses internal API to set antialiasing settings for L&Fs and components.

SwingUtilities2.AATextInfo aaTextInfo = new SwingUtilities2.AATextInfo(
            RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB, 140);

UIManager.getDefaults().put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo); // set aa hints globally component.putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo); // set aa hints for a JComponent


There are some ways to provide a public mechanism for antialiasing enabling in Swing:

1. Setting antialiasing rendering hints into UI defaults and component client properties:

UIManager.getDefaults().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); component.putClientProperty(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);

2. Setting a map which contains antialiasing hints:

    Map<RenderingHints.Key, Object> aaHintsMap = new HashMap<>();
aaHintsMap.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);

    UIManager.getDefaults().put(AA_TEXT_PROPERTY_KEY, aaHintsMap);
    component.putClientProperty(AA_TEXT_PROPERTY_KEY, aaHintsMap);

3. Information about antialiasing hints can be stored in a public class

AATextInfo aaTextInfo = new AATextInfo(RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB, 140);
    UIManager.getDefaults().put(AA_TEXT_PROPERTY_KEY, aaTextInfo);
    component.putClientProperty(AA_TEXT_PROPERTY_KEY, aaTextInfo);

The proposed fix used the first approach.

Thanks,
Alexandr.






--
Best regards, Sergey.

Reply via email to