Coder Social home page Coder Social logo

Comments (9)

srwiley avatar srwiley commented on July 18, 2024 1

from oksvg.

yeldiRium avatar yeldiRium commented on July 18, 2024 1

That is great to hear. Would you mind taking a look at my PR then?
I'm not sure how clean my implementation is, since I basically circumvent the inDefs check by setting inDefsStyle without it. But I added a test and top level styles work the way they are supposed to.

from oksvg.

mysugar avatar mysugar commented on July 18, 2024

Hi ,have you solved this problem? @giancarlobastos

from oksvg.

yeldiRium avatar yeldiRium commented on July 18, 2024

Some input on this: I believe this is due to oksvg not supporting style tags in SVG. I can't say for sure, but I'm having the same problem and removing the style block and putting the style attributes directly into the path tags solved the rendering issue for me.

Edit: I've looked at @giancarlobastos SVG and it also uses a style block to assign fill colors to the paths. I think we are experiencing the same issue.

from oksvg.

yeldiRium avatar yeldiRium commented on July 18, 2024

I've perused the code and I've found something that confuses me:

style tags should be handled here

if se.Name.Local == "style" && cursor.inDefs {
and the code to do so looks fine to me. Once the endElement for the style tag is found, its text content is parsed and added to the styles here
icon.classes, err = parseClasses(classInfo)

But before the style tag can be handled, the readStartElement call here

err = cursor.readStartElement(se)
will always fail, since style tags are not handled there and not a valid draw function, so this line will fail
df, ok := drawFuncs[se.Name.Local]

I'm not that far into the code, so I'm not sure enough on how to fix this to provide a PR. However, my intuition is to handle style tags before and without calling readStartElement on them. @srwiley what do you think about this? Can you do anything with this research?

from oksvg.

yeldiRium avatar yeldiRium commented on July 18, 2024

One more update from me (sorry for the multipost):

After looking at the tests I realize that the style tag is supported, but only within an enclosing defs tag. That is understandable, but is probably not how most SVGs look and as far as I know there is nothing in the SVG spec that says that style tags need to be enclosed in defs tags. @srwiley would you be fine with changing this requirement?

from oksvg.

goloroden avatar goloroden commented on July 18, 2024

@srwiley To me the solution that @yeldiRium came up with looks pretty good. Is there a chance that the according PR gets merged soon?

from oksvg.

srwiley avatar srwiley commented on July 18, 2024

from oksvg.

goloroden avatar goloroden commented on July 18, 2024

Yes, there are tests to support the code (and given the discussion above it seems as if @yeldiRium did a pretty decent job 😊).

from oksvg.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.