JDK-8149369 : [hidpi] HTML-JLabel font sizes are broken in Windows L&F with HiDPI display
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u72
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_7
  • CPU: generic
  • Submitted: 2016-02-08
  • Updated: 2022-09-15
  • Resolved: 2022-09-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Relates :  
Relates :  
Relates :  
Description
When manipulating the font size of an HTML JLabel using the <font size='+1'> tag, the displayed font actually gets smaller, instead of larger. This is probably due to the code starting the calculation at a smaller font-size than the non-HTML JLabel.

This only happens with the Windows Look and Feel.

Steps to reproduce: 
Run the code: 
----------------------- 
import javax.swing.*;
import java.awt.*;

import static javax.swing.JFrame.EXIT_ON_CLOSE;

public class JTextAreaTest {

    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            e.printStackTrace();
        }
        SwingUtilities.invokeLater(() -> {
            final JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
            frame.setBounds(500, 500, 300, 150);
            frame.setLayout(new BorderLayout());
            final JLabel label = new JLabel("Regular Label");
            frame.add(label, BorderLayout.NORTH);
            final JLabel htmlLabel0 = new JLabel("<html><font size='+1'>HTML Label +1</font></html>");
            final JLabel htmlLabel1 = new JLabel("<html><font size='+0'>HTML Label +0</font></html>");
            frame.add(htmlLabel0, BorderLayout.CENTER);
            frame.add(htmlLabel1, BorderLayout.SOUTH);
            frame.setVisible(true);
        });
    }
}

--------------------------

Attached screenshot demonstrates that the +1 font size is actually slightly smaller than the regular font. Also +0 is tiny, even though it should have no effect whatsoever.
Comments
Not reproducible in latest jdk on windows10
15-09-2022