matthiasblaesing closed pull request #437: [NETBEANS-404] Adjust Javadoc font 
size to editor's zoom level, and avoid all-monospace font
URL: https://github.com/apache/incubator-netbeans/pull/437
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/editor.completion/src/org/netbeans/modules/editor/completion/DocumentationScrollPane.java
 
b/editor.completion/src/org/netbeans/modules/editor/completion/DocumentationScrollPane.java
index 62bf92ebe..6b44298f0 100644
--- 
a/editor.completion/src/org/netbeans/modules/editor/completion/DocumentationScrollPane.java
+++ 
b/editor.completion/src/org/netbeans/modules/editor/completion/DocumentationScrollPane.java
@@ -56,6 +56,7 @@
  *  @author  Martin Roskanin, Dusan Balek
  */
 public class DocumentationScrollPane extends JScrollPane {
+    private static final String TEXT_ZOOM_PROPERTY = "text-zoom"; // Defined 
in DocumentView in editor.lib2
 
     private static final String BACK = 
"org/netbeans/modules/editor/completion/resources/back.png"; //NOI18N
     private static final String FORWARD = 
"org/netbeans/modules/editor/completion/resources/forward.png"; //NOI18N
@@ -105,6 +106,16 @@ public DocumentationScrollPane(JTextComponent 
editorComponent) {
         
         // Add the completion doc view
         view = new HTMLDocView(bgColor);
+        Integer textZoom = (Integer) 
editorComponent.getClientProperty(TEXT_ZOOM_PROPERTY);
+        // Use the same logic as in o.n.editor.GlyphGutter.update().
+        if (textZoom != null && textZoom != 0) {
+            Font font = view.getFont();
+            if (Math.max(font.getSize() + textZoom, 2) == 2) {
+                textZoom = -(font.getSize() - 2);
+            }
+            view.setFont(new Font(font.getFamily(), font.getStyle(),
+                    font.getSize() + textZoom));
+        }
         view.addHyperlinkListener(new HyperlinkAction());
         setViewportView(view);
         
diff --git 
a/editor.completion/src/org/netbeans/modules/editor/completion/HTMLDocView.java 
b/editor.completion/src/org/netbeans/modules/editor/completion/HTMLDocView.java
index 7effde4a6..09342b982 100644
--- 
a/editor.completion/src/org/netbeans/modules/editor/completion/HTMLDocView.java
+++ 
b/editor.completion/src/org/netbeans/modules/editor/completion/HTMLDocView.java
@@ -21,6 +21,7 @@
 package org.netbeans.modules.editor.completion;
 
 import java.awt.Color;
+import java.awt.Font;
 import java.awt.Insets;
 import java.awt.Rectangle;
 import java.awt.event.MouseEvent;
@@ -32,7 +33,6 @@
 
 import javax.swing.JEditorPane;
 import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
 import javax.swing.text.BadLocationException;
 import javax.swing.text.DefaultHighlighter;
 import javax.swing.text.Document;
@@ -169,12 +169,14 @@ protected EditorKit createDefaultEditorKit() {
     private void setBodyFontInCSS() {
         javax.swing.text.html.StyleSheet css =
                 new javax.swing.text.html.StyleSheet();
-        java.awt.Font f = new EditorUI().getDefaultColoring().getFont();
-        setFont(f);
+        Font editorFont = new EditorUI().getDefaultColoring().getFont();
+        // do not use monospaced font, just adjust fontsize
+        Font useFont =
+            new Font(getFont().getFamily(), Font.PLAIN, editorFont.getSize());
+        setFont(useFont);
         try {
-            css.addRule(new StringBuilder("body, div { font-size: 
").append(f.getSize()) // NOI18N
-                    .append("; font-family: 
").append(getFont().getFamily()).append(";}").toString()); // NOI18N
-            // do not use monospaced font, just adjust fontsize
+            css.addRule(new StringBuilder("body, div { font-size: 
").append(useFont.getSize()) // NOI18N
+                    .append("; font-family: 
").append(useFont.getFamily()).append(";}").toString()); // NOI18N
         } catch (Exception e) {
         }
         css.addStyleSheet(htmlKit.getStyleSheet());


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to