parsimonhi / animCJK

Draw animated Japanese characters (Kanji and Kana), Korean characters (Hanja) and Chinese characters (Hanzi) in correct stroke order using svg, free open-source code.
284 stars 72 forks source link

How to match svg files with data types #45

Closed jmgawecki closed 3 months ago

jmgawecki commented 3 months ago

Hey there. Thank you very much for this package! I am experimenting with kanjis myself. I am trying to display the kanji in my app, however, I am not quite sure how to match the svg file with the kanji. on the example of 三: This is the reference I found: {"character":"三","set":["hanja1800a"],"definition":"three","radical":"一","decomposition":"⿳一一一","acjk":"三⿳一.1一1一1"}

kanji for 三 seems to correspond to 19977.svg file.

Looking at those two, I can't see the correlation, I failed to locate it in inside the svg too. I am sure there is something im missing! Any help appreciated.

parsimonhi commented 3 months ago

1) You probably found {"character":"三","set":["hanja1800a"],"definition":"three","radical":"一","decomposition":"⿳一一一" ,"acjk":"三⿳一.1一1一1"} in the Ko.txt dictionary which is the dictionary for Korean Hanja (not Japanese Kanji). The dictionary for Japanese is DictionaryJa.txt.

2) DictionaryJa.txt itself does not contain the character shape, nor a way to identify in which file the character shape is stored (it contains the character itself, an English translation, the radical, and a special decomposition used by some examples of animCJK). Kanji shapes are stored in the svgsJa folder as svg files. And you are right, the svg file for "三" is 19977.svg

The number in the svg file names (19977 for "三" in your example) is simply the decimal unicode value of the character ("三" in your example).

3) Are you the author of the application you want to use? What type of app is this? To use svg files in your application, you will probably need to write code (or script) that calculates the decimal Unicode of the character. How to do this depends on the application you want to use.

4) A way to calculate the decimal Unicode of a character using php can be found in samples/_php/unicode.php (see the decUnicode() function which takes the character itself as parameter). Writing a similar function in another language is not very difficult.

Hope this helps!

jmgawecki commented 3 months ago

Yes thanks I figured this out after a while. I am using kanjis in iOS project so just needed a swift function. Thank you