Closed yquemener closed 5 years ago
Hi, This is a good idea to add parsing of /u and /0x codes. I hope some day, minetest engine and formspec will be able to deal with any chars.
I have two remarks on your PR:
First one is, it would be much better to modify font_api than sign_api. This would make non-sign mods benefit of this improvement. Decoding should occur in Font:render
, and more precisely in Font:get_next_char
, making it detect /u and /0x codes.
Second one, I'm not sure the way you do decoding can handle mixed /0x or /u codes with normal chars. I haven't tested, only read the code, but it seems that normal text is stripped out if there is one /0x or /u code in the string. Anyway if you modify get_next_char
, the encode_to_utf8
function will not be needed anymore.
Thanks! Will look into it in a few days.
So that was two excellent remarks. The second one made me ditch the \0x
and \u
format, which are both problematic, in favor of HTML's notation: ģ
which makes it much easier to mix ascii and unicode.
And the first remark made me move the parsing to font_api
but then the infotext was not parsed anymore. At this point I read more deeply in your code and realized that your modpack actually handles unicode correctly everywhere, that the solution is probably more in feeding it correct unicode strings upstream and let it handle it correctly.
Most of minetest handles unicode correctly, it is just irrlicht UI that we need to bypass with that parsing. I'll need to do exactly the same in at least 4 other mods (default's signs and books, a map mod and the mission mod) so instead I propose to make a mini-mod, make it an optional dependency, like intlib, and just add a few calls in on_receive_fields
functions. If you don't mind I'll soon submit a brand new PR for that.
Hi! I needed to add a pre-parsing of text in order to bypass formspec's limitation in terms of character inputs. That allowed me to input japanese character and display them on signs: https://forum.minetest.net/viewtopic.php?f=9&t=23112
I would understand that you consider that too hacky for merging, but just in case, here is a PR. I am open to cleaner suggestions.