oksvg
oksvg copied to clipboard
fix: fix the problem that Black background when converting SVG to PNG
When I parse a style attribute with a global style tag and a stop tag in a Graid component, I will encounter the problem of the above attribute parsing failure,and resulted in the problem that Black background when converting SVG to PNG. I would classify it as the parsing problem of the style attribute, so I submitted this PR to solve the above problem.
stari, can you please check if pull request #40, Support top level style solves this problem? I just merged it today into the main branch.
@srwiley , I just merged the above top style code #40 , but I also solved another problem other than GradStop's rgb color not being resolved, you can see the changes I made to StopF function.
@srwiley asked for my input in #40, so I'm giving it:
I don't know a lot about svg gradients, so I can't say for sure that this solution is good. However, the implementation seems plausible to me. Parsing the contents of style tags within a gradient to obtain gradient related information sounds good. This in addition to the added tests leads me to believe that this PR is good and should be merged.
I am a bit confused about the chinese comments in the tests though. Since the rest of the project is in english, these should probably be translated. I did translate the comments using google translate and they are things like "read svg" and "define length and width", which are the kinds of comments that can in my opinion be removed entirely.
Apart from that, the PR looks good to me.
Sorry, I submitted some Chinese comments into the code, accidentally.
I've just removed the comment.
Thanks!
Sorry for taking so long to get back. I've been busy elsewhere.
I can't accept this pull request as is. The main problem is that in order fix the GradStop bug you have rearranged 8 files. This makes it hard for me to see exactly what you changed because such larger blocks have been moved around. In addition, generated pngs should not be included with source code. Also, I can't see where the fix alters the output from the last merge in the example svgs. You also add the style function to the draw function maps twice, which is unnecessary.
I am sure there is something good here, but please do the minimal alterations to the the existing structure, such as do not split out functions into individual files.