meerk40t / svgelements

SVG Parsing for Elements, Paths, and other SVG Objects.
MIT License
132 stars 29 forks source link

Group with display:none incorrectly text objects. #152

Closed Sophist-UK closed 2 years ago

Sophist-UK commented 2 years ago

I couldn't understand why my K40 started rastering something at y=0, and it turns out that a group with display:none is somehow loading the last of the elements contained in it.

Here is the object list in Inkscape showing the group is hidden: image

Here is what is loaded into Meerk40t: image

Here is the svg group xml and contents:

  <g
     id="g59534"
     style="display:none"
     inkscape:label="Text and paths">
    <text
       xml:space="preserve"
       style="font-size:41.5748px;line-height:37.459px;font-family:'Beyond Wonderland';-inkscape-font-specification:'Beyond Wonderland';letter-spacing:0px;word-spacing:0px;stroke-width:1.00895"
       id="text2732"
       transform="matrix(0.99458124,0,0,0.98768589,-0.3343578,13.79145)"
       inkscape:label="SBdA"><textPath
         xlink:href="#path11278"
         id="textPath11464"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:41.5748px;font-family:Fritz-Quad;-inkscape-font-specification:Fritz-Quad;stroke-width:1.00895">São Brás de Alportel</textPath></text>
    <path
       style="display:inline;fill:none;stroke:#008000;stroke-width:0.741834;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-opacity:1"
       id="path11278"
       sodipodi:type="arc"
       sodipodi:cx="-190.9565"
       sodipodi:cy="233.25325"
       sodipodi:rx="182.80643"
       sodipodi:ry="119.86744"
       sodipodi:start="0.22902013"
       sodipodi:end="3.0558305"
       sodipodi:open="true"
       sodipodi:arc-type="arc"
       d="M -12.923271,260.46596 A 182.80643,119.86744 0 0 1 -204.03954,352.81332 182.80643,119.86744 0 0 1 -373.09105,243.52074"
       transform="scale(-1,1)"
       inkscape:label="SBdA path" />
    <path
       style="display:inline;fill:none;stroke:#008000;stroke-width:0.925896;stroke-linejoin:bevel;stroke-miterlimit:10;stroke-opacity:1"
       id="path26429"
       sodipodi:type="arc"
       sodipodi:cx="-181.77562"
       sodipodi:cy="-136.02663"
       sodipodi:rx="147.33418"
       sodipodi:ry="95.472572"
       sodipodi:start="0.60732563"
       sodipodi:end="2.5258317"
       sodipodi:arc-type="arc"
       d="M -60.788156,-81.542972 A 147.33418,95.472572 0 0 1 -181.15422,-40.554903 147.33418,95.472572 0 0 1 -302.04955,-80.88359"
       transform="scale(-1)"
       sodipodi:open="true"
       inkscape:label="Algarve path" />
    <text
       xml:space="preserve"
       style="font-size:52.9134px;line-height:47.675px;font-family:'Beyond Wonderland';-inkscape-font-specification:'Beyond Wonderland';text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;stroke-width:1.01717"
       id="text43001"
       transform="matrix(0.98428903,0,0,0.98196221,12.775797,8.50574)"
       inkscape:label="Algarve"><textPath
         xlink:href="#path26429"
         startOffset="50%"
         id="textPath59326"
         style="stroke-width:1.01717"><tspan
           id="tspan42999"
           style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Fritz-Quad;-inkscape-font-specification:Fritz-Quad;text-align:center;text-anchor:middle;stroke-width:1.01717">Algarve</tspan></textPath></text>
  </g>
tatarize commented 2 years ago

This is legit and traces back to logic error. Text spans are added on close since they need the actual data between the tags to display. But, the display none isn't checked so sometimes the object can be added to the list of objects even though the display value is set to none.

Sophist-UK commented 2 years ago

I think that there may be two use cases where this happens:

a. Text object is in a group which has display:none; b. Text object itself has display:none.

Both perhaps the same cause if I understood your description.

tatarize commented 2 years ago

Basically text objects get added at the tag close by spec, and the tag close doesn't avoid processing because of display:none so any tag that can occur at the close namely anything where <tag>this text is important</tag> happens. So desc and titles would do this as well even though those are never displays.

tatarize commented 2 years ago

I'm basically waiting on the tests to finish before this thing is marked as fixed.

tatarize commented 2 years ago

Fixed in 1.6.5.