How to display Unicode in TPT?

  • Hoita
    11th Sep 2022 Member 0 Permalink

    Such as Chinese, Japanese and Korean,I tried to convert it into Unicode in the editor, but it will not be displayed after compilation

  • LBPHacker
    11th Sep 2022 Developer 0 Permalink
    If your source files are in UTF-8, and the characters you are trying to display are present in the font, you'll get characters displayed correctly. The catch is that only a limited range of characters is supported right now. Support for other character sets (mainly ones that don't require layout support) and built-in translation is planned, but these aren't being developed right now.

    The game uses a custom bitmap font, which includes most Latin and derivative writing systems, but it doesn't include many other important Unicode blocks, such as most CJK characters, although it does include the Hangul Syllables block and just enough other syllables to allow for Korean text to be displayed properly (but Korean text input is still rather broken and built-in translation is not a feature yet at all, so this fact gets very little recognition).

    For Chinese and Japanese, I've considered bundling zpix, but a fundamental problem that this doesn't address too well is that Chinese and Japanese speakers may expect different characters to be displayed using the same Unicode code points.
    Edited 2 times by LBPHacker. Last: 11th Sep 2022
  • Hoita
    11th Sep 2022 Member 0 Permalink

    @LBPHacker (View Post)

     How to change the custom bitmap, or how to bundle zpix, I don't know much about this

  • LBPHacker
    21st Sep 2022 Developer 0 Permalink
    There's no good documentation on the custom bitmap font's format, you'll have to read the code and figure out how it works if you want to programmatically add characters to it. And you definitely want to add characters programmatically if you're planning to add CJK characters; I don't suppose you'd want to draw them by hand.

    zpix is distributed in the BDF format, and we have a python script that can merge BDF fonts into the codebase. In zpix's case, you can do this by running:

    ./fonttool.py addbdf 0 1114111 ~/Downloads/zpix.bdf 0 -2


    which will give you something like this (text taken from the zpix demo):

    image

    Be sure to ask zpix's owner before you publish anything with the font built in, though.
    Edited 2 times by LBPHacker. Last: 21st Sep 2022
  • Hoita
    11th Oct 2022 Member 0 Permalink

    @LBPHacker (View Post)

     Thank you for your help. How can I change the font size?, The characters I display in the game are fixed in size, and I don't know how to change them. Thank you for taking the time to reply!?

  • LBPHacker
    11th Oct 2022 Developer 0 Permalink
    You can't change the size easily (which is to say, it's possible but TPT has no support for it). That's a trait of bitmap fonts: https://en.wikipedia.org/wiki/Computer_font#Bitmap_fonts
    Edited once by LBPHacker. Last: 11th Oct 2022