<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:08:59 UTC 2021


On Fri, 29 Jan 2021 14:16:46 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> src/java.desktop/share/classes/javax/swing/text/html/CSS.java line 2870:
>> 
>>> 2868:             w3cLengthMapping.put("cm", 37.7952f); //96px/2.54
>>> 2869:             w3cLengthMapping.put("pc", 16f); //1/6 of 1in
>>> 2870:             w3cLengthMapping.put("in", 96f); //96px
>> 
>> I suggest adding a space after `//`.
>> Align the comments?
>> 
>> As for *px*, CSS defines, “1px is equal to 0.75pt”, then 1pt is 4/3px — this is where 1.3f comes from (=96/72).
>
> Copyright year in CSS.java needs updating to 2021 too.

> As for px, CSS defines, “1px is equal to 0.75pt”, then 1pt is 4/3px — this is where 1.3f comes from (=96/72).

This makes sense.

What makes me wonder is why the length mappings for `px` and `pt` without `W3C_LENGTH_UNITS` are exactly the opposite. In particular, it means that with W3C, `1pt > 1px`, while without W3C `1px > 1pt`.
That seems odd.

On the other hand, I don't know what the goal of those length mappings is, and they are not the sope of this PR.

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

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


More information about the swing-dev mailing list