-
-
Notifications
You must be signed in to change notification settings - Fork 67
text following circular path #21
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
Comments
The This should get you started: import drawSvg as draw
import xml.sax.saxutils as xml
class _TextPathNode(draw.DrawingBasicElement):
TAG_NAME = 'textPath'
hasContent = True
def __init__(self, text, path, **kwargs):
super().__init__(xlink__href=path, **kwargs)
self.escapedText = xml.escape(text)
def writeContent(self, idGen, isDuplicate, outputFile, dryRun):
if dryRun: return
outputFile.write(self.escapedText)
class TextOnPath(draw.DrawingParentElement):
TAG_NAME = 'text'
def __init__(self, text, fontSize, path, **kwargs):
super().__init__(font_size=fontSize, **kwargs)
self.append(_TextPathNode(text, path))
d = draw.Drawing(300, 100, origin=(0, 0), displayInline=False)
path = draw.Path(stroke='lightblue', fill='none')
path.M(50, 100-50).C(100, 100-0, 200, 100-100, 250, 100-50)
d.append(path)
text = TextOnPath('Text on a path.', 24, path)
d.append(text)
d |
Thanks for a starter! I'll be happy to contribute! |
Does this apply to the 'basic drawing elements' example? I can't get path text or multi-line text working (lines 32-33). The error states required positional arguments 'x' and 'y' are missing. |
@lthumbe You probably have an old version of drawSvg. The pull request linked right above this added the feature for the version 1.8.1 which was recently published (and I forgot to close this issue). From your terminal run Let me know if this works then I'll close this issue. |
@cduck Upgrade fixed it. Thanks! |
Closing because text following a path was implemented by #22. |
Hello!
I was wondering if it is possible to recreate effect like on following example? Of text following a curved path.
reference: https://www.w3.org/TR/SVG/text.html
more examples:
http://thenewcode.com/482/Placing-Text-on-a-Circle-with-SVG
https://css-tricks.com/snippets/svg/curved-text-along-path/
https://codepen.io/rdfriedl/pen/rOegaP
Thanks a lot for hints!
The text was updated successfully, but these errors were encountered: