Chlumsky / msdfgen

Multi-channel signed distance field generator
MIT License
3.91k stars 404 forks source link

Add a flag that uses nanosvg. #98

Closed fire closed 4 years ago

fire commented 4 years ago

Support more svg files.

fire commented 4 years ago

In my file the svg generates 5 shapes. To support that, a min operation needs to be done on the 5 outputs.

fire commented 4 years ago

I expect all the colored shapes to be white. How can I do that?

out index.zip

Chlumsky commented 4 years ago

So this adds a dependency that is larger than the project itself and all it improves is that it finds more than one shape in the SVG, which can be easily added to the original implementation as well, except for the fact that finding the paths is not the problem, combining them is, and obviously, this "upgrade" doesn't do anything about that. I'm not even going to comment on how it turns everything, even straight lines into cubic curves.

fire commented 4 years ago

Thank you for the comments, I was unable to get multiple shapes working with your implementation, it should be possible. I noticed your documentation says it takes the last shape.

My plan was to stack the sdfs and color the sdfs to output color emoji, but all of this is expensive in the number of textures. Did you have an approach for this? The shapes winding order fails when overlapping. I can provide svgs.

I noticed there are corner cases when I can generate a line that fills horizontally the entire sdf.

I’m blocked on these two issues, which is why I tried this approach. Please advise.

Chlumsky commented 4 years ago

The problem is that the algorithm requires strictly non-intersecting shapes to work properly, and with consistent winding direction. So if you want to use an SVG that has multiple overlapping paths, the only way would be to preprocess the path using something like Paper.js and then pass it to msdfgen.

When it comes to color emojis, you would always need to generate an SDF for each color, since the SDF only represents a colorless shape.

Please post the case where a line fills horiznontally the entire sdf, that might be a bug.