svgcleaner icon indicating copy to clipboard operation
svgcleaner copied to clipboard

Feature request: remove duplicate x/y in tspan

Open Artoria2e5 opened this issue 5 years ago • 2 comments

It is a common pattern for Inkscape to put x/y coordinates in a <text> element, only to repeat it again in the <tspan> element. There should be some space saving out of these cases, especially for files with a large number of these elements.

The below test case is from File:CtDNA.svg on Wikimedia Commons:

<g fill="#0bc056">
    <text letter-spacing="-5" x="3.643575" y="22.362129" text-align="center"><tspan dx="0 0 0 0 0 0 0 0 0 0 2.28" font-size="72.5" x="1.143574" y="22.362129" sodipodi:role="line">chloroplast dna</tspan></text>
    <g font-family="'Frutiger Neue 35','Segoe UI',Ubuntu,sans-serif" font-weight="200" letter-spacing="0">
        <text font-style="italic" x="3.279297" y="-57.637871" text-align="center"><tspan font-size="30" x="3.279297" y="-57.637871" sodipodi:role="line">nicotiana tabacum</tspan></text>
        <text font-size="25" x="1.579299" xml:space="preserve" y="72.362129" text-align="center"><tspan dx="0 -3.159999" fill="#0bc056" font-size="25" letter-spacing="0" text-anchor="middle" text-align="center">155,939</tspan><tspan fill="#0bc056" font-family="'Frutiger Neue 35','Segoe UI',Ubuntu,sans-serif" font-weight="200" font-size="25" letter-spacing="0" text-anchor="middle" text-align="center"> base pairs</tspan></text>
    </g>
</g>

Artoria2e5 avatar Jan 09 '21 16:01 Artoria2e5

Yes, text element optimization is pretty simple right now.

RazrFalcon avatar Jan 09 '21 16:01 RazrFalcon

There are some feature-requests relating to tspan/text: (beging with the most similar one)

  • Improvement merge text and tspan #127
  • Process 'text' and 'tspan' attributes #39
  • Remove empty text and tspan elements #105
  • Apply transforms to 'text' element #38

JoKalliauer avatar Jan 10 '21 08:01 JoKalliauer