ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.33k stars 254 forks source link

[bug] Drawing CJK characters #165

Open myevan opened 5 years ago

myevan commented 5 years ago

rot.js has a bug when drawing CJK characters in node (ok in web)

1) First bug is rot.js does not support CJK unicode blocks

https://en.wikipedia.org/wiki/Unicode_block

  • 0x1100 ~ 0x11FF (Korean: optional)
  • 0x2E80 ~ 0x9FFF (CJK)
  • 0xA960 ~ 0xA97F (Korean: optional)
  • 0xAC00 ~ 0xD7FF (Korean)

2) CJK characters are full-width characters, but they are strangely printed in node. In english, it's like this: Hello -> Hello or H e l l o (안녕 -> 안녕 or 안 녕)

node english (ok)

rot js_draw_text_english

node korean (bug)

rot js_draw_text_bug_korean

node japanese (bug)

rot js_draw_text_bug_japanese

3) rot.js needs special work to draw CJK characters correctly and I tried to fix the bug.

https://github.com/myevan/js-ecs/commit/8bf688bf0c69aa07c7860dc816a4014b3d03d896

node korean (fixed)

rot js_draw_text_fixed_korean

node japanese (fixed)

rot js_draw_text_fixed_japanese

web korean (no problem)

rot js_draw_text_fixed_korean_in_web

thanks.

ondras commented 5 years ago

Hi @myevan ,

thanks for the report! It would be great if you managed to send a PR, provided you were already able to fix the issue.

myevan commented 5 years ago

hi @ondras, thank you for your answer. i'm a beginner in javascripting and will need some time for making the PR : )