Page MenuHomePhabricator

Incorrect text positioning in SVG with tspan element and text-anchor attribute
Open, Needs TriagePublic

Description

LibRsvg seems not apply the text-anchor attribute (middle, end) if a tspan child-element, except of the last one, has an absolute dimension (x/y) value.
This case seems very rare, if not a program like ChemDraw 12 would produce such code.
(As mentioned at https://commons.wikimedia.org/wiki/Commons:Graphics_village_pump#Problem_rendering_chemical_structures)

Upstream ticket: https://gitlab.gnome.org/GNOME/librsvg/-/issues/651

Event Timeline

Perhelion raised the priority of this task from to Lowest.
Perhelion updated the task description. (Show Details)
Perhelion updated the task description. (Show Details)
Perhelion set Security to None.
Perhelion updated the task description. (Show Details)Apr 25 2015, 9:01 PM
Perhelion updated the task description. (Show Details)Apr 25 2015, 9:14 PM
Perhelion added a comment.EditedApr 26 2015, 11:08 AM

I'm not sure about to handle this bug, because librsvg is used for speed. This seems more a bad and rare code from ChemDraw (anyway there could be more). As we can see LibRsvg pass all the W3C text-anchor test (with except of text on path and vertical, more than Chrome 42 which don't pass one test):

ChemDraw workaround (posted by Leyo): "I get the best results, if I first save the structure as .eps. I then convert the .eps to .svg using Scribus."

That's still an issue with librsvg 2.40.16, it renders the attached SVG like this: https://people.wikimedia.org/~jmm/svg/alanin.png

Perhelion added a subscriber: MartinK.EditedAug 31 2016, 9:26 PM

I mean now this is a bug of ChemDraw, because the text-tag needs x/y values (after W3C specifikation). (As this issue was newly reported on the German SVG-Projekt. https://de.wikipedia.org/wiki/Wikipedia_Diskussion:WikiProjekt_SVG#Chemdraw_Dateien) The browser and editor interpretation seems only fallback fault tolerance calculating.
@MartinK has created an JS-tool to fix such files: http://tools.martinkraft.com/fixChemdrawSvg.html.

AntiCompositeNumber raised the priority of this task from Lowest to Needs Triage.Oct 14 2020, 4:29 PM
AntiCompositeNumber added a project: Thumbor.

This issue still occurs in librsvg 2.44.10:


The file has even more problems in librsvg 2.50.1:

I could not find an upstream bug report for this

Aklapper updated the task description. (Show Details)Sat, Nov 21, 8:40 PM
Aklapper moved this task from Backlog to Upstream (librsvg) on the Thumbor board.Tue, Nov 24, 8:09 AM