Chinese keeps using squares only[SOLVED]

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

Chinese keeps using squares only[SOLVED]

#1 Post by rebellare »

So, all the documentation I went through resulted in nothing. I tried everything I could think of and the only thing I noticed is that the game name (when the game is turned on) is actually in chinese, everything else is just squares, no matter what I do. I already got russian working long time ago and it did the same thing at first, but I got it working, can't even remember how anymore. The current solution that's out there is "copy east_asian.rpy from /extras", but the extras directory doesn't exist anymore so I can't get the east_asian.rpy file. I'm completely lost now and it's starting to drive me mad. Please help!

I got a menu that lets you choose a language and the chinese choice is:

Code: Select all

imagebutton auto "buttons/lang_choice_chi_%s.png" focus_mask True action [Language("chinese"), Function(font_change), Return(None)]
and the font_change function does this:

Code: Select all

if _preferences.language == u"chinese":
            gui.text_font = "Muyao-Softbrush-2"
            gui.name_text_font = "Muyao-Softbrush-2"
            gui.interface_text_font = "Muyao-Softbrush-2"
            gui.button_text_font = gui.interface_text_font
            gui.choice_button_text_font = gui.text_font
            gui.text_size = 15
            gui.name_text_size = 20
            gui.interface_text_size = 10
            gui.label_text_size = 15
            gui.notify_text_size = 10
            gui.title_text_size = 30
            gui.button_text_size = gui.interface_text_size
            gui.quick_button_text_size = 10
            gui.choice_button_text_size = gui.text_size
            gui.slot_button_text_size = 10
Last edited by rebellare on Fri Mar 11, 2022 9:07 am, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Chinese keeps using squares only

#2 Post by Ocelot »

Changing gui variables in-game does nothing to already existing styles. YOu need to rebuild them.

Also, I believe, such style changes are expected to be done through style translations, since style and gui objects are not saved, and simple reloading can break the game.
< < insert Rick Cook quote here > >

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Chinese keeps using squares only

#3 Post by Imperf3kt »

I also wonder,

Code: Select all

gui.text_font = "Muyao-Softbrush-2"
Shouldn't this include the file extension?

Code: Select all

gui.text_font = "Muyao-Softbrush-2.ttf"
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Chinese keeps using squares only

#4 Post by PyTom »

You can do:

Code: Select all

translate chinese python:
            gui.text_font = "Muyao-Softbrush-2.ttf"
            gui.name_text_font = "Muyao-Softbrush-2.ttf"
            gui.interface_text_font = "Muyao-Softbrush-2.ttf"
            gui.button_text_font = gui.interface_text_font
            gui.choice_button_text_font = gui.text_font
            gui.text_size = 15
            gui.name_text_size = 20
            gui.interface_text_size = 10
            gui.label_text_size = 15
            gui.notify_text_size = 10
            gui.title_text_size = 30
            gui.button_text_size = gui.interface_text_size
            gui.quick_button_text_size = 10
            gui.choice_button_text_size = gui.text_size
            gui.slot_button_text_size = 10
[code]

Note that you do need to stick the font in game/ , as Ren'Py no longer looks at system fonts.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

Re: Chinese keeps using squares only

#5 Post by rebellare »

Thanks for the reply, I've been dabbling since then and already realized that the changes I did changed nothing since they were local so I changed everything to define. Naturally, since they're "define" it just went through everything despite the conditions I set and just did the defines that were furthest below -.-
Currently there are english, spanish, russian, german and chinese and the chinese/russian are giving me the most trouble since it's different characters. I have a font that works for one and a font that works for the other. I made a screen that the players receive upon opening the game and they can re-open it while in main menu:

Code: Select all

screen choose_lang_main:
    zorder 0
    tag menu

    image "bg/lang_choice_bg.jpg"

    vbox:
        imagebutton auto "buttons/lang_choice_eng_%s.png" focus_mask True action [Language(None), Jump("after_lang_choice")]

    vbox:
        imagebutton auto "buttons/lang_choice_ger_%s.png" focus_mask True action [Language(None), Jump("after_lang_choice")]

    vbox:
        imagebutton auto "buttons/lang_choice_spa_%s.png" focus_mask True action [Language("spanish"), Jump("after_lang_choice")]

    vbox:
        imagebutton auto "buttons/lang_choice_rus_%s.png" focus_mask True action [Language("russian"), Jump("after_lang_choice")]

    vbox:
        imagebutton auto "buttons/lang_choice_chi_%s.png" focus_mask True action [Language("chinese"), Jump("after_lang_choice")]
and then I had set up a label to change the fonts and whatever else I needed/wanted, like text size (at least, that's what I planned...)

Code: Select all

label after_lang_choice:
    if preferences.language == "russian":
        $ gui.text_font = "DejaVuSans.ttf"
        $ gui.name_text_font = "DejaVuSans-Bold.ttf"
        $ gui.interface_text_font = "DejaVuSans-Bold.ttf"
        $ gui.button_text_font = gui.interface_text_font
        $ gui.choice_button_text_font = gui.text_font
        #-10
        $ gui.text_size = 23
        $ gui.name_text_size = 30
        $ gui.interface_text_size = 18
        $ gui.label_text_size = 21
        $ gui.notify_text_size = 15
        $ gui.title_text_size = 60
        $ gui.button_text_size = gui.interface_text_size
        $ gui.quick_button_text_size = 16
        $ gui.choice_button_text_size = gui.text_size
        $ gui.slot_button_text_size = 16

    elif preferences.language == "chinese":
        $ gui.text_font = "Muyao-Softbrush-2.ttf"
        $ gui.name_text_font = "Muyao-Softbrush-2.ttf"
        $ gui.interface_text_font = "Muyao-Softbrush-2.ttf"
        $ gui.button_text_font = gui.interface_text_font
        $ gui.choice_button_text_font = gui.text_font
        $ gui.text_size = 28
        $ gui.name_text_size = 35
        $ gui.interface_text_size = 23
        $ gui.label_text_size = 26
        $ gui.notify_text_size = 20
        $ gui.title_text_size = 65
        $ gui.button_text_size = gui.interface_text_size
        $ gui.quick_button_text_size = 21
        $ gui.choice_button_text_size = gui.text_size
        $ gui.slot_button_text_size = 21

    else:#english/spanish/german
        $ gui.text_font = "DejaVuSans.ttf"
        $ gui.name_text_font = "DejaVuSans-Bold.ttf"
        $ gui.interface_text_font = "DejaVuSans-Oblique.ttf"
        $ gui.button_text_font = gui.interface_text_font
        $ gui.choice_button_text_font = gui.text_font
        #-10
        $ gui.text_size = 28
        $ gui.name_text_size = 35
        $ gui.interface_text_size = 23
        $ gui.label_text_size = 26
        $ gui.notify_text_size = 20
        $ gui.title_text_size = 65
        $ gui.button_text_size = gui.interface_text_size
        $ gui.quick_button_text_size = 21
        $ gui.choice_button_text_size = gui.text_size
        $ gui.slot_button_text_size = 21

    return
This is pretty much where I'm at now. If only I could somehow change these variables and have them STAY after leaving the main menu, I'd be golden.
I hope this shows what I'm stuck at currently in more detail. Also, I did put all the languages into the /game folder and they all work, separately, but not when I try giving the players a choice. I would like it to remain as a "main menu only" choice so the lack of knowledge to make the changes stay "changed" is killing me.

rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

Re: Chinese keeps using squares only

#6 Post by rebellare »

Of course, if there is a smarter, simpler option to do what I'm trying to, I'd be really grateful

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Chinese keeps using squares only

#7 Post by PyTom »

I'm a bit confused by what you're doing here. You seem to be trying to implement your own translation system, that's not the one that's implemented in Ren'Py. By setting the translations in a translate python block, they'll be updated when the language changes, and when the game starts and restarts.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

Re: Chinese keeps using squares only

#8 Post by rebellare »

Is this it?

Code: Select all

translate piglatin style default:
    font "stonecutter.ttf"
translate piglatin python:
    style.default.font = "stonecutter.ttf"
If yes, what's the difference? Since it says equivalently, I'm presuming it's either, right?

rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

Re: Chinese keeps using squares only

#9 Post by rebellare »

Could you maybe show how it'd look for my project? just for one language, I'll do the rest, of course. What I want is the abilty to choose which font for dialgoue, names and interface and the sizes for them all

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Chinese keeps using squares only

#10 Post by Ocelot »

An example of how changing default font affects say screen:

Code: Select all

translate incomprehensible style default:
    font "CNTDN_.TTF"

translate fancy style default:
    font "Bolero script.ttf"

translate typewriter style default:
    font "B52.ttf"

screen lang_change():
    vbox:
        align (1.0, 0.0)
        label "What font do you want to use?"
        textbutton "normal" action Language(None)
        textbutton "fancy" text_font "Bolero script.ttf" action Language("fancy")
        textbutton "typewriter" text_font "B52.ttf" action Language("typewriter")
        textbutton "incomprehensible" text_font "CNTDN_.TTF" action Language("incomprehensible")


label start:
    show screen lang_change
    "Hello"
    "This is test of font translation"
    "Enjoy"
    return
In action: https://i.imgur.com/k16i74m.gif

Notice, that a lot of screen elements did not change. That is because they override default font somewhere in their styles. You will need to translate those too.
< < insert Rick Cook quote here > >

rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

Re: Chinese keeps using squares only

#11 Post by rebellare »

So in my case, it'd be:

Code: Select all

translate chinese style default:
    font "ChineseFontThatIFound.ttf"
and what would I use to change to font of names and my interface?
I mean, the equivalents of "gui.name_text_font" and "gui.interface_text_font" since font is equivalent to gui.text_font, I'm presuming

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2405
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Chinese keeps using squares only

#12 Post by Ocelot »

1) Check the styles those entries use. Either checking corresponding screens, or pressing Shift+I while hovering above text you want to inspect to open Style Inspector:

Pressing Shift+I here to find out label style:
Image
Guess it is label_text...
Image
But actually, font is overriden earlier by gui_text!
Image
I can just replace that instead!

2) Translate styles you need. You probably want styles gui_text and button_text. Those should account to almost 100% of fonts used in default gui.
< < insert Rick Cook quote here > >

rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

Re: Chinese keeps using squares only

#13 Post by rebellare »

Great! Thanks a lot! I'll try making it work today, fingers crossed

rebellare
Regular
Posts: 34
Joined: Mon Nov 06, 2017 9:34 am
Contact:

Re: Chinese keeps using squares only

#14 Post by rebellare »

Made it work with styles, gonna put the subject as resolved. Thanks a lot, everyone!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]