question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

text following circular path

See original GitHub issue

Hello! I was wondering if it is possible to recreate effect like on following example? Of text following a curved path.

<svg xmlns="http://www.w3.org/2000/svg"
     width="300" height="100" viewBox="0 0 300 100">

  <path id="MyPath" stroke="lightblue" fill="none"
	d="M 50,50 C 100,0 200,100 250,50"/>

  <text style="font: 24px sans-serif;">
    <textPath href="#MyPath">Text on a path.</textPath>
  </text>

</svg>
Screenshot 2020-09-21 at 10 49 52 PM

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!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lthumbecommented, Feb 12, 2021

@cduck Upgrade fixed it. Thanks!

1reaction
cduckcommented, Sep 21, 2020

The textPath element has not been implemented yet. You can subclass DrawingBasicElement or DrawingParentElement yourself to make any SVG tag (and maybe make a pull request).

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
output image
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Type In a Circle In Photoshop - Text In a Circular ...
Type on a Circular Path. On the Toolbar, select the Text tool. On the Options bar, On the Options bar, click on the...
Read more >
How To Type Text In A Circle In Photoshop (Step By Step)
To type text in a circle in Photoshop, select the Ellipse Tool then click and drag out on your canvas to create a...
Read more >
Curve text around a circle or other shape
Wrap around a circle To create text that completely circles your shape, choose Circle under Follow Path, and then drag any of the...
Read more >
Tip: Wrapping text around a circle in After Effects - Angie Taylor
3) Open the Layer in the Timeline by clicking it's disclosure triangle and then open the 'Text' section too. 4) Open the 'Path...
Read more >
How To Wrap Text Around A Circle In GIMP {Fix Upside ...
Make sure your “Top” path layer is selected. Next, navigate back to your layers panel. In the layer window, click the text layer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found