RazrFalcon / svgcleaner

svgcleaner could help you to clean up your SVG files from the unnecessary data.
GNU General Public License v2.0
1.62k stars 93 forks source link

Feature request: remove duplicate x/y in tspan #224

Open Artoria2e5 opened 3 years ago

Artoria2e5 commented 3 years ago

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>
RazrFalcon commented 3 years ago

Yes, text element optimization is pretty simple right now.

JoKalliauer commented 3 years ago

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