<Swing Dev> [13] RFR JDK-8214702:Wrong text position for whitespaced string in printing Swing text

Prasanta Sadhukhan prasanta.sadhukhan at oracle.com
Thu Jan 24 10:18:00 UTC 2019


Hi All,

Please review a fix for an issue where it is seen that a string 
beginning with multiple whitespaces is displayed properly in Swing
component.

However, when printing, the start position of the line changes.

Basically,in SwingUtilities#drawString(), during printing,
  we calculate the screenWidth, obtain a TextLayout with advances for 
printer graphics FontRenderContext and then justify it to fit the entire 
width of screen.
It is seen that this justification of textlayout through 
TextLayout.getJustifiedLayout(screenWidth) is aligning the printed text 
wrongly.

Proposed fix is to check if we need text layouting for printing too as 
it is done for swing text drawing on console. If we need text layouting, 
then only use textlayout justification.

Bug: https://bugs.openjdk.java.net/browse/JDK-8214702
webrev: http://cr.openjdk.java.net/~psadhukhan/8214702/webrev.0/

Regards
Prasanta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/swing-dev/attachments/20190124/dc77a0b0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdlklgpcelmeeejc.png
Type: image/png
Size: 4135 bytes
Desc: not available
URL: <https://mail.openjdk.java.net/pipermail/swing-dev/attachments/20190124/dc77a0b0/gdlklgpcelmeeejc-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: omjcpnnpljnpmbff.png
Type: image/png
Size: 12087 bytes
Desc: not available
URL: <https://mail.openjdk.java.net/pipermail/swing-dev/attachments/20190124/dc77a0b0/omjcpnnpljnpmbff-0001.png>


More information about the swing-dev mailing list