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

Bug 354121

Summary: Positionning of text contained in svg files is not correct
Product: z_Archived Reporter: joel <joel.moreau>
Component: BIRTAssignee: Birt-ReportEngine-inbox <Birt-ReportEngine-inbox>
Status: NEW --- QA Contact: Maggie Shen <lshen>
Severity: normal    
Priority: P3 CC: bluesoldier, vladk.dev
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
svg file to import as an image
none
powitionning with birt
none
correct positionning with Mozilla none

Description joel CLA 2011-08-08 06:12:52 EDT
Build Identifier: Build id: 20110615-0604

The psoittionning of texts contained in svg files is not correct.
In fact, it seems that birt doesn't take in account the flag
style="dominant-baseline: text-before-edge" which indicate  the positionning of the txt relatively to the position

I will join the foolowing parts:
1/ p1.svg ( the svg to test)
2/ new_report_birt.pdf ( the result in birt)
3/ mozilla.jpg : the visu when mozilla opens the svg ( correct positionning)


Reproducible: Always

Steps to Reproduce:
1.Create a simple birt project
2.add an image
3.select p1.svg file ( set the dimensions in mm to see better)
4.generate the pdf file
Comment 1 joel CLA 2011-08-08 06:14:14 EDT
Created attachment 201066 [details]
svg file to import as an image
Comment 2 joel CLA 2011-08-08 06:15:05 EDT
Created attachment 201067 [details]
powitionning with birt
Comment 3 joel CLA 2011-08-08 06:15:57 EDT
Created attachment 201068 [details]
correct positionning with Mozilla
Comment 4 vlad dev CLA 2013-11-05 03:40:08 EST
The issue is caused by the fact that the SVG feature set supported by Batik is limited. The following page shows what SVG features are supported: http://xmlgraphics.apache.org/batik/status.html

As you can read the "dominant-baseline" attribute is not supported for "svg:text" elements and texts are displayed with "dominant-baseline=alphabetic".

To overcome this issue, you would have to transform SVG files to replace "dominant-baseline=text-before-edge" by "dominant-baseline=alphabetic". Of course, you will have to recalculate coordinates of the text box to make the text appear at the same place. For that you will have to know the height of the font:
yShift = font ascent
Comment 5 vlad dev CLA 2013-11-05 05:56:31 EST
The following page describes how the "text-before-edge -> alphabetic" transformation could be performed:
http://stackoverflow.com/questions/14461735/dominant-baselinetext-before-edge-equivalent-dy-transformation