JDK-6760148 : Certain fonts are not correctly soft wrapped when using JTextComponent.print()
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u10
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-10-16
  • Updated: 2012-10-01
  • Resolved: 2009-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6-poolResolved 7Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
When printing, the letters at the end of the line are sometimes truncated when soft wrap is activated. This happens for all platforms and all printers. It is also independent of configured printer magins/borders.
Interestingly the issue does not happen for all font sizes. There seems to be some mathematical miscalculation.
To reproduce, run the attached test program. Try various fonts. it looks that the issue
is present with sizes 6, 8, 11, 13, 15, und 17 while it is not with sizes 7, 9, 10, 12, 14, 16, 18, 19 and 20

Comments
SUGGESTED FIX http://sa.sfbay.sun.com/projects/swing_data/6u14/6760148.0
24-02-2009

EVALUATION When fractional metrics are enabled on the FontRenderContext (as in the case of printing), the length of the rendered string, calcualted as a whole, may be different than the sum of the lenghts of the individual characters. For some font sizes the lenght of the whole string is bigger, for some it is smaller. Line breaking mechanism implemented in JTextArea finds breakpoints analyzing a string character-by-character. Character drawing mechanism, OTOH, draws the string as a whole. So, when the lenght of the string as a whole is bigger than the sum of the lenghts of the individual characters, a line gets clipped. The solution is, when a breakpoint is found, to check that the lenght of the string-as-a-whole does not exceed the calculated breakpoint distance, and if it does, clip characters from the breakpoint until the lenght fits.
20-01-2009

EVALUATION I reproduced this problem with font size #8 and made sure that it is not reproduced with font size #9 on Windows XP, anyway this looks like a platform independent problem assigned to the text team
10-11-2008