[OpenJDK 2D-Dev] [9] Review request for 8142966 Wrong cursor position in text components on HiDPI display

Alexander Scherbatiy alexandr.scherbatiy at oracle.com
Sat Feb 6 15:28:47 UTC 2016

On 05/02/16 23:39, Phil Race wrote:
> Two things strike me when I read this
> 1) Initial surprise at how deep into the font code it goes.
> Perhaps there are alternatives.
> 2) That it changes to using the linear metrics for measuring advance.
> Regardless of (1) I do not think (2) is correct. I am fairly sure this
> will lead to changes in text advance. It seems like it must throw
> away adjusted metrics as a result of glyph hinting.
> I don't know what the fix should be, since I have not looked at the
> problem top-down, I am just seeing the bottom-up proposed solution.
> So all I can say for now is that it needs to be at least somewhat 
> different.

   There was the same issue on Mac OS X which has been fixed in the 
similar way:
   8013569 [macosx] JLabel preferred size incorrect on retina displays 
with non-default font size

   The problem is that in many case for UI scale 2 we return to a user 
an unscaled value.
   But a value for transformed glyph advance, rounded and descaled can 
differ from just rounded glyph advance.

  For example, font[dialog, plain, 12] char 'a':
  transform: 12, advance: 7.35,  rounded advance: 8
  transform: 24, advance: 14.70 round advance: 14

  and 8 does not equal 14 / 2.

   The solution for Mac OS X was to get the glyph advance using only 
font transform, round it and then apply the dev transform:

  481     advance = CGSizeApplyAffineTransform(advance, strike->fFontTx);
  482     if (!JRSFontStyleUsesFractionalMetrics(strike->fStyle)) {
  483         advance.width = round(advance.width);
  484         advance.height = round(advance.height);
  485     }
  486     advance = CGSizeApplyAffineTransform(advance, strike->fDevTx);

> -phil.
> On 01/27/2016 01:26 PM, Alexander Scherbatiy wrote:
>> Hello,
>> Could you review the fix:
>>   bug: https://bugs.openjdk.java.net/browse/JDK-8142966
>>   webrev: http://cr.openjdk.java.net/~alexsch/8142966/webev.00/
>>  The proposed fix rounds a glyph advance first and then scales it if 
>> UI scales do not equal to one.
>>  Thanks,
>>  Alexandr.

More information about the 2d-dev mailing list