korlibs-archive / korge-next

Moved to https://github.com/korlibs/korge
75 stars 37 forks source link

SVG renderer issue #435

Closed Kietyo closed 2 years ago

Kietyo commented 2 years ago

Describe the bug

suspend fun main() = Korge(width = 640, height = 360, bgcolor = Colors.LIGHTGRAY) {
    val tonPng = resourcesVfs["tiles/Regular/Man1.svg"].readSVG().render()
    image(tonPng) {
        scale = 0.5
    }
}

Expected:

image

Actual:

image

File: Man1

More examples of svg files with messed up rendering can be found here:

https://github.com/FluffyStuff/riichi-mahjong-tiles

soywiz commented 2 years ago

This seems to be the offending path:

        <path
           sodipodi:nodetypes="cccccscccccccccsccccccccccc"
           inkscape:connector-curvature="0"
           id="path6021"
           d="m -834.43931,229.52922 c -2.37961,3.3e-4 -5.11545,0.35227 -7.98633,0.67579 -25.98124,4.23953 -44.63197,13.66167 -87.7832,12.14062 -5.84133,0.0296 -10.79709,3.10802 -10.5918,7.58984 0.41578,9.89302 7.70014,62.17673 8.30469,66.88868 0.85285,6.41756 9.79015,6.98803 10.96679,1.34179 0.21553,-1.03423 0.2214,-3.95763 0.0977,-7.99609 0.54781,-1.14352 1.39786,-2.02021 2.30859,-2.18359 l 56.98242,-5.0918 c 0.57955,0.007 1.01412,0.54453 1.32032,1.33008 -0.4418,20.09339 -0.68432,39.74185 -0.25391,46.62304 0.12358,1.52015 0.0514,3.12015 1.57031,4.48635 3.62687,3.0336 24.10801,1.3634 29.40821,-1.9473 1.46854,-1.0778 1.9999,-1.583 2.19726,-3.83006 -2.96095,-33.99173 -0.66802,-77.2174 1.60547,-110.87305 0.59643,-7.45293 -2.91134,-9.15502 -8.14648,-9.1543 z m -26.98047,16.76368 c 5.65219,-1.38928 2.02203,15.82857 0.0879,15.87695 l -58.82813,4.61133 c -5.12716,-1.0242 -4.8804,-13.06608 -1.42188,-13.22852 26.63848,-0.89616 35.74375,-3.18112 60.16211,-7.25976 z m -0.12891,29.15234 c 1.70565,-0.1306 2.01753,12.38455 -0.38086,12.58598 l -57.32031,4.79687 c -4.10107,-1.15065 -4.35221,-11.96168 -0.7793,-12.49218 z"
           style="fill:#b93c3c;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />

And it seems to be because it uses exponential notation in 3.3e-4, replacing it with 0.0033 works. I'm going to check the path parser