JDK-5087395 : Repainting text at non-integral positions can be off-by-one pixel.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 5.0,5.0u1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2004-08-16
  • Updated: 2012-10-09
  • Resolved: 2004-10-26
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.
Other JDK 6
5.0u2Fixed 6 b10Fixed
Description
Name: gm110360			Date: 08/16/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-
Java HotSpot(TM) Client VM (build 1.5.0-beta3-b60, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

EXTRA RELEVANT SYSTEM CONFIGURATION :
graphics card : GeForce 4 nv 440

A DESCRIPTION OF THE PROBLEM :
(seems to be related to 4967352 but not sure)

Wrong display of text in JeditorPane when displayed in a JScrollPane
When moved Vertically some of the text will become very ugly and some letters are wrongly positioned. This bug seems to appear only when bidi text is introduced.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
use the given code with the test html and move down and up slowly and fast and you will see the problem (I will send you a png with the problem described)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
text displayed correctly
ACTUAL -
text display unconsistently way when moved up and down

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error message are given

REPRODUCIBILITY :
This bug can be reproduced often.

---------- BEGIN SOURCE ----------
java code :
import javax.swing.*;
import java.io.*;
public class JEditorTestCase{
    
    public static void main(String[] args){
         JFrame frame = new JFrame("test frame");
         try{
        frame.getContentPane().add(new JScrollPane(new JEditorPane("file:c:/test.html")));
         }
         catch(IOException ioe){
             ioe.printStackTrace();
         }
         frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
         frame.setSize(300,600);
         frame.setVisible(true);
    }
    
}


html code : (test.html)

<html>
 <head>
 <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=WINDOWS-1255">
 </head>
 <body bgcolor="F9F5F0" style="padding-right: 10px;" align="right" dir="rtl">
    <b><u> Simple test Html test case English part : </u> </b>
     <br>
     This is a test for Wrong display of text in JeditorPane when displayed in a JScrollPane
     <br>
     When moved Vertically some of the text will become very ugly and some letter are wrongly positionned.
     <br>
     <b> This bug seems to appear only when bidi text are introduced.
      <br>
      For that reason Hebrew text are inserted at the end .
     </b>
     <br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
<br>
     These two line are reproduced
     <br>
     a lot of times to give the user the the ability to scrool Verticaly
     <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506; &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
&#1500;&#1488;&#1495;&#1512; &#1502;&#1499;&#1503; &#1497;&#1513; &#1500;&#1492;&#1511;&#1500;&#1497;&#1511; &#1506;&#1500; &#1492;&#1499;&#1508;&#1514;&#1493;&#1512; "&#1495;&#1508;&#1513;" &#1493;&#1492;&#1502;&#1495;&#1513;&#1489; &#1497;&#1510;&#1497;&#1490; &#1488;&#1514; &#1512;&#1513;&#1497;&#1502;&#1514; &#1492;&#1514;&#1493;&#1510;&#1488;&#1493;&#1514;. &#1489;&#1495;&#1497;&#1512;&#1492; &#1489;&#1488;&#1495;&#1514; &#1502;&#1492;&#1503; &#1514;&#1493;&#1489;&#1497;&#1500; &#1500;&#1510;&#1508;&#1497;&#1492; &#1489;&#1502;&#1511;&#1496;&#1506;
###@###.### 10/5/04 23:36 GMT
 &#1488;&#1493; &#1489;&#1506;&#1502;&#1493;&#1491; &#1492;&#1502;&#1514;&#1488;&#1497;&#1501; &#1489;&#1505;&#1508;&#1512;.
  <br>
 </body>
</html>
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
No bypass
(Incident Review ID: 297164) 
======================================================================

Comments
EVALUATION The only difference I can think of here from latin text here is Bidi text is a little slower (it needs to go through layout), but that is already completed before rendering which should then be no different. Something about the graphics card could be relevant, and I can't reproduce this on an Nvidia card (Quadro 9600) and Nvidia cards share a common driver, so the driver version would be useful information (please provide that information). Also useful would be to test what happens when the test case is run with -Dsun.java2d.noddraw=true please add that information too. Also I can't reproduce it on an ATI Radeon on XP, nor for that matter can I reproduce it on Solaris SPARC. ###@###.### 2004-08-16 ============================ I eventually saw the problem and its a tiger only bug. I've created a refinement of the test case below which is a little more straightforward. If you run it on solaris or windows and verically scroll slowly you'll see occasional places where a horizontal line of pixels comes into display duplicated. It only happens if Bidi text is in there. It happens with or without double-buffering. Causing the text to be repaired by for example selecting it repairs the damage. The Bidi Hebrew text is only important since it causes the text to be drawn (and presumably under the deliberate control of Swing, to be measured) using TextLayout. Once the test cases is running the same problem can be seen even if you edit out (manually) the hebrew text. [[Seems like Swing notices when to start using TextLayout in a text component but never reverts]] It started very close to the time we did the font rearchitecture so something that changed there is almost certainly triggering it, but its not clear if its really a problem in TextLayout My guess (and the maintainer of the TextLayout class agrees) is that the editor pane is somehow accumulating line heights to decide what to paint where and floating point rounding error is contributing to this, so sometimes the calculation rounds differently. This sounds then like a latent bug in the text components, but we don't know how Swing's text components is doing this calculation. This bug is being referred to the maintainer of the swing text classes, to pinpoint how this presumed rounding error is occurring. With that info we can then decide how the bug should be further handled import java.awt.*; import javax.swing.*; public class JTextTestCase { public static void main(String[] args) { String ls = System.getProperty("line.separator"); String theText = "Scrolling corruption test case"+ls; for (int i=0;i<100;i++) { String number = Integer.toString(i+1); String line = number+" some text that can be scrolled up and down"; theText+=line+ls; } theText+="\u05d4\u05de\u05ea\u05d0\u05d9\u05dd \u05d1\u05e1\u05e4\u05e8."; JFrame frame = new JFrame("test frame"); RepaintManager rpm = RepaintManager.currentManager(frame); rpm.setDoubleBufferingEnabled(false); JEditorPane pane = new JEditorPane("text/plain", theText); pane.setFont(new Font("serif", Font.PLAIN, 14)); frame.getContentPane().add(new JScrollPane(pane)); frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); frame.setSize(350,600); frame.setVisible(true); } } ###@###.### 2004-08-26 ============================ this bug is not a showstopper for tiger. will work on this one for the next release ###@###.### 2004-08-27 ============================ The same problem without using editor pane: === ScrollTest.java import java.awt.*; import java.awt.font.*; import javax.swing.*; class ScrollTest { public static void main(String[] args) { SwingUtilities.invokeLater( new Runnable() { public void run() { initGUI(); } }); } static void initGUI() { JFrame frame = new JFrame("scrolling test"); frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); frame.add(new JScrollPane(new TextPanel())); frame.setSize(350,600); frame.setVisible(true); } static class TextPanel extends JPanel { public TextPanel() { super(); initText(); setPreferredSize(new Dimension(300, (int)rowY[rowY.length - 1] + 50) ); } public void paintComponent(Graphics g) { super.paintComponent(g); Insets insets = getInsets(); Graphics2D g2d = (Graphics2D)g; for (int i = 0; i < textRows.length; i++) { TextLayout layout = textRows[i]; //from javax.swing.text.GlyphPainter2.paint float y = rowY[i] + layout.getAscent() + layout.getLeading(); layout.draw(g2d, insets.left, (float)insets.top + y); } } private void initText() { textRows = new TextLayout[100]; rowY = new float[textRows.length + 1]; rowY[0] = 0; FontRenderContext frc = new FontRenderContext(null, false, false); Font font = new Font("serif", Font.PLAIN, 14); for (int i = 0;i < textRows.length;i++) { String number = Integer.toString(i+1); String line = number + " some text that can be scrolled up and down"; TextLayout layout = new TextLayout(line, font, frc); textRows[i] = layout; //from javax.swing.text.GlyphPainter2.getHeight float height = layout.getAscent() + layout.getDescent() + layout.getLeading(); rowY[i + 1] = rowY[i] + height; } } TextLayout textRows[]; float rowY[]; } } === we always draw same TextLayout at the same origin. I think this bug is due to rounding erros in TextLayout. As a workaround for swing I could suggest rounding origin before layout.draw For ScrollTest.java it would be float y = (float)Math.ceil(rowY[i] + layout.getAscent() + layout.getLeading()); instead of float y = rowY[i] + layout.getAscent() + layout.getLeading(); Transferring this bug to java2d for further investigation ###@###.### 2004-08-27 =================================== The problem is that 1.5 is missing a call to floor() that was present in 1.4.x That is relevant when using Graphics2D APIs which draw text at a non-integral position, eg drawString(String,float,float), and when rendering on the screen this needs to be rounded to pixels. Without the call to floor() it is always rounded towards zero. In some rare cases, which have only been seen to manifest in Swing UIs, because of a translation on the Swing back buffer, this results in the y position being negative. Floor rounding towards zero thus rounds "up", not "down". ie -2.7 becomes -2.0 instead of -3.0. So text can be painted one pixel offset from where it should be. This is not observable on a full repaint, but is observable on scroll or damage repaints. It doesn't affect typical GUIs, but does affect Swing when it uses TextLayout (as Swing doesn't round), or apps which use floating point directly, or scale the graphics non-integrally. ###@###.### 2004-10-01 ============================ ###@###.### 10/5/04 23:36 GMT
01-10-2004