Modify

Opened 3 years ago

Closed 14 months ago

#20850 closed defect (fixed)

[patch] Font size in Note dialog is very small in Windows10

Reported by: vasony <vasony.tamas@…> 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 Don-vip)

What steps will reproduce the problem?

  1. Download any area
  2. Click the create note icon
  3. 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.

Look and feels

Screenshot

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)

create note.PNG (15.3 KB ) - added by vasony <vasony.tamas@…> 3 years ago.
Screenshot
look.png (19.9 KB ) - added by anonymous 3 years ago.
Look and feels

Download all attachments as: .zip

Change History (24)

by vasony <vasony.tamas@…>, 3 years ago

Attachment: create note.PNG added

Screenshot

by anonymous, 3 years ago

Attachment: look.png added

Look and feels

comment:1 by anonymous, 3 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 Don-vip, 3 years ago

Description: modified (diff)
Keywords: windows added

comment:3 by gaben, 19 months ago

Ticket #22648 has been marked as a duplicate of this ticket.

comment:4 by gaben, 19 months ago

In #22648 @mpasha reported same on Java 18, so the scaling problem probably persist across Java versions 8..18.

Last edited 19 months ago by gaben (previous) (diff)

comment:5 by gaben, 19 months ago

Cc: mpasha added

comment:6 by skyper, 18 months ago

Component: CoreCore notes

comment:7 by gaben, 16 months ago

Also see #22253.

comment:8 by gaben, 14 months ago

Cc: taylor.smock 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

     
    66import java.awt.event.FocusListener;
    77
    88import javax.swing.JTextArea;
     9import javax.swing.UIManager;
    910import javax.swing.text.Document;
    1011
    1112import org.openstreetmap.josm.gui.MainApplication;
     
    9091     */
    9192    public JosmTextArea(Document doc, String text, int rows, int columns) {
    9293        super(doc, text, rows, columns);
     94        setFont(UIManager.getFont("TextField.font"));
    9395        launcher = TextContextualPopupMenu.enableMenuFor(this, true);
    9496        addFocusListener(this);
    9597    }

@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.

Last edited 14 months ago by gaben (previous) (diff)

comment:9 by gaben, 14 months ago

Component: Core notesCore

comment:10 by taylor.smock, 14 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 taylor.smock, 14 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 taylor.smock, 14 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 taylor.smock, 14 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  
    7070import java.util.regex.Matcher;
    7171import java.util.regex.Pattern;
    7272
     73import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
    7374import org.openstreetmap.josm.data.Preferences;
    7475import org.openstreetmap.josm.data.StructUtils;
    7576import org.openstreetmap.josm.data.StructUtils.StructEntry;
     
    7980import org.openstreetmap.josm.io.OnlineResource;
    8081import org.openstreetmap.josm.spi.preferences.Config;
    8182
     83import javax.swing.UIManager;
     84
    8285/**
    8386 * {@code PlatformHook} implementation for Microsoft Windows systems.
    8487 * @since 1023
     
    152155        extendFontconfig("fontconfig.properties.src");
    153156    }
    154157
     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
    155168    @Override
    156169    public void startupHook(JavaExpirationCallback javaCallback, WebStartMigrationCallback webStartCallback) {
    157170        warnSoonToBeUnsupportedJava(javaCallback);

comment:14 by gaben, 14 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 taylor.smock, 14 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 taylor.smock, 14 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  
    11011101        if ("Metal".equals(laf) && javaVersion >= 11 && javaVersion < 17) {
    11021102            UIManager.put("ToolTipUI", JosmMetalToolTipUI.class.getCanonicalName());
    11031103        }
     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        }
    11041110    }
    11051111
    11061112    static void setupCallbacks() {

comment:17 by gaben, 14 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 taylor.smock, 14 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 anonymous, 14 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  
    841841
    842842        PlatformManager.getPlatform().afterPrefStartupHook();
    843843
    844         applyWorkarounds();
    845 
    846844        FontsManager.initialize();
    847845
    848846        GuiHelper.setupLanguageFonts();
     
    913911        }
    914912        // Configure Look and feel before showing SplashScreen (#19290)
    915913        setupUIManager();
     914        // Then apply LaF workarounds
     915        applyLaFWorkarounds();
    916916        // MainFrame created before setting look and feel and not updated (#20771)
    917917        SwingUtilities.updateComponentTreeUI(mainFrame);
    918918
     
    10621062                JOSM_WEBSITE_NTV2_SOURCE);
    10631063    }
    10641064
    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() {
    10661070        final String laf = UIManager.getLookAndFeel().getID();
    10671071        final int javaVersion = Utils.getJavaVersion();
    10681072        // Workaround for JDK-8180379: crash on Windows 10 1703 with Windows L&F and java < 8u141 / 9+172
     
    11011105        if ("Metal".equals(laf) && javaVersion >= 11 && javaVersion < 17) {
    11021106            UIManager.put("ToolTipUI", JosmMetalToolTipUI.class.getCanonicalName());
    11031107        }
     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        }
    11041114    }
    11051115
    11061116    static void setupCallbacks() {

comment:20 by gaben, 14 months ago

Ah yes, the LaF workarounds should be set later in order to work.

So this version fixes both #20850 and #22253, confirmed.

Last edited 14 months ago by gaben (previous) (diff)

comment:21 by gaben, 14 months ago

Keywords: laf added

comment:22 by taylor.smock, 14 months ago

Resolution: fixed
Status: newclosed

In 18751/josm:

Fix #20850 and #22253: Font size in TextAreas is very small in Windows (patch by gaben, modified)

This is due to JDK-6396936: Windows LaF has an incorrect font for TextArea.font.
The bug will most likely never be fixed due to backwards compatibility concerns.

Modifications are as follows:

  • Move the workaround to be with other LaF workarounds
  • Ensure that LaF workarounds are applied by calling them after the LaF is set.
  • Add a check to the workaround to ensure that it will only be applied in known-bad configurations.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.