On Mon, 1 Feb 2021 12:28:32 GMT, Matthias Perktold 
<github.com+7334069+mperkt...@openjdk.org> wrote:

> > 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 as the decimal separator.

Interesting. With `Locale.ENGLISH`, it will be more robust.


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

It is likely because `sun.java2d.uiScale` gets applied to both frames. If the 
font size is the same, 2d surface gets scaled up to the same level, which 
results in the same size of the frames.

Yet the calculations of the conversion ratios in CSS depend only on the 
resolution of the main screen. If the main screen resolution is 96dpi (100% 
scaling), the font size will be the same as after your fix.

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

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

Reply via email to