<Swing Dev> RFR: 8231286: HTML font size too large with high-DPI scaling and W3C_LENGTH_UNITS
Alexey Ivanov
aivanov at openjdk.java.net
Fri Jan 29 23:19:42 UTC 2021
On Fri, 29 Jan 2021 19:58:37 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> test/jdk/javax/swing/text/html/HtmlFontSizeTest.java line 98:
>>
>>> 96: String str = String.format("%.1g%n", ratio);
>>> 97: if (str.compareTo(String.format("%.1g%n", 1.3f)) != 0) {
>>> 98: throw new RuntimeException("HTML font size too large with high-DPI scaling and W3C_LENGTH_UNITS");
>>
>> 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.
>>
>> The formatted string, `str`, contains only the number before the decimal point. I mean for `1.3f`, the formatted string is `"1"`. I'd expect the formatted string to have at least one digit after the decimal point but there's none.
>>
>> Does
>> if ("1.3".equals(String.format("%1.1", ratio))
>> look clearer?
>>
>>
>> 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.
>
> I propose to move the test into CSS folder, and probably to create its own folder, `8231286` or 'font-size`.
> 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.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2256
More information about the swing-dev
mailing list