Someone translated my game to Chinese, but I don't know how to change to a Chinese font when you choose it in the menu. So everything shows up as rectangles:
https://www.renpy.org/wiki/renpy/doc/co ... d_Japanese:
init:
$ style.default.font = "chinese.ttf" #this is my chinese font name
$ style.default.language = "eastasian"
But it doesn't have an effect. I feel like it's probably being overridden by me setting the default menu/dialogue fonts elsewhere like gui.rpy?
Do I need to make a class that will change the default font to the Chinese one, and then in my Settings menu do something like this?
textbutton "中文" action Language("traditional_chinese") ToggleField(persistent, "chineseFont")
(I'm not a programmer, sorry if this sounds wonky)
Or is there an obvious method I'm missing? Thanks in advance for any advice!
I've added a Chinese font to the game directory with my other fonts, and tried adding the lines of code from this [SOLVED] Toggling between English/Chinese font for game translation
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.
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.
- hassohappa
- Regular
- Posts: 33
- Joined: Thu Oct 22, 2015 8:51 pm
- Tumblr: me-patra
- Contact:
[SOLVED] Toggling between English/Chinese font for game translation
Last edited by hassohappa on Thu Feb 01, 2018 11:02 pm, edited 1 time in total.
- ComputerArt.Club
- Veteran
- Posts: 427
- Joined: Mon May 22, 2017 8:12 am
- Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
- Location: Taiwan
- Contact:
Re: Toggling between English/Chinese font for game translation
I'll bump this for you since I am also working on a Chinese game. I'm still working in the art for mine though, I haven't started coding it yet.
First thought that came to mind, are you using Editra? I believe it does not support Chinese characters, you may need to try a different editor if you haven't already.
First thought that came to mind, are you using Editra? I believe it does not support Chinese characters, you may need to try a different editor if you haven't already.
Facebook:
Renpy Creators and Enthusiasts Facebook Group
My latest game:
Famous Fables: Read, Learn and Play - Android App for teaching children to read
Creative Commons stuff:
Shape transitions,
100+ 360° photos of Japan,
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Toggling between English/Chinese font for game translation
The simplest way is probably to use gui.preference for the font and add actions to the language swap buttons.
This Page outlines how it works.
Alternatively the translate style method could work if you can understand what to do (it confuses me as it says 'translate style python:' which makes no sense, lol)
This Page outlines how it works.
Alternatively the translate style method could work if you can understand what to do (it confuses me as it says 'translate style python:' which makes no sense, lol)
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
- Donmai
- Eileen-Class Veteran
- Posts: 1960
- Joined: Sun Jun 10, 2012 1:45 am
- Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
- Projects: Slumberland
- Location: Brazil
- Contact:
Re: Toggling between English/Chinese font for game translation
If I understood it correctly, add this to any rpy file:
Code: Select all
translate english style default:
font "fonts/your_english_font_name_here.ttf"
translate chinese style default:
font "fonts/your_chinese_font_name_here.ttf"
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)
TOIRE NO HANAKO (A Story About Fear)
- hassohappa
- Regular
- Posts: 33
- Joined: Thu Oct 22, 2015 8:51 pm
- Tumblr: me-patra
- Contact:
Re: Toggling between English/Chinese font for game translation
This worked, thank you so much! In English, I used multiple fonts in different places (for example, menus, dialogue), so I have to add that extra line to many styles. Here's a snippet of what it looks like in my rpy files, for anyone else wondering how to do it:Donmai wrote: ↑Thu Feb 01, 2018 2:59 pm If I understood it correctly, add this to any rpy file:Code: Select all
translate english style default: font "fonts/your_english_font_name_here.ttf" translate chinese style default: font "fonts/your_chinese_font_name_here.ttf"
Code: Select all
style main_menu_hbox:
font "YunusH.ttf"
spacing 21
translate traditional_chinese style main_menu_hbox:
font "traditional_chinese.ttf"
style main_menu_button_text:
xanchor 0.5
xalign 0.5
text_align 0.5
font "YunusH.ttf"
size 45
color "#c1adff"
hover_color "#ffcef2"
translate traditional_chinese style main_menu_button_text:
font "traditional_chinese.ttf"
size 20 #you can also change other stuff in the style for different language versions! so handy!
Code: Select all
textbutton _("OpenDyslexic") action gui.TogglePreference("font", "OpenDyslexic-Regular.otf", "DejaVuSans.ttf")
I am still using Editra, and the Chinese characters are showing up inside the editor and in-game just fine. I'm not sure if my translator typed the characters in a different word processor and then pasted them into Editra, but it looks like once they are there, there's no issue.ComputerArt.Club wrote: ↑Thu Feb 01, 2018 8:00 am I'll bump this for you since I am also working on a Chinese game. I'm still working in the art for mine though, I haven't started coding it yet.
First thought that came to mind, are you using Editra? I believe it does not support Chinese characters, you may need to try a different editor if you haven't already.
- ComputerArt.Club
- Veteran
- Posts: 427
- Joined: Mon May 22, 2017 8:12 am
- Completed: Famous Fables, BoPoMoFo: Learn Chinese, Santa's workshop, Cat's Bath, Computer Art Club
- Location: Taiwan
- Contact:
Re: Toggling between English/Chinese font for game translation
Right, I see now that Renpy states that:hassohappa wrote: ↑Thu Feb 01, 2018 10:54 pm I am still using Editra, and the Chinese characters are showing up inside the editor and in-game just fine. I'm not sure if my translator typed the characters in a different word processor and then pasted them into Editra, but it looks like once they are there, there's no issue.
So I guess its more of an issue of inputting it inside the program rather than pasting it from another program. Glad to hear that your problem is solved!Editra currently lacks the IME support required for Chinese, Japanese and Korean text input.
Facebook:
Renpy Creators and Enthusiasts Facebook Group
My latest game:
Famous Fables: Read, Learn and Play - Android App for teaching children to read
Creative Commons stuff:
Shape transitions,
100+ 360° photos of Japan,
Who is online
Users browsing this forum: 3N16M4