Applying a class to SVG

bloodnok
Posts: 36
Joined: Mon Jun 27, 2011 10:51 pm

Applying a class to SVG

Post by bloodnok » Wed May 15, 2019 10:46 pm

I'm experimenting with embedding SVG in my docs. Found a probable bug with Chemistry.
I've the following

Code: Select all

<svg-container id="opt-svg">
  <svg class="fontfab" fill-rule="evenodd" clip-rule="evenodd"
    stroke-linejoin="round" stroke-miterlimit="1.414" viewBox="0 0 512 512"
    xmlns="http://www.w3.org/2000/svg">
    <path
      d="M493.716 438.858H347.43c-7.227 0-19.49-4.256-22.424-10.86l-141.46-295.426H18.286C8.188 132.572 0 112.956 0 102.858c0-10.099 8.188-29.715 18.286-29.715h182.857c7.227 0 19.49 4.256 22.425 10.86l141.46 295.427h128.688c10.1 0 18.285 19.615 18.285 29.714 0 10.1-8.186 29.714-18.285 29.714zm0-306.286H310.858c-10.1 0-18.286-19.616-18.286-29.714 0-10.099 8.187-29.715 18.286-29.715h182.858c10.1 0 18.285 19.616 18.285 29.715 0 10.098-8.186 29.714-18.285 29.714z"
      fill-rule="nonzero"/>
  </svg>
</svg-container>
The class "fontfab" is defined

Code: Select all

svg.fontfab{
  height: 0.8em;
  width: 0.8em;
}
After building with Chemistry, the SVG appears in the PDF at its viewBox size, ignoring the CSS.
Tried changing the height/width definitions to points to no avail. The CSS was still ignored.
Embedding the height/width values in the <svg> tag works but breaks my HTML output.
Is this a known bug? Is there a workaround?

Dan
Posts: 395
Joined: Mon Feb 03, 2003 10:56 am

Re: Applying a class to SVG

Post by Dan » Thu May 16, 2019 10:47 am

Thank you for reporting this!
Yes, this is a limitation, we will try to find a solution for this. For the moment I see no easy workaround, except trying to alter all the SVG from the documentation using the oXygen refactoring actions in a form that is acceptable for both the print and web formats.
Another way would be to write some XSLT extensions:

https://www.oxygenxml.com/doc/ug-pdf-cs ... sions.html


Many regards,
Dan

bloodnok
Posts: 36
Joined: Mon Jun 27, 2011 10:51 pm

Re: Applying a class to SVG

Post by bloodnok » Sun May 19, 2019 12:26 am

I've found a workaround using an ANT replaceregexp - fortunately the class="fontfab" is easy to find:

Code: Select all

<replaceregexp file="${pub.dir}/index.html" flags="gs" match="class=&quot;fontfab&quot;"
    replace="height=&quot;9pt&quot; width=&quot;9pt&quot;" byline="true"/>
Thanks for the confirmation, Dan. Hope you guys come up with a better fix than my kludge.

Post Reply