<Swing Dev> [9] Review request for 8142966 Wrong cursor position in text components on HiDPI display

Alexandr Scherbatiy alexandr.scherbatiy at oracle.com
Wed Jun 1 05:50:08 UTC 2016


On 6/1/2016 12:26 AM, Phil Race wrote:
> On 5/31/2016 1:36 PM, Alexandr Scherbatiy wrote:
>> On 5/31/2016 10:54 PM, Phil Race wrote:
>>>
>>>
>>> This looks reasonable except I am not sure when gc would be null 
>>> here :-
>>>
>>> 1062     private static FontRenderContext getFRCProperty(JComponent 
>>> c) {
>>> 1063         if (c != null) {
>>> 1064
>>> 1065             GraphicsConfiguration gc = 
>>> c.getGraphicsConfiguration();
>>> 1066             AffineTransform tx = (gc == null) ? null : 
>>> gc.getDefaultTransform();
>>>
>>>
>>> if it is only in some case such as where Swing is rendering in 
>>> headless mode that should be OK
>>     It happens when a size of a component is requested but the 
>> component has not been added to a frame yet. This is a case where a 
>> text component size can differ before it is added to a frame and 
>> after that.
>
> I do not know the flow here but it seems like you need to be careful 
> that anything
> dependent on this needs to be updated once the component is added to a 
> parent.

   It is covered by the changes in PlainView.updateMetrics() method.

   Thanks,
   Alexandr.
>
>
> -phil.
>
>>
>>   Thanks,
>>   Alexandr.
>>>
>>> -phil.
>>>
>>> On 05/04/2016 10:42 PM, Alexandr 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/webrev.02
>>>>
>>>>   Swing uses a font rendering context which does not take the 
>>>> graphics configuration transform into account.
>>>>   This lead to the situation when text size is measured by one font 
>>>> rendering context and drawn by another. As the result the 
>>>> calculated text size can differ from the drawn text size.
>>>>
>>>>   For this issue it means that a cursor position can be farther 
>>>> away from the char position.
>>>>
>>>>   This is the initial fix where graphics configuration transform is 
>>>> included into the Swing font rendering context.
>>>>
>>>>   There is one more issue related to the fact that glyph advances 
>>>> are calculated in dev space and then transformed to the user space. 
>>>> Char width can have fractional value in user space if dev transform 
>>>> is not identity.
>>>>   It means that Swing should be able to draw a cursor at or select 
>>>> a text from a fractional position.
>>>>   These issues will be considered in separated fixes.
>>>>
>>>>  Thanks,
>>>>  Alexandr.
>>>>
>>>
>>
>




More information about the swing-dev mailing list