BigBadaboom / androidsvg

SVG rendering library for Android
http://bigbadaboom.github.io/androidsvg/
Apache License 2.0
1.19k stars 226 forks source link

SVG Rendering Issue in androidsvg Library #275

Closed Nidhi2712 closed 1 year ago

Nidhi2712 commented 1 year ago

Dear @BigBadaboom,

I hope this message finds you well. I want to start by expressing my gratitude for your work on the androidsvg library. It has been a valuable library for our development efforts.

I am writing to report an issue we've encountered while using androidsvg . We are currently developing a product that involves editing SVG images on both Android and iOS platforms. we have been facing some challenges on Android. please review attached images.

The problem we're experiencing is related to SVG rendering. It appears that certain SVGs are not rendering correctly on Android devices, resulting in visual inconsistencies.

We have thoroughly reviewed our implementation and confirmed that the issue seems to be rooted in the androidsvg library itself, as the SVGs in question are well-formed and display correctly on other platforms.

We are eager to continue using androidsvg for our Android development, but this rendering issue is currently a roadblock for us. We would greatly appreciate your assistance in resolving this matter or any guidance you can provide to help us better understand and address the issue.

If needed, we can provide specific SVG files and additional details to help diagnose the problem. We understand that open-source projects require time and effort, and we are more than willing to assist in any way we can to resolve this issue.

Android SVG Image :

Android_SVG

IOS SVG Image :

IOS_SVG

SVG String :

content_hide_svg.txt

Thank you for your attention to this matter, and we look forward to your guidance.

BigBadaboom commented 1 year ago

display correctly on other platforms

I tested your SVG in Chrome and Firefox, and they are rendering it identically to AndroidSVG.

I took a look at your file, and similarly to Issue #274, the viewBox in this file is incorrect. The correct viewBox for this file should be something like "-106 -46 212 258". If you update the SVG with this corrected viewBox, it should render completely on screen.

So it is actually your IOS library that is rendering the SVG incorrectly. :)

Hope this helps.

Nidhi2712 commented 1 year ago

Thanks for the replay, Can you let me know how you calculated the viewbox?

BigBadaboom commented 1 year ago

In this case, I used Chrome and the developer tools.

I loaded the SVG into Chrome. Opened the developer console. Selected the <svg> element. Then typed $0.getBBox() into the console.

If you are writing an SVG editor, you are going to have to do it yourself programmatically. Most SVG rendering libraries are probably not going to provide that feature. However you should be able to get the dimensions of each object via the OS' 2D graphics library. For example, in Android, you can use methods like Path.computeBounds().