eridur-de / mightyscape-1.2

A maintained extension collection for Inkscape 1.2, working on Windows and Linux
https://y.stadtfabrikanten.org/mightyscape
GNU General Public License v3.0
40 stars 3 forks source link

[repair_text] extension #149

Open vmario89 opened 6 months ago

vmario89 commented 6 months ago

Create an extension which makes it possible to convert text/tspan correctly into sth editable after using the PDF import. Problem: after PDF import, text is often not correctly editable. Take the following example:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="104.91422mm"
   height="4.3511581mm"
   viewBox="0 0 104.91422 4.3511581"
   version="1.1"
   id="svg2051"
   inkscape:version="1.3.2 (091e20ef0f, 2023-11-25)"
   sodipodi:docname="text bug.svg"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <sodipodi:namedview
     id="namedview2053"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageshadow="2"
     inkscape:pageopacity="0.0"
     inkscape:pagecheckerboard="false"
     inkscape:document-units="mm"
     showgrid="false"
     inkscape:showpageshadow="false"
     inkscape:snap-tangential="true"
     inkscape:snap-perpendicular="true"
     inkscape:deskcolor="#ffffff"
     inkscape:zoom="0.54469687"
     inkscape:cx="141.36303"
     inkscape:cy="0"
     inkscape:window-width="1920"
     inkscape:window-height="1014"
     inkscape:window-x="0"
     inkscape:window-y="0"
     inkscape:window-maximized="1"
     inkscape:current-layer="layer1" />
  <defs
     id="defs2048" />
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(-365.65416,-287.33749)">
    <text
       id="text98-0"
       xml:space="preserve"
       x="365.4733"
       y="291.01169"
       style="font-size:4.23333px;stroke-width:0.352777"><tspan
         style="font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.29167px;font-family:Carlito;writing-mode:lr-tb;fill:#05498c icc-color(sRGB-IEC61966-2, 0.1, 0.02099609, 0.2869873, 0.54899597);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.352777"
         x="365.4733 367.45715 369.14621 371.755 374.50668 377.11282 379.8645 381.03397 384.79105 385.97635 387.79669 388.96616 391.71783 394.46951 396.51208 397.68152 400.18982 401.37512 403.41769 404.58719 406.7832 409.38934 411.20969 413.96133 415.55414 416.7236 419.47528 422.22693 424.97861 426.14807 429.37598 431.98477 434.73639 437.11765 440.82712 443.43594 445.25623 447.58621 449.57001 451.25174 453.71075"
         y="291.01169"
         sodipodi:role="line"
         id="tspan99-3">stehen wir uns als Lern- und Denkwerkstätt</tspan><tspan
         style="font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.29167px;font-family:Carlito;writing-mode:lr-tb;fill:#05498c icc-color(sRGB-IEC61966-2, 0.1, 0.02099609, 0.2869873, 0.54899597);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.352777"
         x="456.98419 459.5903 462.34201 463.6358 464.80524 467.31348 468.49881 470.56839"
         y="291.01169"
         sodipodi:role="line"
         id="tspan100-7">en, als </tspan></text>
  </g>
</svg>

to make editable text, we need to remove x and y attributes from tspan and maybe from text; additionally larger text is split up in a lot of certain tspan elements. It would be good to merge them info one text block.