fxsvgimage icon indicating copy to clipboard operation
fxsvgimage copied to clipboard

Arrow marker not rendered correctly

Open xeruf opened this issue 2 years ago • 17 comments

I have an SVG made with inkscape containing arrow heads as markers, which fxsvgimage does not render: aufstellung-rearranged-plain

So I wanted to convert the arrow to a path via Path>Stroke to Path (as mentioned in https://stackoverflow.com/a/10480412/6723250), but the resulting SVG somehow crashes the SVGLoader.load such that it does not even throw an exception but simply returns null: aufstellung-rearranged-slim

Converting the SVG via ImageMagick also produces something not understood by SVGLoader :/

xeruf avatar Jun 09 '22 09:06 xeruf

Thanks, I will try the two svg files ASAP.

hervegirod avatar Jun 09 '22 12:06 hervegirod

For the first problem, it's because the "marker" element is not supported ATM. It should not be difficult to support it, because the "use" element is already supported.

For the second, I have to debug :)

hervegirod avatar Jun 09 '22 12:06 hervegirod

Trying with Batik via https://github.com/codecentric/javafxsvg I get this error on all of them, maybe that helps:

org.w3c.dom.DOMException: <unknown>:
The attribute "style" represents an invalid CSS declaration ("fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt").
Original message:
The "context-stroke" identifier is not a valid value for the "fill" property. 

If you find a fix in the next two days that would be fantastic, and be it dirty ;)

xeruf avatar Jun 09 '22 13:06 xeruf

Thanks, I will have a look this evening :)

hervegirod avatar Jun 09 '22 13:06 hervegirod

The second problem (null result) is fixed in master (I created another issue just for this problem), but the marker element is still not rendered for the moment. Should be working tomorrow evening I hope

hervegirod avatar Jun 09 '22 22:06 hervegirod

Almost fixed :)

hervegirod avatar Jun 12 '22 11:06 hervegirod

I have an initial support for the marker element. Some things are still not handled correctly:

  • The orientation of the marker is not taken into account, though it does not change anything in your use case I think
  • The Positioning of the marker for a path is not correctly handled, but again in your case it does not impact the result
  • The size of the marker does not take into account the viewport and markerWidth / markerHeigh of the marker

I will continue to add these features, because I think I know how to handle them (it's not bugs, but features which are not handled yet).

hervegirod avatar Jun 12 '22 18:06 hervegirod

Normally the size of the marker now takes the viewbox into account (and the marker width and height)

hervegirod avatar Jun 12 '22 21:06 hervegirod

You are awesome, I will stay with the converted PNG for now but check it out when I have more time ;)

xeruf avatar Jun 13 '22 07:06 xeruf

Latest jitpack build fails :/ https://jitpack.io/com/github/hervegirod/fxsvgimage/c67eeb8e36/build.log

xeruf avatar Jun 14 '22 08:06 xeruf

I'll take a look. Probably some structure changes that are not reflected in the pom.xml

perNyfelt avatar Jun 14 '22 09:06 perNyfelt

I'll take a look. Probably some structure changes that are not reflected in the pom.xml

I will look also. And yes I changed things in the structure of the xml package a bit

hervegirod avatar Jun 14 '22 09:06 hervegirod

OK, it's the org.girod.javafx.svgimage.xml.SVGShapeBuilder java file which should not be there. It must be a mistake in my commit. For whatever reason, the deletion of this file was not pushed (the file does not exist in my local repo). The correct file is under the org.girod.javafx.svgimage.xml.builders package (and it's there in the repo). I can fix this this evening, or you can do it yourself today and ask for a pull request, and I will accept the request. Whatever you prefer :)

hervegirod avatar Jun 14 '22 09:06 hervegirod

Besides removing the org.girod.javafx.svgimage.xml.SVGShapeBuilder, the following addition is needed in the pom.xml on line 36 (between the testSourceDirectory and the plugins elements):

<testResources>
    <testResource>
        <directory>${project.basedir}/src/test</directory>
        <excludes>
            <exclude>**/*.java</exclude>
        </excludes>
    </testResource>
</testResources>

This will ensure that the svg files used by tests are copied properly.

However, i get test failure in SVGImageScaled2Test:

java.lang.AssertionError: width 
Expected :25.0
Actual   :1.0

...so maybe there are some other code changes missing in master?

perNyfelt avatar Jun 14 '22 13:06 perNyfelt

I will look at that test regression as soon as I am home. Thanks!!

hervegirod avatar Jun 14 '22 17:06 hervegirod

I seem to have broken something with the last modifications (those I did to fix this issue I think). I am sorry for that. I tested and as you said many test cases are broken. I will fix this mess ASAP.

hervegirod avatar Jun 15 '22 13:06 hervegirod

I fixed these failing unit tests. These are problems I introduced after fixing issue #25

hervegirod avatar Jun 18 '22 12:06 hervegirod