Arabic Text with TextLayout on Mac OS X Has Broken Implementation
843807Aug 2 2006 — edited Aug 9 2006Hi all,
I discovered this problem while testing an application I am developing on Mac OS X. I have posted this as a bug report on the Apple Developer's network system, though I am not sure if it is an Apple bug or a Java bug. Thus I'm repasting my report below. The original version is viewable here if you have an Apple developer account: ( https://bugreport.apple.com/cgi-bin/WebObjects/RadarWeb.woa/5/wo/E0Y6M4TmVK0fbJva7JpN1w/3.33.26.0.3 )
31-Jul-2006 03:10 PM Yaman Salahi:
Summary:
This is a problem that is specific to Mac OS X, and the same application when tested on Windows XP and Linux do not have this bug. Therefore, the error should be with the implementation of Java on Mac OS X.
When an AttributedString is created using Unicode characters in the Arabic subset, and properties such as color are added, the proper ligatures are not assembled and rendered. Rather, substrings of different colors are treated as if they do not connect to each other, although they do.
Steps to Reproduce:
(1) Create a basic Java application that simply opens a Window using Swing API, or an Applet, as long as there is a Graphics2D context available for drawing.
(2) Insert the following code into the method that draws
public void draw(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
String arabicHello = "\u0627\u0647\u0644\u0627";
AttributedString astr_linked = new AttributedString(arabicHello);
AttributedString astr_broken = new AttributedString(arabicHello);
astr_broken.addAttribute(TextAttribute.FOREGROUND, Color.red, 0, 1);
astr_broken.addAttribute(TextAttribute.FOREGROUND, Color.green, 1, 2);
astr_broken.addAttribute(TextAttribute.FOREGROUND, Color.blue, 2, 3);
FontRenderContext frc = g2d.getFontRenderContext();
TextLayout broken = new TextLayout(astr_broken.getIterator(), frc);
TextLayout linked = new TextLayout(astr_linked.getIterator(), frc);
broken.draw(g2d, 50, 50);
linked.draw(g2d, 50, 100);
}
(3) Compile and execute the code and notice that the Arabic script in the lower line connects properly, but that the Arabic script in the upper line is completely disconnected with some characters overlapping.
Expected results:
The expected result would be that both drawn Strings, upper and lower, display the same glyphs but with different color patterns.
Actual results:
The Strings drawn appear different though they contain the same character content.
Regression:
This problem occurs only under Java (of all versions, as far as I know--though I have only tested on 1.4.2 and 1.5.0) on Mac OS X. The problem does NOT occur on Windows XP or Linux.
Notes:
I have no additional information at this time, however I am certain that the issue is a problem with the Mac OS X implementation of TextLayout for Java.