[hg] main-silver: #216655 - Font anti aliasing broken when using...

  • From: Miloslav Metelka < >
  • To: ,
  • Subject: [hg] main-silver: #216655 - Font anti aliasing broken when using...
  • Date: Tue, 12 Nov 2013 21:57:04 +0000

changeset f2ba621880bf in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/f2ba621880bf
description:
        #216655 - Font anti aliasing broken when using Java SE 7.

diffstat:

 editor.lib2/src/org/netbeans/modules/editor/lib2/view/DocumentViewOp.java |  
34 ++++++++-
 1 files changed, 29 insertions(+), 5 deletions(-)

diffs (84 lines):

diff --git 
a/editor.lib2/src/org/netbeans/modules/editor/lib2/view/DocumentViewOp.java 
b/editor.lib2/src/org/netbeans/modules/editor/lib2/view/DocumentViewOp.java
--- 
a/editor.lib2/src/org/netbeans/modules/editor/lib2/view/DocumentViewOp.java
+++ 
b/editor.lib2/src/org/netbeans/modules/editor/lib2/view/DocumentViewOp.java
@@ -51,6 +51,7 @@
 import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.Rectangle;
+import java.awt.RenderingHints;
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.event.InputEvent;
@@ -82,7 +83,6 @@
 import javax.swing.text.Keymap;
 import javax.swing.text.StyleConstants;
 import org.netbeans.api.editor.mimelookup.MimeLookup;
-import org.netbeans.api.editor.settings.EditorStyleConstants;
 import org.netbeans.api.editor.settings.FontColorNames;
 import org.netbeans.api.editor.settings.FontColorSettings;
 import org.netbeans.api.editor.settings.SimpleValueNames;
@@ -107,6 +107,9 @@
     // -J-Dorg.netbeans.modules.editor.lib2.view.DocumentViewOp.level=FINE
     private static final Logger LOG = 
Logger.getLogger(DocumentViewOp.class.getName());
 
+    // Whether use fractional metrics rendering hint
+    private static final boolean useFractionalMetrics = 
Boolean.getBoolean("org.netbeans.editor.aa.fractional");
+
     static final char PRINTING_SPACE = '\u00B7';
     static final char PRINTING_TAB = '\u2192';
     static final char PRINTING_TAB_ALTERNATE = '\u00BB';
@@ -228,6 +231,8 @@
 
     Map<?, ?> renderingHints;
     
+    Map<?, ?> extraRenderingHints;
+    
     private int lengthyAtomicEdit; // Long atomic edit being performed
 
     ViewHierarchyImpl viewHierarchyImpl; // Assigned upon setParent()
@@ -568,10 +573,21 @@
     
     void updateFontRenderContext(Graphics2D g, boolean paint) {
         if (g != null) {
+            if (!paint && 
ViewHierarchyImpl.SETTINGS_LOG.isLoggable(Level.FINE)) {
+                ViewHierarchyImpl.SETTINGS_LOG.fine(
+                        "DocumentView.updateFontColorSettings() Antialiasing 
Rendering Hints:\n    Graphics: " + // NOI18N
+                                g.getRenderingHints() + 
+                                "\n    Desktop Hints: " + renderingHints + 
// NOI18N
+                                "\n    Extra Hints: " + extraRenderingHints 
+ '\n'); // NOI18N
+            }
+
             // Use rendering hints (antialiasing etc.)
             if (renderingHints != null) {
                 g.addRenderingHints(renderingHints);
             }
+            if (extraRenderingHints != null) {
+                g.addRenderingHints(extraRenderingHints);
+            }
             if (paint) {
                 if (!fontRenderContextFromPaint) {
                     fontRenderContextFromPaint = true;
@@ -829,11 +845,19 @@
         // Attempt to always hold non-null content of "defaultColoring" 
variable once it became non-null
         if (newDefaultColoring != null) {
             defaultColoring = newDefaultColoring;
-            renderingHints = (Map<?, ?>) 
defaultColoring.getAttribute(EditorStyleConstants.RenderingHints);
-        } else {
-            Map<?, ?> desktopHints = (Map<?, ?>) 
Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"); 
//NOI18N
-            renderingHints = desktopHints;
+//            renderingHints = (Map<?, ?>) 
defaultColoring.getAttribute(EditorStyleConstants.RenderingHints);
         }
+
+        // Use desktop hints
+        renderingHints = (Map<?, ?>) 
Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"); 
//NOI18N
+        // Possibly use fractional metrics
+        extraRenderingHints = null;
+        if (useFractionalMetrics) {
+            Map<Object, Object> hints = new HashMap<Object, Object>();
+            hints.put(RenderingHints.KEY_FRACTIONALMETRICS, 
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+            extraRenderingHints = hints;
+        }
+
         if (asTextField) {
             return;
         }

[hg] main-silver: #216655 - Font anti aliasing broken when using...

Miloslav Metelka 11/12/2013

<Possible follow-up(s)>

[hg] main-silver: #216655 - Font anti aliasing broken when using...

Miloslav Metelka 11/23/2013

[hg] main-silver: #216655 - Font anti aliasing broken when using...

Miloslav Metelka 11/23/2013

[hg] main-silver: #216655 - Font anti aliasing broken when using...

Miloslav Metelka 11/25/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 147 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close