Kimtaro / kanjivg2svg

Ruby script to convert SVG data from the KanjiVG project
62 stars 10 forks source link

Issue with SVG created for 喩 #4

Closed aphirst closed 5 years ago

aphirst commented 5 years ago

I mentioned this on Reddit, where someone shared a fullset of prerendered PNGs. https://www.reddit.com/r/LearnJapanese/comments/awr5vw/downloading_stroke_order_image/ewufmhi/

The affected kanji is 喩. The fault seems to be with the SVG itself. 21929_frames.svg AE0pQ44

Is this issue further upstream?

Kimtaro commented 5 years ago

Turns out it's an issue both in the SVG and the script. The path data for the 入 group is formatted differently from the other path elements, and the script can't handle that format.

It looks like this:

<path id="kvg:055a9-s4" kvg:type="㇒" d="M 64.900813,10.431453 c -0.04496,1.753402 -0.431606,2.697541 -0.962123,3.884459 -4.88255,10.898068 -14.74656,24.25989 -22.614389,30.032629"/>
<path id="kvg:055a9-s5" kvg:type="㇏" d="M 59.386395,5.3152892 C 65.6228,6.6784373 73.343249,25.137162 82.898922,36.539902 c 2.099248,2.508193 4.239392,4.955045 6.393167,6.318194"/>

But the script can't handle the spaces. It expects the d attribute to be formatted like this:

<path id="kvg:055a9-s4" kvg:type="㇒" d="M64.900813,10.431453c-0.04496,1.753402,-0.431606,2.697541,-0.962123,3.884459,-4.88255,10.898068,-14.74656,24.25989,-22.614389,30.032629"/>
<path id="kvg:055a9-s5" kvg:type="㇏" d="M59.386395,5.3152892C65.6228,6.6784373,73.343249,25.137162,82.898922,36.539902c2.099248,2.508193,4.239392,4.955045,6.393167,6.318194"/>

But given that Jisho, which doesn't use this script anymore, displays this fine (https://jisho.org/search/喩%20%23kanji), I'm inclined to think this should be fixed in the script.

Kimtaro commented 5 years ago

I've updated the script and it looks like it's working correctly now. Try it out and let me know if it looks good to you.

aphirst commented 5 years ago

I'll try to find the time later on. If it does work, it will warrant replacing svgs.tar.gz too, right?

Kimtaro commented 5 years ago

Yeah, I forgot to include svgs.tar.gz yesterday. It's been updated now, based on the latest KanjiVG data and the fixed version of the script.