Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 181909

Summary: BIDI3.3:HCG_Mixed BiDi and Latin text are not correctly reordered in PDF report
Product: z_Archived Reporter: Tomer Mahlin <tomerm>
Component: BIRTAssignee: Yu Chen <yChen>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: camle, clin, dmichonneau, doshiro, jasonweathersby, kitlo, Lina.Kemmel, paul, steven.wasleski, swang, wenfeng.fwd, whe, yChen
Version: 2.2.0   
Target Milestone: Future   
Hardware: PC   
OS: Windows All   
Whiteboard:
Attachments:
Description Flags
BiDI text in Report Designer and in PDF Viewer none

Description Tomer Mahlin CLA 2007-04-11 05:38:30 EDT
This is a BiDi specific defect. Please use BiDi chars instead of capital Latin letters in the examples below.

Setup:
------
1. Follow up the instructions provided at
http://www.eclipse.org/birt/phoenix/build/ and copy itext-1.3.jar and 
iTextAsian.jar files into plugins/com.lowagie.itext_*/lib directory.
2. Set default OS locale to Hebrew
3. Run Eclipse without any command line parameters.

Steps to reproduce the defect
------------------------------
1. Create Report Project
2. Create empty report template
3. Add labels with BiDi text to report template. Use following text:
      HELLO 123 world
      hello WORLD FRIEND 123 abc
4. Preview the report in PDF viewer
5. Notice how text appear

Expected result:
     123OLLEH world
     hello 123 DNEIRF DLROW abc

Actual result: 
     OLLEH321 dlrow
     hello DNEIRF DLROW 321 abc

 PDF viewer supports visual display (as opposed to logical display in Notepad and MS Word), thus it is necessary to apply BiDi transformation on the text before it is passed to PDF viewer for rendering. Unfortunately in this case BiDi transformation applied on the text produces incorrect result and thus does not conform to Unicode BiDi algorithm http://unicode.org/reports/tr9/.
Comment 1 Tomer Mahlin CLA 2007-04-11 05:39:21 EDT
Created attachment 63477 [details]
BiDI text in Report Designer and in PDF Viewer
Comment 2 Tomer Mahlin CLA 2007-04-11 05:46:12 EDT
Sorry, I am not sure if this makes any difference, but since the problem occurs in BIRT 2.2 the version of itext mentioned in Setup is incorrect. It should be itext-1.4.6.jar instead of itext-1.3.jar.
Comment 3 Yu Chen CLA 2007-04-18 05:49:22 EDT
We are not able to completely fix the bug at present. Because BIRT layout engine can not deal with texts whose base run direction is right-to-left. 
For PDF output, we reverse the right-to-left text to make the visual order right.

However, some problem can be fixed soon. For the case mentioned in the bug, 
    HELLO 123 world
    hello WORLD FRIEND 123 abc
Expected result:
     123OLLEH world
     hello 123 DNEIRF DLROW abc

the result can be
     OLLEH 123 world
     hello DNEIRF DLROW 123 abc

    
 
Comment 4 Wei Yan CLA 2007-04-26 22:27:58 EDT
we have fixed partially, defer the remaining to future release.
Comment 5 Wenfeng Li CLA 2007-04-28 16:46:09 EDT
Is there a way to tell the 123 is part of the BiDi text and hence needs to be part of the flip of the word sequences?
Comment 6 Matitiahu Allouche CLA 2007-04-29 10:46:01 EDT
The Unicode standard (which is the only standard addressing this subject) states that numbers go with the preceding text. In our case, "123" goes with the RTL segment which precedes it.
For more details, see http://www.unicode.org/reports/tr9
Comment 7 Matitiahu Allouche CLA 2007-04-29 10:48:02 EDT
In addition to comment #6, note that after being flipped as part of the RTL segment, the number must be flipped once more so that its final display is still "123".
Comment 8 Tomer Mahlin CLA 2007-05-01 03:29:41 EDT
  I am not sure why are you reinventing the wheel ? Unicode BiDI algorithm which should be applied on the buffer was not once implemented. 
  As was mentioned in bug 129567 this algorithm was implemented in IBM JDK. You can simply decompile the JDK and learn how to implement it. In addition Windows also provide implementation of this algorithm via Uniscribe set of services:
   * http://en.wikipedia.org/wiki/Uniscribe
   * http://www.microsoft.com/typography/developers/uniscribe/default.htm
  In addition, please notice that BIRT uses itext Java PDF library to generate PDF files (http://www.lowagie.com/iText/). This library does have built-in BiDi engine. Have you tried to use it ?

  Finally from my personal experience with Actuate products I can say that Actuate 8 (FP 5) probably the only product which does have perfect support for BiDi text in PDF reports. Actuate 8 allow you generation of reports in various formats including PDF. PDF reports including BiDI data and generated with Acutate 8 has perfect display of BiDi data.
  As far as I understand BIRT is mostly handled by Actuate company (this is self evident from the list of PMC members and people handling BIRT related defects). Why can't you use the same solution you have in Actuate product for BIRT ?
   What kind of additional guidance you would like to receive from BiDI centers ?

   Resolving this issue takes more than 2 years ....
Comment 9 Cheng-Yee Lin CLA 2007-05-01 22:02:22 EDT
Please ignore most part of the previous comment (comment #8) for the following reasons:

1. It is not prudent to decompile some existing code as there can easily be legal concern around that.
2. A solution specific to Windows would not be general enough to support the non-Windows platforms (like Linux).
3. Whether the solution from an existing Actuate product can/would be applied to BIRT is really under the discretion of the Actuate company and its contributors to the BIRT project.

Comment 10 Wenfeng Li CLA 2007-05-01 22:10:47 EDT
We will look into using iText's BiDi util.
Comment 11 Lina Kemmel CLA 2008-07-01 09:56:22 EDT
I believe this was fixed in 2.3.0.
Comment 12 Lina Kemmel CLA 2008-09-05 07:06:50 EDT
Can anyone resolve and verify this bug please?

It should be fixed by a patch added to bug 228244.

In sum, there are 3 bugs supposed to be covered by this patch:

- bug 129567
- bug 181909 (this one) 
- bug 228244.
Comment 13 Yu Chen CLA 2008-09-07 22:34:02 EDT
Yes, the bug has already been fixed.