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

How to add attributes to textpath instead of the parent text node #74

Open
marcuswu opened this issue Sep 12, 2024 · 2 comments · May be fixed by #75
Open

How to add attributes to textpath instead of the parent text node #74

marcuswu opened this issue Sep 12, 2024 · 2 comments · May be fixed by #75

Comments

@marcuswu
Copy link

Code like this:

draw.Textpath("Some text here", "#topArc", `text-anchor="middle"`, `startOffset="50%"`, `font-size="25"`, `font-family='Salma Pro'`, `fill="black"`)

Results in this xml:

<text xmlns="http://www.w3.org/2000/svg" text-anchor="middle" startOffset="50%" font-size="25px" font-family="Salma Pro" fill="black">
  <textPath xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#topArc">Some text here</textPath>
</text>

I want the text-anchor and startOffset fields to be on the <textPath> tag instead of the <text> tag. How would I make that happen? Is there a way to define the two tags separately?

@marcuswu
Copy link
Author

Looking at the code it seems that it does not support this right now. I'll think about how this could be implemented. I might submit a PR.

I did find a hacky way of working around it for now similar to an SQL injection. I inject attributes via the path id field:

draw.Textpath("Some text here", "#topArc\" text-anchor=\"middle\" startOffset=\"50%", `font-size="25"`, `font-family='Salma Pro'`, `fill="black"`)

@marcuswu marcuswu linked a pull request Sep 13, 2024 that will close this issue
@marcuswu
Copy link
Author

@ajstarks I know you have been focused on other libraries / projects (and I considered using one of them instead, but it doesn't cover all of my needs right now. Mainly text along a path), but I would love to have your opinion on the changes I proposed in the above PR.

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

Successfully merging a pull request may close this issue.

1 participant