Opened 4 years ago
Closed 18 months ago
#20850 closed defect (fixed)
[patch] Font size in Note dialog is very small in Windows10
Reported by: | Owned by: | team | |
---|---|---|---|
Priority: | normal | Milestone: | 23.06 |
Component: | Core | Version: | |
Keywords: | template_report windows javabug laf | Cc: | mpasha, taylor.smock |
Description (last modified by )
What steps will reproduce the problem?
- Download any area
- Click the create note icon
- Enter some text
What is the expected result?
Font size is the same as in the Tags/Membership dialog
What happens instead?
Font size is smaller.
Please provide any additional information below. Attach a screenshot if possible.
URL:https://josm.openstreetmap.de/svn/trunk Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b Last:Changed Date: 2021-04-27 20:35:33 +0200 (Tue, 27 Apr 2021) Build-Date:2021-04-27 21:58:39 Revision:17833 Relative:URL: ^/trunk Identification: JOSM/1.5 (17833 en) Windows 10 64-Bit OS Build number: Windows 10 Enterprise 1909 (18363) Memory Usage: 517 MB / 1820 MB (271 MB allocated, but free) Java version: 1.8.0_291-b10, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM Look and Feel: com.sun.java.swing.plaf.windows.WindowsLookAndFeel Screen: \Display0 1920×1080 (scaling 1.00×1.00) \Display1 1920×1080 (scaling 1.00×1.00) Maximum Screen Size: 1920×1080 Best cursor sizes: 16×16→32×32, 32×32→32×32 System property file.encoding: Cp1250 System property sun.jnu.encoding: Cp1250 Locale info: en_US Numbers with default locale: 1234567890 -> 1234567890 Plugins: + AddrInterpolation (35640) + FixAddresses (35640) + Mapillary (1.5.37.6) + OpeningHoursEditor (35640) + apache-commons (35524) + apache-http (35589) + buildings_tools (35669) + imagery_offset_db (35640) + javafx-windows (35655) + jna (35662) + measurement (35640) + reverter (35732) + scripting (30798) + turnrestrictions (35640) + undelete (35640) + utilsplugin2 (35691)
Tried with Java Adopt OpenJDK16 as well, the result is the same.
Attachments (2)
Change History (24)
by , 4 years ago
Attachment: | create note.PNG added |
---|
comment:1 by , 4 years ago
Please note that this bug only affects the "Windows" and "Windows Classic" themes. Font sizes are correct in Metal and CDE/Motif look and feel.
comment:2 by , 3 years ago
Description: | modified (diff) |
---|---|
Keywords: | windows added |
comment:4 by , 23 months ago
In #22648 @mpasha reported same on Java 18, so the scaling problem probably persist across Java versions 8..18.
comment:5 by , 23 months ago
Cc: | added |
---|
comment:6 by , 23 months ago
Component: | Core → Core notes |
---|
comment:8 by , 18 months ago
Cc: | added |
---|---|
Milestone: | → 23.06 |
Summary: | Font size in Note dialog is very small in Windows10 → [patch] Font size in Note dialog is very small in Windows10 |
The following seems to fix both this and #22253.
-
src/org/openstreetmap/josm/gui/widgets/JosmTextArea.java
6 6 import java.awt.event.FocusListener; 7 7 8 8 import javax.swing.JTextArea; 9 import javax.swing.UIManager; 9 10 import javax.swing.text.Document; 10 11 11 12 import org.openstreetmap.josm.gui.MainApplication; … … 90 91 */ 91 92 public JosmTextArea(Document doc, String text, int rows, int columns) { 92 93 super(doc, text, rows, columns); 94 setFont(UIManager.getFont("TextField.font")); 93 95 launcher = TextContextualPopupMenu.enableMenuFor(this, true); 94 96 addFocusListener(this); 95 97 }
@taylor Could you please have a look? I checked both on Ubuntu with Java 11 (no change) and Windows with Java 8. The latter no longer produces small fonts.
comment:9 by , 18 months ago
Component: | Core notes → Core |
---|
comment:10 by , 18 months ago
setFont(UIManager.getFont("TextField.font"));
As a stupid question, why not TextArea.font
? With Java 20, they appear to be the same on Windows.
comment:11 by , 18 months ago
NVM. I think this is a LaF issue.
See WindowsLookAndFeel.java#L1393 and WindowsLookAndFeel.java#L1401 versus MetalLookAndFeel.java#L698 and MetalLookAndFeel.java#L708.
I'll open an upstream ticket.
comment:12 by , 18 months ago
Keywords: | javabug added |
---|
Upstream ticket: https://bugs.openjdk.org/browse/JDK-6396936
I think we can just put it in PlatformHookWindows
.
comment:13 by , 18 months ago
@gaben: Can you check and see if the following works for you?
-
src/org/openstreetmap/josm/tools/PlatformHookWindows.java
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 diff --git a/src/org/openstreetmap/josm/tools/PlatformHookWindows.java b/src/org/openstreetmap/josm/tools/PlatformHookWindows.java
a b 70 70 import java.util.regex.Matcher; 71 71 import java.util.regex.Pattern; 72 72 73 import com.sun.java.swing.plaf.windows.WindowsLookAndFeel; 73 74 import org.openstreetmap.josm.data.Preferences; 74 75 import org.openstreetmap.josm.data.StructUtils; 75 76 import org.openstreetmap.josm.data.StructUtils.StructEntry; … … 79 80 import org.openstreetmap.josm.io.OnlineResource; 80 81 import org.openstreetmap.josm.spi.preferences.Config; 81 82 83 import javax.swing.UIManager; 84 82 85 /** 83 86 * {@code PlatformHook} implementation for Microsoft Windows systems. 84 87 * @since 1023 … … 152 155 extendFontconfig("fontconfig.properties.src"); 153 156 } 154 157 158 @Override 159 public void preStartupHook() { 160 // See #20850. The upstream bug (JDK-6396936) is unlikely to ever be fixed due to potential compatibility 161 // issues. This affects Windows LaF only (includes Windows Classic, a sub-LaF of Windows LaF). 162 if (UIManager.getLookAndFeel() instanceof WindowsLookAndFeel 163 && "Monospaced".equals(UIManager.getFont("TextArea.font").getFamily())) { 164 UIManager.put("TextArea.font", UIManager.getFont("TextField.font")); 165 } 166 } 167 155 168 @Override 156 169 public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback) { 157 170 warnSoonToBeUnsupportedJava(javaCallback);
comment:14 by , 18 months ago
Unfortunately, it's not working. Also, I couldn't compile it with Java 11 because the WindowsLookAndFeel
class isn't available.
Furthermore, the UIManager.getLookAndFeel()
returns javax.swing.plaf.metal.MetalLookAndFeel
even on Windows with native LaF. Maybe the LafPreference
should be used, but I haven't dug into it yet.
comment:15 by , 18 months ago
I probably have to fiddle with the location of the patch; I thought that we were setting the LaF early in startup. I'll check the code flow.
But it does look like we have a MainApplication.applyWorkarounds
method which would be an even better location to put it (it does LaF workarounds).
comment:16 by , 18 months ago
-
src/org/openstreetmap/josm/gui/MainApplication.java
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 diff --git a/src/org/openstreetmap/josm/gui/MainApplication.java b/src/org/openstreetmap/josm/gui/MainApplication.java
a b 1101 1101 if ("Metal".equals(laf) && javaVersion >= 11 && javaVersion < 17) { 1102 1102 UIManager.put("ToolTipUI", JosmMetalToolTipUI.class.getCanonicalName()); 1103 1103 } 1104 1105 // See #20850. The upstream bug (JDK-6396936) is unlikely to ever be fixed due to potential compatibility 1106 // issues. This affects Windows LaF only (includes Windows Classic, a sub-LaF of Windows LaF). 1107 if ("Windows".equals(laf) && "Monospaced".equals(UIManager.getFont("TextArea.font").getFamily())) { 1108 UIManager.put("TextArea.font", UIManager.getFont("TextField.font")); 1109 } 1104 1110 } 1105 1111 1106 1112 static void setupCallbacks() {
comment:17 by , 18 months ago
Yeah, yesterday I fiddled a bit around the applyWorkarounds()
method but could not get it work.
Negative :( The patch in comment:16 doesn't work.
comment:18 by , 18 months ago
Looks like I'm going to have to use windows for debugging. Hopefully no one else needs to use that system while I'm doing that.
comment:19 by , 18 months ago
This should work (taylor.smock here; not logged in on Windows machine).
-
src/org/openstreetmap/josm/gui/MainApplication.java
diff --git a/src/org/openstreetmap/josm/gui/MainApplication.java b/src/org/openstreetmap/josm/gui/MainApplication.java index f00419f..703859f 100644
a b 841 841 842 842 PlatformManager.getPlatform().afterPrefStartupHook(); 843 843 844 applyWorkarounds();845 846 844 FontsManager.initialize(); 847 845 848 846 GuiHelper.setupLanguageFonts(); … … 913 911 } 914 912 // Configure Look and feel before showing SplashScreen (#19290) 915 913 setupUIManager(); 914 // Then apply LaF workarounds 915 applyLaFWorkarounds(); 916 916 // MainFrame created before setting look and feel and not updated (#20771) 917 917 SwingUtilities.updateComponentTreeUI(mainFrame); 918 918 … … 1062 1062 JOSM_WEBSITE_NTV2_SOURCE); 1063 1063 } 1064 1064 1065 static void applyWorkarounds() { 1065 /** 1066 * Apply workarounds for LaF and platform specific issues. This must be called <i>after</i> the 1067 * LaF is set. 1068 */ 1069 static void applyLaFWorkarounds() { 1066 1070 final String laf = UIManager.getLookAndFeel().getID(); 1067 1071 final int javaVersion = Utils.getJavaVersion(); 1068 1072 // Workaround for JDK-8180379: crash on Windows 10 1703 with Windows L&F and java < 8u141 / 9+172 … … 1101 1105 if ("Metal".equals(laf) && javaVersion >= 11 && javaVersion < 17) { 1102 1106 UIManager.put("ToolTipUI", JosmMetalToolTipUI.class.getCanonicalName()); 1103 1107 } 1108 1109 // See #20850. The upstream bug (JDK-6396936) is unlikely to ever be fixed due to potential compatibility 1110 // issues. This affects Windows LaF only (includes Windows Classic, a sub-LaF of Windows LaF). 1111 if ("Windows".equals(laf) && "Monospaced".equals(UIManager.getFont("TextArea.font").getFamily())) { 1112 UIManager.put("TextArea.font", UIManager.getFont("TextField.font")); 1113 } 1104 1114 } 1105 1115 1106 1116 static void setupCallbacks() {
comment:21 by , 18 months ago
Keywords: | laf added |
---|
Screenshot