[OpenJDK 2D-Dev] <AWT Dev> [9] Review request for 8076545 Text size is twice bigger under Windows L&F on Win 8.1 with HiDPI display

Jim Graham james.graham at oracle.com
Mon Nov 16 20:02:38 UTC 2015

Hi Alexandr,

One bug - we should be using LOGPIXELSY instead of X.

Otherwise, the changes look OK except for the one question/issue which I 
don't know/remember the answer for:

How does this interact with per-monitor APIs?  I believe LOGPIXELSX will 
not change until the user logs off and back on even if the application 
is declared per-monitor aware.  On the other hand, if we use the new 8.1 
per-monitor DPI functions then we will be getting appropriate values for 
DPI that do change dynamically (they change instantaneously as the user 
modifies the DPI preferences in the CP).

I don't think we need to worry about what happens when the CP settings 
change while we are running because this code is converting a pixel font 
size into a scalable font size and that should remain valid across all 
monitors and DPI changes.  We are worried more about the case of the 
user changing the CP settings and then running a Java program before 
rebooting - where the LOGPIXELSX value is "stale" and only the new API 
produces the current value.

The other question is, when we grab the indicated font size, is the API 
we query for the font size based upon the non-PM-aware LOGPIXELSX value? 
  Or is it based upon a more dynamic PM-aware value?  If it is dynamic 
then we will need to de-scale it by the dynamic DPI value.  If it is not 
dynamic then LOGPIXELSX may be the right value to de-scale it even if 
the CP has been modified.  In other words, are the platform APIs for 
font sizes static until reboot just like LOGPIXELSX?

And I forget if we are already using the new APIs in the rest of the 
Windows HiDPI code...?

In either case this will require some testing to see what happens as the 
CP values are modified dynamically (without logging out) in 8.1...


On 11/16/15 6:07 AM, Alexander Scherbatiy wrote:
>    Hello,
>    Could you review the updated fix:
>      http://cr.openjdk.java.net/~alexsch/8076545/webrev.02
>    - round is used instead of ceil
>    - inverted scales are used
>    Thanks,
>    Alexandr.
> On 10/30/2015 10:40 PM, Jim Graham wrote:
>> In this case round may be better.  ceil() is more for cases where you
>> needed "at least X amount of room", but I don't think a font size is
>> an "at least this much" kind of case.
>> Also, I've been toying with the idea that use of ceil() and floor() in
>> any DPI-adjustment equations should really be "ceil(val - epsilon)" or
>> "floor(ceil + epsilon)" for some small value of epsilon chosen just
>> large enough to prevent various round-off errors from affecting the
>> outcome.  One idea is for 1/256 as the value of epsilon since that
>> could equate to the smallest measurable difference in terms of alpha
>> or interpolation results (or 1/512 for "half the smallest quantum")...
>>             ...jim
>> On 10/29/15 1:36 PM, Phil Race wrote:
>>> size->cx = (int)ceil(size->cx / scale);
>>> So if size->cx / scale works out to be 12.0001 you will round it up
>>> to 13?
>>> Can you check what pixel size windows gives you in such a case ?
>>> I'd be a little surprised if they did that rather than round.
>>> Is the SetFontProperty that does not accept a scale parameter still used
>>> somewhere ?
>>> -phil.
>>> On 10/29/2015 04:53 AM, Sergey Bylokhov wrote:
>>>> On 17.07.15 16:27, Alexander Scherbatiy wrote:
>>>>>> - Sergey's point about multi-mon should be checked out.
>>>>>      Windows 8.1 has option "Let me choose one scaling level for
>>>>> all my
>>>>> displays".
>>>>>      If I unset it I am able to change the size of all items. However,
>>>>> the DPI which returns GetDPIForMonitor is still 2 on HiDPI displays.
>>>> This version looks fine, but I am sure it can be double checked on
>>>> windows 10 at some moment as well.

More information about the 2d-dev mailing list