<Swing Dev> [9] Review request for 8156217 Selected text is shifted on HiDPI display

Alexandr Scherbatiy alexandr.scherbatiy at oracle.com
Thu Jun 2 20:41:51 UTC 2016


On 5/31/2016 10:40 PM, Phil Race wrote:
>
> I applied this and it is *much* better but there still seem to be some 
> tiny quirks.
> When I drag the mouse to select text down and then up again, as I pass 
> the
> original mouse click point vertically, repaint seem to jiggle 
> vertically by a pixel.
> Perhaps a rounding issue in the repaint code's calculation of the 
> location of
> the target y. I think I may see the same in left/right dragging along 
> a line too.
> So I think this is repaint and not text related. Can you take a look.

     I am able to reproduce this only using a floating point scale.
     It looks like 2d issue. I used a test which draws a text in two 
pieces. The second piece of the text is shifted from the first piece by 
the floating point size of the the first piece of the text.
   -----------
     Rectangle2D rect = font.getStringBounds(TEXT, 0, index, 
g.getFontMetrics().getFontRenderContext());
     float selectedTextPosition = (float) rect.getWidth();
     g.drawString(TEXT.substring(0, index), x, y);
     g.drawString(TEXT.substring(index, TEXT.length()), x + 
selectedTextPosition, y);
   -----------

   The second piece of the text can be shifted in the 2 cases:
   a) graphics scale is 1.5 and translation is 1.
   b) graphics scale is 2.25 without applied translation

   I have filed an issue on it:
     JDK-8158370 Text drawn from float pointing position and with float 
pointing scale is shifted
       https://bugs.openjdk.java.net/browse/JDK-8158370

   Thanks,
   Alexandr.

>
> -phil.
>
>
> On 05/06/2016 12:31 PM, Alexandr Scherbatiy wrote:
>> Hello,
>>
>> Could you review the fix:
>>   bug: https://bugs.openjdk.java.net/browse/JDK-8156217
>>   webrev: http://cr.openjdk.java.net/~alexsch/8156217/webrev.00
>>
>>   This is the second part of the fix related to the fact that char 
>> width can be fractional in user space.
>> http://mail.openjdk.java.net/pipermail/swing-dev/2016-May/005814.html
>>
>>   The Font.getStringBounds(...) method is used for the fractional 
>> string width calculation by Swing in user space.
>>
>>  Thanks,
>>  Alexandr.
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20160602/00d68dd0/attachment.html>


More information about the swing-dev mailing list