JDK-4650042 : REGRESSION: AttributedString displayed incorrectly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-03-09
  • Updated: 2003-04-12
  • Resolved: 2002-09-16
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
1.4.2 mantisFixed
Related Reports
Relates :  
Description

Name: gm110360			Date: 03/08/2002


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

FULL OPERATING SYSTEM VERSION : Windows 2000 Professional
5.00.2195




A DESCRIPTION OF THE PROBLEM :
g2.drawString(as.getIterator(), X, Y) displays very
unexpected results. The Attributes of the ArrbiutedString
are not displayed correctly. Even when the AttributedString
has no attributes (i.e. no as.addAttribute(AAA,,BBB,X,Y) is
called), the string is displyed strangely:
1-All characters are displayed in capital.
2-Some characters are not displyed.
3-Characters are displayed in bold.
4-Some characters on the same line are a bit above or below
others.

Note: I tested this in the paint method in a Frame (AWT)
component and in a JFrame (Swing). Also note that when
trying to display an AttributedString in the paintComponent
method in a JFrame nothing is displayed.

This bug does not occur with JDK 1.3.0. I have not tested
it with JDK 1.3.1

REGRESSION.  Last worked in version 1.3

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
In the public void paint(Graphics g) for a Frame
1- define: Graphics2D g2 = (Graphics2D)g;
2- define: AttributedString as = new AttributedString(s);
3- (optional) add any attribute to the AttributedString by
    as.addAttribute(AAA, BBB, X, Y);
4-g2.drawString(as.getIterator(), x-coor, y-coor);

EXPECTED VERSUS ACTUAL BEHAVIOR :
The display of the AttributedString is expected to be
normal with the attributes (if any) also displayed
correctly. Because of this bug, the results are far from
normal.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
//////////////////////////////////////////////
//NOTE IF THE LINE BEGININNG WITH as.addAttribute IS UNCOMMENTED, THE FOLLOWING
//SHOULD BE DISPLAYED:
// a big number 7^11 (7 to the power of 11)
//THE BUG IS OCCURS WITH AND WITHOUT COMMENTING THAT LINE
/////////////////////////////////////////////

import java.text.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;

public class IteratorTest2 {
  static AffineTransform superTransform;
   
  public static void main(String[] args) {
    final Frame f = new Frame("IteratorTest v1.0") {
      public void paint(Graphics g) {
        Graphics2D g2 = (Graphics2D)g;
        superTransform = AffineTransform.getScaleInstance(0.65, 0.65);
        superTransform.translate(0, -7);
         TransformAttribute superAttribute = new TransformAttribute
(superTransform);
         String s = "a big number 7 11";
         Dimension d = getSize();
         AttributedString as = new AttributedString(s);
         //as.addAttribute(TextAttribute.TRANSFORM, superAttribute,15,17);
         //THE ABOVE LINE CAN BE UNCOMMENTED TO TEST THE ATTRIBUTE
  	 g2.drawString(as.getIterator(), 40, 180);
      }
    };
    f.setSize(500,400);
    f.setVisible(true);
    f.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        f.dispose();
        System.exit(0);
      }
    });
  
  }
  

}

---------- END SOURCE ----------

CUSTOMER WORKAROUND :
I have not found any workaround.

Release Regression From : 1.3.1_02
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Review ID: 139280) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis mantis-b02 FIXED IN: mantis mantis-b02 INTEGRATED IN: mantis mantis-b02
14-06-2004

EVALUATION Works in 1.3.1. ###@###.### 2002-03-18 The font substitution mechanism that TextLayout uses when no font is defined is not passing the transform along to the fonts that it creates. Not sure how this would have changed in JDK1.4 but apparently it did when Font was updated. ###@###.### 2002-05-06 Can't reproduce the other errors the submitter mentioned, but I can reproduce the fact that it ignores the transform. Originally, and as still documented in TextAttribute.java, TRANSFORM was intended to be a per-glyph transform with particular characteristics. But historically it's been interpreted by Font to be a rotation of the glyphs _and_ the baseline. So I'm just reenabling that behavior. We still have problems with the differences between TextLayout's interpretation of this attribute and Font's, this doesn't fix that. ###@###.### 2002-05-13 Just to elaborate, new Font(Map) was interpreting the TRANSFORM attribute, but deriveFont(Map) wasn't, and TRANSFORM wasn't listed as one of the supported attributes. Also (the original bug) FontResolver wasn't looking at the TRANSFORM attribute either. The inconsistencies are just too maddening. Since TRANSFORM doesn't do what it was originally spec'd to do, we might need to change the spec for TRANSFORM and provide a new attribute called CHAR_TRANSFORM for the original behavior. ###@###.### 2002-05-16
16-05-2002