CairoSVG icon indicating copy to clipboard operation
CairoSVG copied to clipboard

Problem with rendering text

Open vincentfpgarcia opened this issue 1 year ago • 1 comments

Here is an input SVG image: https://upload.wikimedia.org/wikipedia/commons/7/7d/Roll_pitch_yaw_mnemonic.svg

When rendering it, the text is off:

output_cairosvg

The SVG code contains 2 tspan tags nested within a text tag. By removing one tspan, the text displays correctly.

As pointed https://stackoverflow.com/questions/78807441/problem-with-text-rendering-using-cairosvg/78807953?noredirect=1#comment138959543_78807953, the problem might come from a bug in the interpretation of the text-anchor: middle style.

vincentfpgarcia avatar Jul 31 '24 12:07 vincentfpgarcia

the problem might come from a bug in the interpretation of the text-anchor: middle style.

Yes, that’s exactly the problem.

As the bug doesn’t happen in WeasyPrint, that uses a code that’s close to CairoSVG’s code, I think that it’s fixed by https://github.com/Kozea/WeasyPrint/commit/1460522596d6b14d8bd959f8d89651839da3168c in WeasyPrint.

Would you like to try to backport it?

liZe avatar Jul 31 '24 15:07 liZe