linuxmint / xviewer

A generic Image viewer
GNU General Public License v2.0
75 stars 37 forks source link

Nested CSS classes in SVG not supported #137

Closed rosecitytransit closed 3 years ago

rosecitytransit commented 3 years ago
 * Xviewer version 2.4.3
 * Mint 19.3

Line charts generated by a customized version of http://topnew.net/chart (e.g. by having it put the CSS inside the SVG) do not look correct as the chart line is shown filled in (even though the element is not closed) and not just as a line. In addition, the chart title is not shown in the specified font.

I simplified the SVG down to just the line and title elements to isolate the issue:

<svg viewBox="0 0 960 200" class="chart" version="1.0" xmlns="http://www.w3.org/2000/svg">
<defs>
<style type="text/css"><![CDATA[
.chart text{font-family:Helvetica,Arial,Verdana,sans-serif;font-size:12px;fill:#666}
.chart .line{fill:none;stroke-width:3}
]]></style>
</defs>
  <text y="15" x="480" text-anchor="middle">Chart title (wrong font)</text>
    <g fill="#d9534f">
      <path d="M0,51.11333 695.73504,51.36439 891.01232,135.80061" class="line" stroke="#d9534f"/>
    </g>
</svg>

Note that removing the .chart class from the style definitions does result in correct display.

Steps to reproduce Save the above SVG to a local file and view it.

Expected behaviour A line should appear, not a filled triangle, and the text should be in the specified font.

Other information Issue also appears in whatever Linux Mint uses to generate file thumbnails.

131 may be related

programmer-ceds commented 3 years ago

Using Mint 20.1 and xviewer 2.8.1 I see a line rather than a filled triangle unless I delete the .chat lines in which case the font (not surprisingly changes) and a filled triangle is drawn. This also applies to the thumbnails.

The attached file is part of what is displayed for the file as listed above. Screenshot from 2021-04-05 16-53-52

Note that I can't reproduce #131 either with my system.

Can you try with the latest version of xviewer?

programmer-ceds commented 3 years ago

I also get the same results with inkscape and pix - that is to say that the code you posted displays as shown above (the background is transparent but I set xviewer to show it as as a colour in order that the text was more readable)

Looking at the code my understanding is that the image buffer is loaded (rendered) by a call to the GTK+ function rsvg_handle_get_pixbuf() - in which case the error that you are seeing would lie at a lower level than xviewer, rather than in xviewer itself.

What do you see if you type the following in a terminal window?

dpkg -s librsvg2-2|grep '^Version'

rosecitytransit commented 3 years ago

Well, I recently upgraded Mint to 20, which includes Xviewer 2.6.2, and the SVG displays correctly.

I guess I'll close this since it seems a newer version seems to work correctly.