You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ma...@apache.org on 2018/04/07 19:14:44 UTC
[incubator-netbeans] branch master updated: [NETBEANS-404] Have the
font size in the Javadoc popup follow the editor zoom level,
and avoid rendering Javadoc in monospace font only.
This is an automated email from the ASF dual-hosted git repository.
matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 0a1afbb [NETBEANS-404] Have the font size in the Javadoc popup follow the editor zoom level, and avoid rendering Javadoc in monospace font only.
0a1afbb is described below
commit 0a1afbbebe1df2623d40f0e96acb27f0e203ad8e
Author: Eirik Bakke <eb...@ultorg.com>
AuthorDate: Mon Feb 26 14:43:05 2018 +0100
[NETBEANS-404] Have the font size in the Javadoc popup follow the editor zoom level, and avoid rendering Javadoc in monospace font only.
---
.../modules/editor/completion/DocumentationScrollPane.java | 11 +++++++++++
.../netbeans/modules/editor/completion/HTMLDocView.java | 14 ++++++++------
2 files changed, 19 insertions(+), 6 deletions(-)
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 62bf92e..6b44298 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 @@ import org.openide.util.RequestProcessor;
* @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 class DocumentationScrollPane extends JScrollPane {
// 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 7effde4..09342b9 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 java.io.StringReader;
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 @@ public class HTMLDocView extends JEditorPane {
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());
--
To stop receiving notification emails like this one, please contact
matthiasblaesing@apache.org.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists