Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6760148
Votes 0
Synopsis Certain fonts are not correctly soft wrapped when using JTextComponent.print()
Category java:classes_swing
Reported Against b30
Release Fixed 6u14(b03)
State 11-Closed, Verified, bug
Priority: 3-Medium
Related Bugs 6818231 , 6832120
Submit Date 16-OCT-2008
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
Posted Date : 2008-10-16 11:04:50.0
Work Around
N/A
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
Posted Date : 2008-11-10 16:07:15.0

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.
Posted Date : 2009-01-20 12:30:57.0
Comments
  
  Include a link with my name & email   

Submitted On 28-JUL-2009
uvoigt
The fix of this problem produces a new severe bug  6828938. An ArrayIndexOutOfBoundsException is thrown in some cases now. Please revert this fix.



PLEASE NOTE: JDK6 is formerly known as Project Mustang