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

Bug 328166

Summary: Composite Characters are displayed incorrectly
Product: [Modeling] GMF-Runtime Reporter: Alex Boyko <aboyko>
Component: GeneralAssignee: Alex Boyko <aboyko>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ahunter.eclipse, lgrahek
Version: 2.3.1   
Target Milestone: 1.4.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
diagram that demonstrates the issue
none
possible fix none

Description Alex Boyko CLA 2010-10-19 13:56:37 EDT
Created attachment 181210 [details]
diagram that demonstrates the issue

If a label has a non-latin string it's displayed fine on the diagram. However if it's exported to PNG or JPEG image via Batik, i.e. via AWT Graphics 2D and hence GMF's GraphicsToGraphics2DAdaptor the string can be displayed differently... characters may have a different size and the string may be cut-off.
Attached is the geo-shape diagram that demonstrates the issue on Win XP with no japanese fonts installed and on Win 7.
Comment 1 Alex Boyko CLA 2010-10-19 14:06:05 EDT
Created attachment 181211 [details]
possible fix

I figured that it's probably best to create an SWT bitmap of such string, convert the bitmap to AWT bitmap and then paint on AWT graphics.
The criteria determining whether a bitmap needs to be created or just paint the string is the comparison of AWT and SWT string widths. If the difference in width is more than 2 pixels then an SWT bitmap is created. Therefore, if japanese fonts are installed the string will just be painted with AWT graphics, otherwise the widths difference is over 2 pixels and a bitmap is created.
GraphicsSVG is a vector format consequently there is no need to create an SWT bitmap at all. Therefore the string is just added to the SVG DOM (regular painting) and it's up to the SVG rendering app to paint this correctly, i.e. Firefox.

Lidija, can you please review this patch and tell what you think?
Comment 2 Lidija Grahek CLA 2010-10-20 15:18:21 EDT
I am OK with the patch. As a workaround to the AWT issue, it is going to take a bit longer (for generating SWT bitmap) but it's either that or it doesn't work.
Comment 3 Alex Boyko CLA 2010-10-21 12:04:54 EDT
Delivered to R1_4_maintenance for GMF 2.3.2 and HEAD. Will see how this fix will work out for us.