Convert textPath to rotated text

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Convert textPath to rotated text

Joel C. Salomon
Neighbors,

I have in an e-book a title page formatted with SVG, using <textPath> to
place text along a curve.  To reduce the picture to a minimum example,
consider curvetext.svg:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <svg xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
      viewBox="0 0 160 256" width="160" height="256">
      <g style="text-align:center;text-anchor:middle;stroke:none;">
        <path style="fill:none;"
          d="m 0,72 c 32,-16 52,-20 80,-20 28,0 48,4 80,20"
          id="path-upper" />
        <text style="font-size:9px;"
          ><textPath xlink:href="#path-upper" startOffset="50%"><tspan
            >Text to be Placed Along a Curve</tspan></textPath></text>
      </g>
    </svg>

Trouble is, Kindle (among other platforms) doesn’t support <textPath> in
SVG.  I can generate a raster image, but that’s no fun.  But
experimenting with various formats suggests this:

    $ inkscape -A curvetext.pdf --export-ignore-filters curvetext.svg
    $ inkscape -l curvetext2.svg curvetext.pdf

And it works, generating lines like

    <text
transform="matrix(0.94068351,0.33928532,0.33928532,-0.94068351,17.864857,145.9156)"><tspan
y="0" x="0">T</tspan></text>
    <text
transform="matrix(0.94997891,0.31231406,0.31231406,-0.94997891,20.665461,146.93493)"><tspan
y="0" x="0">e</tspan></text>
    <text
transform="matrix(0.96048875,0.27831882,0.27831882,-0.96048875,24.497618,148.19598)"><tspan
y="0" x="0">x</tspan></text>
    <text
transform="matrix(0.96875188,0.24803186,0.24803186,-0.96875188,28.337099,149.29823)"><tspan
y="0" x="0">t</tspan></text>

Well, the result actually includes a bunch of other boilerplate that
Inkscape likes to add to SVGs (some of which I’ve removed for clarity in
the example above), and also it adds a global transform matrix,

    <g transform="matrix(1.3333333,0,0,-1.3333333,0,256)">

around everything and the result is generally odd-looking code.  And
maybe I should just let Inkscape do its thing and not worry about this.
But what I’d really like is to compile down ›just‹ the <textPath> code,
and have it yield something anchored around where the text actually
appears on the page (maybe the start of the <path> at (0,72), or the
midpoint at (80,52), or something plausible).

Is what I’m looking for at all reasonable, and is there some way to
accomplish this with Inkscape?  (I’m prepared to hear “no” to both parts
of my question.)

––Joel C. Salomon

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-user
Reply | Threaded
Open this post in threaded view
|

Re: Convert textPath to rotated text

Marc Jeanmougin
Hi,

You can try to convert it to path, if it suits your needs

--
Mc

On 09/07/2017 08:01 PM, Joel C. Salomon wrote:

> Neighbors,
>
> I have in an e-book a title page formatted with SVG, using <textPath> to
> place text along a curve.  To reduce the picture to a minimum example,
> consider curvetext.svg:
>
>     <?xml version="1.0" encoding="UTF-8" standalone="no"?>
>     <svg xmlns="http://www.w3.org/2000/svg"
>       xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
>       viewBox="0 0 160 256" width="160" height="256">
>       <g style="text-align:center;text-anchor:middle;stroke:none;">
>         <path style="fill:none;"
>           d="m 0,72 c 32,-16 52,-20 80,-20 28,0 48,4 80,20"
>           id="path-upper" />
>         <text style="font-size:9px;"
>           ><textPath xlink:href="#path-upper" startOffset="50%"><tspan
>             >Text to be Placed Along a Curve</tspan></textPath></text>
>       </g>
>     </svg>
>
> Trouble is, Kindle (among other platforms) doesn’t support <textPath> in
> SVG.  I can generate a raster image, but that’s no fun.  But
> experimenting with various formats suggests this:
>
>     $ inkscape -A curvetext.pdf --export-ignore-filters curvetext.svg
>     $ inkscape -l curvetext2.svg curvetext.pdf
>
> And it works, generating lines like
>
>     <text
> transform="matrix(0.94068351,0.33928532,0.33928532,-0.94068351,17.864857,145.9156)"><tspan
> y="0" x="0">T</tspan></text>
>     <text
> transform="matrix(0.94997891,0.31231406,0.31231406,-0.94997891,20.665461,146.93493)"><tspan
> y="0" x="0">e</tspan></text>
>     <text
> transform="matrix(0.96048875,0.27831882,0.27831882,-0.96048875,24.497618,148.19598)"><tspan
> y="0" x="0">x</tspan></text>
>     <text
> transform="matrix(0.96875188,0.24803186,0.24803186,-0.96875188,28.337099,149.29823)"><tspan
> y="0" x="0">t</tspan></text>
>
> Well, the result actually includes a bunch of other boilerplate that
> Inkscape likes to add to SVGs (some of which I’ve removed for clarity in
> the example above), and also it adds a global transform matrix,
>
>     <g transform="matrix(1.3333333,0,0,-1.3333333,0,256)">
>
> around everything and the result is generally odd-looking code.  And
> maybe I should just let Inkscape do its thing and not worry about this.
> But what I’d really like is to compile down ›just‹ the <textPath> code,
> and have it yield something anchored around where the text actually
> appears on the page (maybe the start of the <path> at (0,72), or the
> midpoint at (80,52), or something plausible).
>
> Is what I’m looking for at all reasonable, and is there some way to
> accomplish this with Inkscape?  (I’m prepared to hear “no” to both parts
> of my question.)
>
> ––Joel C. Salomon
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Inkscape-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/inkscape-user
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-user

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Convert textPath to rotated text

Joel C. Salomon
On 2017-09-07 3:29 PM, Marc Jeanmougin wrote:
> You can try to convert it to path, if it suits your needs

That’s at least as clean a solution as what I was hoping for.  And not
going through PDF conversion means there’s no funny change of
coordinates.  Thanks!

––Joel C. Salomon

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Inkscape-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/inkscape-user