<Swing Dev> RFR: 8231286: HTML font size too large with high-DPI scaling and W3C_LENGTH_UNITS [v4]

Matthias Perktold github.com+7334069+mperktold at openjdk.java.net
Mon Feb 1 12:31:43 UTC 2021


On Sat, 30 Jan 2021 16:22:17 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>>> The test passes for me with the fresh build of JDK, even without the fix applied.
>>> Indeed, I get the same frame dimensions in both cases: 150×42.
>>> 
>>> However, the test fails when run with JDK 11.0.10 or JDK 15, the dimension of `htmlPane` is 409×76.
>>> 
>> [JDK-8257664](https://bugs.openjdk.java.net/browse/JDK-8257664): HTMLEditorKit: Wrong CSS relative font sizes
>> has changed the behaviour. With the fix reverted, I get frame size of 409×76 as in previous versions.
>
>> > The test passes for me with the fresh build of JDK, even without the fix applied.
>> > Indeed, I get the same frame dimensions in both cases: 150×42.
>> > However, the test fails when run with JDK 11.0.10 or JDK 15, the dimension of `htmlPane` is 409×76.
>> 
>> [JDK-8257664](https://bugs.openjdk.java.net/browse/JDK-8257664): HTMLEditorKit: Wrong CSS relative font sizes
>> has changed the behaviour. With the fix reverted, I get frame size of 409×76 as in previous versions.
> 
> I have submitted [JDK-8260687](https://bugs.openjdk.java.net/browse/JDK-8260687): _Inherited font size is smaller than expected when using StyleSheet to add styles_.
> 
> I suggest declaring the `font-size` property on the `<body>` element in `style` attribute.

> Does
> ```java
> if ("1.3".equals(String.format("%1.1", ratio))
> ```
> look clearer?

I went with something similar to this now. Unfortunately, I also needed to use `Locale.ENGLISH` explicitely to get a dot a as the decimal separator.

> I guess the test does not fail if the system scaling (of the main monitor) is set to 100% because res value read from Toolkit.getDefaultToolkit().getScreenResolution() is 96/72 which is 1.3.
> 
> In my testing, sun.java2d.uiScale has no effect on the result.

To be honest, this is unclear to me as well, I just copied what @prsadhuk had. When testing with older JDKs, I got some different dimensions, but at least now with the fix applied it doesn't seem to change anything.

> I propose to move the test into CSS folder, and probably to create its own folder, `8231286` or 'font-size`.

Done, moved into `./CSS/8231286`. 

> I suggest declaring the `font-size` property on the `<body>` element in `style` attribute.

Done.

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

PR: https://git.openjdk.java.net/jdk/pull/2256


More information about the swing-dev mailing list