<Swing Dev> [10] RFR JDK-8178025:HiDPI with non-integer scale factor - SPANs in HTML are rendered overlapping each other
Sergey Bylokhov
Sergey.Bylokhov at oracle.com
Mon Oct 16 19:38:09 UTC 2017
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.
>> 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.
--
Best regards, Sergey.
More information about the swing-dev
mailing list