dompdf / php-svg-lib

SVG file parsing / rendering library
GNU Lesser General Public License v3.0
1.4k stars 77 forks source link

tspan tags are ignored when parsing text #64

Open nsorin opened 3 years ago

nsorin commented 3 years ago

Hello,

I am trying to display SVG images with text in them in using dompdf (which depends on this library for SVG rendering). Some of my text is divided into <tspan> elements, because it is too long to be displayed in a single line. In a browser, the image is rendered correctly. In dompdf, however, the text is displayed in a single line. For example the following <text> tag:

<text x="10" text-anchor="start" class="highcharts-caption" data-z-index="4" style="color:#666666;font-size:11px;fill:#666666;" y="368">
    <tspan>This is an example text. The text is too long to be displayed in a single line, so it has to be</tspan>
    <tspan dy="14" x="10">broken down into multiple parts using the tspan tag.</tspan>
</text>

is displayed as:

"This is an example text. The text is too long to be displayed in a single line, so it has to bebroken down into multiple parts using the tspan tag."

As you can see, the line break is ignored. "be" and "broken" end up merged together.

I used a debugger to look into how this library handles the text, and it turns out the <tspan> tag is not recognized at all. It is simply removed from the text. Which means my previous example is interpreted as:

<text x="10" text-anchor="start" class="highcharts-caption" data-z-index="4" style="color:#666666;font-size:11px;fill:#666666;" y="368">
This is an example text. The text is too long to be displayed in a single line, so it has to bebroken down into multiple parts using the tspan tag.
</text>

The <tspan> Tag is part of the SVG specification and should not be ignored by this library. Any chance for a fix?

Thank you for the support.

c-ancia commented 2 years ago

Hi there,

We are also experiencing these two issues, the tspan text of our SVGs are either not at the appropriate place or their font size is too small to be readable.

Do you have an ETA on a fix please? I don't mean to be pushy, I am just trying to assess what is the best course of action for us. :)

Many thanks!

bsweeney commented 2 years ago

Sorry to say I don't have an ETA at this time.

c-ancia commented 2 years ago

Thanks for letting me know, at least we can take a decision from this and we'll just follow the progress on this issue. 👍🏻

fateenarinah commented 3 months ago

Any progress on this? I'm experiencing the same issue.