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

SVGTextPath node not being rasterized when added as child of SVGText #213

Closed
liamjt95 opened this issue Jan 4, 2024 · 4 comments
Closed
Labels
duplicate This issue or pull request already exists

Comments

@liamjt95
Copy link

liamjt95 commented Jan 4, 2024

Description

I'm trying to create an SVG image that contains some curved text. Exporting my document as XML results in a successful SVG that looks correct.

<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="236.05" height="78.86"
     viewBox="98.48 265.39 236.05 78.86" style="fill: none">
    <path d="M 99.97623748074814 266.88704311777553 C 119.74920068227658 314.6231990472097 166.33075715003895 345.74800000000005 218 345.74800000000005 C 269.66924284996105 345.74800000000005 316.2507993177234 314.62319904720965 336.0237625192519 266.8870431177755"
          id="text-path" style="fill: none; stroke: none"/>
    <text x="0" y="0" style="fill: #04ADB2; font-size: 40; font-weight: 400; text-anchor: middle; ">

        <!-- Problem is here, as 'textPath' is a child node of 'text' -->
        <textPath href="#text-path" style="text-anchor: 'middle';" startOffset="50%">Test Text</textPath>

    </text>
</svg>

My issue is that I now want to export this to a PNG with some custom font files I have installed locally. When rasterizing my image, I cannot see that the SVGTextPath node is being rendered at all. Looking at the code, it seems there is no logic in either \SVG\Nodes\Texts\SVGText::rasterize to rasterize children or any logic in \SVG\Nodes\Texts\SVGTextPath::rasterize.

Just want to check if I am missing some implementation detail or whether rasterizing child text nodes/text path nodes has not been implemented yet (I'm aware this stuff is a work in progress!).

Thanks!

@Niellles
Copy link
Contributor

Niellles commented Feb 8, 2024

Looks like this was never implemented to me.

TextPath as a node was added in #42 , however, as you noted, without rasterization.

I don't want to speak for @meyfa, however I don't suspect this will be added soon, unless someone is willing to raise a PR. Your best bet, if you really need this, is probably to rasterize with Gmagick/Imagick.. or.. even better.. help fixing #98.

@Niellles
Copy link
Contributor

Niellles commented Feb 8, 2024

For more discussion, also see: #10.

Voting to close this is a duplicate.

@meyfa
Copy link
Owner

meyfa commented Feb 12, 2024

Agreed, #10 covers all text elements, including <textPath>. Text rasterization is notoriously difficult with GD and placing text on paths even more so. Someone needs to dedicate some time to implement this - I'll gladly review PRs. Thanks for the opening this issue, but closing as a duplicate.

@meyfa meyfa closed this as completed Feb 12, 2024
@meyfa meyfa added the duplicate This issue or pull request already exists label Feb 12, 2024
@liamjt95
Copy link
Author

Thanks for your responses! Unfortunately, this was required for some paid client work, for which we had to find another workaround. If I'm ever back in this space I will look into raising a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants