iOS Question iSVG Error

nobbi59

Active Member
Licensed User
Longtime User
Hi,

Im trying to display a SGV file in my app using iSVG. When I load the SVG file, I get the following error:

B4X:
*** Assertion failure in +[SVGKPointsAndPathsParser readCoordinate:intoFloat:], /Users/b4j/Downloads/SVGKit-2.x/Source/Parsers/SVGKPointsAndPathsParser.m:322

Ive done a bit of research and found this answer on github: https://github.com/SVGKit/SVGKit/issues/445

It says that seperating commas are the problem. I replaced all commas with spaces but its still not working. Everything works fine in Chrome and Firefox.

Link To SVG File: https://lt-tech.net/misc/logo.svg
 

nobbi59

Active Member
Licensed User
Longtime User
Thanks for your answer, @Erel

That was my guess, too. Has anyone encountered the problem and has an idea how to fix it? Maybe there is a trick to make the svg compatible with SVGKit.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Make SVG as simple as possible. Save in format 1.0 (not in 1.1). Then remove in text editor all "excess" tags.
For example, my SVG looks so
B4X:
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="108px" height="108px" viewBox="0 0 108 108">
<path fill="..."/> (many statements)
</svg>
Works in B4A and B4i

If noticed that some graphic editors, for instance, do not include width and height properties in SVG tag.
Post your SVG, I can try to "correct" it.
 
Last edited:
Upvote 0

nobbi59

Active Member
Licensed User
Longtime User
Thanks for the Info. Ill try it on my own first, dont want others to do the work im supposed to do :D

But if I still get Errors, ill ask you again.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
With inkScape (free) you also have some options to clean the svg, convert shapes to paths or select how it gets exported.

This is an easy one so I don't see why it should freak out on it.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
It seems that you're lucky with your browser tests.

The svg on your web page doesn't display right in inkScape nor Illustrator.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
Here you go...

B4X:
Dim mySVG As SVG
mySVG.Initialize(File.DirAssets,"drawing.svg")   

Dim iv As ImageView
iv.Initialize("")
iv.Bitmap=mySVG.Export(200,200)
Page1.RootPanel.AddView(iv,0,0,200,200)

B4X:
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="22.6mm" width="22.6mm" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" viewBox="0 0 80 80">
<defs>
<style>.cls-1{fill:#E2061A;}.cls-2{fill:#fff;}</style>
<style>.cls-1{fill:#E2061A;}.cls-2{fill:#fff;}</style>
</defs>
<g transform="translate(-237 -347)">
<g transform="translate(237 347)">
<path fill="#f00" d="m0 40c0-22.1 17.9-40 40-40s40 17.9 40 40-17.9 40-40 40-40-17.9-40-40z"/>
<g fill="#fff">
<polygon points="24.7 48.3 28.7 27.6 22.2 27.6 21 34.2 14.9 34.2 16.2 27.6 9.77 27.6 9.77 27.6 9.77 27.6 5.81 48.3 12.2 48.3 13.8 40.1 19.9 40.1 18.4 48.3"/>
<polygon points="54.3 27.6 50.4 48.3 56.4 48.3 60.3 27.6 54.3 27.6"/>
<path d="m68.1 37.1c-1.92 0-2.74 2.1-3.26 3.9s0.291 3.55 1.86 3.55 2.74-1.86 3.15-3.44c0.471-1.92 0.23-4-1.75-4v-0.01zm1.26-3.93c8 0 8.16 9.32 3 13.6-1.63 1.4-4 1.63-6.76 1.63-7.63 0-8.33-8.51-4-12.9 2.39-2.39 4.84-2.33 7.69-2.33h0.071z"/>
<path d="m36.9 41.2c-1.16 0.7-4.66 0.471-5 2-0.29 0.929 0.12 1.52 1.16 1.52 2.62 0 3.26-1.46 3.85-3.55l-0.01 0.03zm-0.61 5.74c-2 1.28-3.38 1.4-5.83 1.4-2.68 0-4.66-2-3.79-5 1.69-6.53 11-3.79 11.5-5.24 0.29-0.87-0.12-1.81-1.81-1.81-1.05 0.126-1.87 0.952-2 2h-5.65c1-4 3.15-5.13 8.91-5.13 4.83 0 6.7 2.91 5.82 6.12l-1.63 6.87c-0.229 0.931-0.35 1.51 0.121 1.86l-0.061 0.289h-5.65c-0.018-0.469 0.023-0.939 0.12-1.4l-0.029 0.04z"/>
<polygon points="43 48.3 45.8 33.6 51.5 33.6 48.8 48.3 43 48.3"/>
<polygon points="46.2 31.6 46.9 27.6 52.6 27.6 51.9 31.6 46.4 31.6"/>
</g>
</g>
</g>
</svg>

logo.png
 
Upvote 0
Top