Ren'Py Translate font defined in displayable?

gojira667

Member
Sep 9, 2019
289
274
Can you set a different font via Ren'Py's translation system if someone chose to define it directly in the displayable? E.G.
Code:
    text _("Save") color "#000" font "stonecutter.ttf"
I know you can rename a new font to the existing one (stonecutter.ttf) then place it in the tl/LANG specific folder to override the original. Though you obviously lose access to the original font this way in that language...
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,602
2,242
Can you set a different font via Ren'Py's translation system if someone chose to define it directly in the displayable? E.G.
Code:
    text _("Save") color "#000" font "stonecutter.ttf"

I'd suggest just trying it.
RenPy will normally add anything within the _( ) delimiters to a translation.
I presume it isn't just limited to one translation block per line.

Python:
# Try...
    text _("Save") color "#000" font "stonecutter.ttf"

# Then try...
    text _("Save") color "#000" font _("stonecutter.ttf")

Worse thing that happens is that it results in an error. Or it appears within the translation file.
Then you'll have found the answer for yourself.

I'd normally question "Why?". But if you wanted the Spanish translation to be shown in Comic-Sans... that's your creative choice as a developer to make.
 
  • Like
Reactions: gojira667

gojira667

Member
Sep 9, 2019
289
274
I'd normally question "Why?". But if you wanted the Spanish translation to be shown in Comic-Sans... that's your creative choice as a developer to make.
Heh, different alphabet. It's tw_ch and the guy actually overwrote the default font. It needs the double underscore variant, __(s), but it works! :D

Guess I still don't understand exactly what layer Ren'Py does such translations. I'm fairly certain almost all of the displayable level font defines are actually gratuitous, but it's good to have a solution for those that aren't.(y)
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,602
2,242
Guess I still don't understand exactly what layer Ren'Py does such translations.

As I understand it, RenPy effectively does two passes for translations.

Anything part of a "normal" piece of dialogue that would be displayed by the game is translated by default. Think "any string that would be executed at runtime within a label".

Anything that isn't dialogue, but is part of the game (contents of screens for example) need to be manually flagged by the developer. These are not translated by default, but using _( ) means they will be.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,620
15,601
Can you set a different font via Ren'Py's translation system if someone chose to define it directly in the displayable? E.G.
Code:
    text _("Save") color "#000" font "stonecutter.ttf"
Well, if you choose to not use style properties, but define a whole new property, you should then benefit from Ren'Py ability to :

Python:
style myNavigationButtons is navigation_button
style myNavigationButtons_text is navigation_button_text:
    font "stonecutter.ttf"

translate LANGUAGE_NAME style myNavigationButtons_text:
    font "whatever_alternate_font.ttf"

screen navigation():
    [...]

    text _("Save") color "#000" style "myNavigationButtons"