Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering issue with <tspan> and <style> #343

Open
jspobst opened this issue May 19, 2022 · 4 comments
Open

Rendering issue with <tspan> and <style> #343

jspobst opened this issue May 19, 2022 · 4 comments

Comments

@jspobst
Copy link

jspobst commented May 19, 2022

A plotly figure I made isn't rendering correctly. The part that's failing involves a <tspan>, so I went and grabbed the simplest tspan example I could find from here to test further.

<svg viewBox="0 0 240 40" xmlns="http://www.w3.org/2000/svg">
  <style>
    text  { font: italic 12px serif; }
    tspan { font: bold 10px sans-serif; fill: red; }
  </style>

  <text x="10" y="30" class="small">
    You are
    <tspan>not</tspan>
    a banana!
  </text>
</svg>

That should produce
image

But when putting it through

drawing = svglib.svg2rlg(io.StringIO(textwrap.dedent(svg_string)))
renderPDF.draw(drawing, c, 50, 50)

I get this in the produced pdf
image

svglib: 1.3.0
reportlab: 3.6.9
python: 3.97
MacOS: 12.3.1

Thank you.

@github-actions
Copy link

Thank you for raising your first issue! Your help to improve svglib is much appreciated!

@jspobst
Copy link
Author

jspobst commented May 19, 2022

Given that no text after not shows, it almost seems as though the </tspan> is somehow closing the <text>.

claudep added a commit to claudep/svglib that referenced this issue May 19, 2022
@claudep
Copy link
Collaborator

claudep commented May 19, 2022

In #344, I tried to solve the issue of the trailing part of text nodes. The rendering of the sample above is not yet optimal, but at least it seems all text appear.

claudep added a commit to claudep/svglib that referenced this issue May 19, 2022
claudep added a commit to claudep/svglib that referenced this issue May 19, 2022
claudep added a commit to claudep/svglib that referenced this issue May 19, 2022
@jspobst
Copy link
Author

jspobst commented May 20, 2022

Hi @claudep, I see that this isn't optimal just yet, but I wanted to say thanks for the work you've already put into it so quickly. It really is appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants