Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

support display:none in svg parsing #1137

Closed
springmeyer opened this Issue · 9 comments

3 participants

@springmeyer
Owner

I've stripped down the svg testcase to be as minimal as possible.

Here are Two renderings without (left) and with (right) the final commenting fix below:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.0"
   width="580"
   height="580"
>
  <g
     id="g1327">
    <path
       d="M 66.275,1.768 C 24.94,1.768 1.704,23.139 1.704,66.804 L 1.704,516.927 C 1.704,557.771 22.599,579.156 63.896,579.156 L 515.92,579.156 C 557.227,579.156 578.149,558.841 578.149,516.927 L 578.149,66.804 C 578.149,24.203 557.227,1.768 514.628,1.768 C 514.624,1.768 66.133,1.625 66.275,1.768 z "
       style="fill:#111;stroke:#eee;stroke-width:3.40799999"
       id="path1329" />
  </g>
<!--
  <g
     id="layer3"
     style="display:none;stroke:#757575;stroke-opacity:1"
     transform="matrix(48.14969,0,0,48.14969,-536.27327,-33.306752)">
    <rect
       style="fill:none;stroke:#757575;stroke-width:0.10000000000000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline"
       id="rect4134"
       width="10"
       height="10"
       x="1"
       y="1" />
    <rect
       style="fill:none;stroke:#757575;stroke-width:0.10000000000000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline"
       id="rect4136"
       width="8"
       height="8"
       x="2"
       y="2" />
  </g>
-->
  <path
     transform="matrix(14.685839,0,0,14.685839,565.76584,1146.0639)"
     style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:NPSPICT3;"
     d="M -19.0625,-67.787842 C -19.542663,-67.78782 -19.962788,-67.967874 -20.322876,-68.328003 C -20.683002,-68.688088 -20.863055,-69.12164 -20.863037,-69.628662 C -20.863055,-70.108781 -20.683002,-70.528703 -20.322876,-70.888428 C -19.962788,-71.248103 -19.542663,-71.427953 -19.0625,-71.427979 C -18.555522,-71.427953 -18.122173,-71.248103 -17.762451,-70.888428 C -17.402772,-70.528703 -17.222922,-70.108781 -17.2229,-69.628662 C -17.222922,-69.12164 -17.402772,-68.688088 -17.762451,-68.328003 C -18.122173,-67.967874 -18.555522,-67.78782 -19.0625,-67.787842 L -19.0625,-67.787842 z M -5.3820801,-57.988037 C -5.4887217,-58.628487 -5.888705,-58.948718 -6.5820312,-58.94873 C -6.9027014,-58.948718 -7.1960768,-58.815254 -7.4621582,-58.54834 L -11.903076,-54.388184 C -12.222927,-54.122062 -12.382839,-53.802238 -12.382812,-53.428711 C -12.382839,-52.788242 -12.089464,-52.374831 -11.502686,-52.188477 L -10.38208,-51.828369 C -10.942004,-50.308183 -11.835354,-49.008135 -13.062134,-47.928223 C -14.288965,-46.848307 -15.702335,-46.148438 -17.302246,-45.828613 L -17.302246,-65.547852 C -15.515974,-66.321757 -14.622827,-67.682026 -14.622803,-69.628662 C -14.622827,-70.828182 -15.056176,-71.861302 -15.922852,-72.728027 C -16.789573,-73.594699 -17.836121,-74.028048 -19.0625,-74.028076 C -20.262877,-74.028048 -21.296201,-73.594699 -22.162476,-72.728027 C -23.028784,-71.861302 -23.46193,-70.828182 -23.461914,-69.628662 C -23.46193,-67.682026 -22.555355,-66.321757 -20.742188,-65.547852 L -20.742188,-45.78833 C -22.368995,-46.108154 -23.822444,-46.808227 -25.102539,-47.88855 C -26.382662,-48.968869 -27.302665,-50.282141 -27.862549,-51.828369 L -26.741943,-52.188477 C -26.156019,-52.374831 -25.86305,-52.788242 -25.863037,-53.428711 C -25.86305,-53.775383 -26.009535,-54.095207 -26.30249,-54.388184 L -30.782471,-58.54834 C -31.049406,-58.815254 -31.342781,-58.948718 -31.662598,-58.94873 C -32.355964,-58.948718 -32.755947,-58.628487 -32.862549,-57.988037 L -33.822021,-51.947998 C -33.848882,-51.815343 -33.86231,-51.722162 -33.862305,-51.668457 C -33.86231,-50.814774 -33.42245,-50.387935 -32.542725,-50.387939 C -32.409268,-50.387935 -32.289232,-50.401363 -32.182617,-50.428223 L -31.142578,-50.78833 C -30.288909,-48.228107 -28.762217,-46.134806 -26.5625,-44.508423 C -24.362808,-42.882043 -21.876238,-42.068852 -19.102783,-42.068848 C -16.356224,-42.068852 -13.862737,-42.895267 -11.622314,-44.548096 C -9.4625133,-46.148031 -7.9557603,-48.228107 -7.1020508,-50.78833 L -6.0620117,-50.428223 C -5.9554368,-50.401363 -5.8354011,-50.387935 -5.7019043,-50.387939 C -4.8222185,-50.387935 -4.3823589,-50.814774 -4.3823242,-51.668457 C -4.3823589,-51.722162 -4.3957866,-51.815343 -4.4226074,-51.947998 L -5.3820801,-57.988037 z"
     id="flowRoot3192" />
</svg>
@springmeyer
Owner

ping @twain47 - we should definitely support this <g> with display:none in mapnik, right (by skipping rendering it)? In other words, this is an intended part of these icons that we should be able to handle, right?

@twain47

I don't think this display:none is deliberate - it can probably be stripped out.

I'd have thought you needed to support display:none in general though?

@springmeyer
Owner

@twain47 - thanks for the thoughts. Yes, I think we should support display:none, but we do not yet - to my knowledge this is the first svg icon someone has tried to use with mapnik where the lacking display:none support caused a problem.

@twain47

I'll modify the icons to remove it and check for any other examples

@artemp artemp closed this
@artemp
Owner

Fixed in 80a1178

@springmeyer springmeyer reopened this
@springmeyer
Owner

re-opening. not working as I would expect.

@springmeyer
Owner

display is different than visibility, right? The gray boxes are now fixed but the image is still shifted to the right. If I uncomment the id="layer3" section in the sample svg and render with svg2png then I get:

while safari ignores the whitespace on the left when rendering. Shouldn't we match safari/chrome on this?

@artemp artemp referenced this issue from a commit
@artemp artemp + support 'display' property, if set to 'none' don't parse children #…
…1137

+ fix memory leak : xmlTextReaderGetAttribute -> string must be deallocated by the caller
+ call xmlTextReaderMoveToElement after xmlTextReaderMoveToFirstAttribute loop to restore
  reader position.

Conflicts:

	src/svg_parser.cpp
57d6d62
@artemp artemp referenced this issue from a commit
@artemp artemp + support 'display' property, if set to 'none' don't parse children #…
…1137

+ fix memory leak : xmlTextReaderGetAttribute -> string must be deallocated by the caller
+ call xmlTextReaderMoveToElement after xmlTextReaderMoveToFirstAttribute loop to restore
  reader position.
bba21e3
@springmeyer
Owner

tested, looking good now, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.