Hi Prasanta,

Hi Prasanta,

It seems another global issue was missed during this bug evaluation. After HiDPI support is introduced all text UIs need to receive notifications about graphics configuration update as about font change. This is because another GC scale changes font size but since symbols and spaces are not scaled linearly the text layout should be fully refreshed with the new GC.

--Semyon


On 10/17/2017 03:48 AM, Prasanta Sadhukhan wrote:


On 10/17/2017 10:22 AM, Prasanta Sadhukhan wrote:


On 10/17/2017 1:08 AM, Sergey Bylokhov wrote:
On 16/10/2017 02:50, Prasanta Sadhukhan wrote:
Probably this is a root cause of the bug?
Does not seem like. If we only use floating point API getTabbedTextWidth() in GlyphPainter1.getSpan() to get floating point width, it calls SwingUtilities2.getFontStringWidth() which calls getStringBounds() with default FRC. When getStringBounds() calls fm.getFontRenderContext(), it returns DEFAULT_FRC which has a null AffineTransform so when we try to get the transform for that through getTransform(), it creates a new AffineTransform with scale 1
public AffineTransform getTransform() {
         return (tx == null) ? new AffineTransform() : new AffineTransform(tx);
     }

So this is a problem why default FRC is used. We should find a way to create a correct one instead.
I guess that is what I did which is to create a FRC with correct transform .

When JLabel with html tag span is created, GlyphPainter1.getSpan() calls sync() which finds JLabel.getFontMetrics() which calls SwingUtilities2.getFontMetrics which calls getFRCProperty() and it tries to find JLabel.getGraphicsConfiguration() which comes out to be null so affinetransform also becomes null.
AffineTransform tx = (gc == null) ? null : gc.getDefaultTransform();

It seems for JLabel, Component.updateGraphicsData() with proper GraphicsConfiguraiton is never called which it does for JTextComponent or JDialog. Do you know why? Because of this, correct FRC is not created.
I am not sure what else I can do to create correct FRC.
Regards
Prasanta

It will apply the screens scale to the FRC even if the component is located on some other screen.
I was of the opinion that this

GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getDefaultTransform().getScaleX()

will give the scale factor as passed to sun.java2d.uiScale which should be applicable for all screen(s), which is what I leveraged in my fix.

The "sun.java2d.uiScale" is a debug option which applies the scale on all screens, but in case of the common configuration it is possible to have different scales(example: hidpi laptop + lowdpi external screen).

GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getDefaultTransform().getScaleX() Will returns default transform for default configuration of the main/default screen.




Reply via email to