<Swing Dev> [10] RFR JDK-8178025:HiDPI with non-integer scale factor - SPANs in HTML are rendered overlapping each other
Prasanta Sadhukhan
prasanta.sadhukhan at oracle.com
Mon Oct 16 09:50:45 UTC 2017
Hi Sergey,
On 10/14/2017 6:40 AM, Sergey Bylokhov wrote:
> Hi, Prasanta.
>
> On 11/10/2017 02:43, Prasanta Sadhukhan wrote:
>> Issue was, when a JLabel with an html text is created, the
>> GlyphPainter1.getSpan() uses a FontrenderedContext with transform
>> scale 1
>> and also the obtained width is converted to int and not to float.
>
> 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);
}
> FontrenderedContext is an abstraction which encapsulate information
> about text attributes for some specific surface such as screen,
> window, etc. If the label or any other components will use some FRC
> for rendering then the same FRC should be used for font size
> measurement. So why the scale is 1?
>
>> Proposed fix is to use correct transform while calculating the string
>> width and also use floating point API to get floating point width.
>
> 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.
>
>
Regards
Prasanta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20171016/52131e40/attachment.html>
More information about the swing-dev
mailing list