Ren'Py Can i change default Ren'Py font in other person's game?

athreusclouds

Member
Oct 8, 2023
223
3,129
Hi everybody. I know how to change fonts in a game that you develop and create in Ren'py yourself,
but what i do not know is whether it is even possible to change the default font in a game created by another person?

For example, there is a novel that i really like, but as a font for the main body of text game uses a default Ren'Py font that i don't like. Is there a way to change default Ren'Py font to another one more comfortable in another persons completed game?


There is a fonts.rpa file inside the game folder. I opened it.
Inside it has only 1 font file called NIKEA, but replacing this file with another font while retaining the original name did not helped me.

The game itself uses only 2 types of fonts. The default Ren'Py font for dialogs and Ren'Py font, but only italic, for narrator.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,130
14,809
Is there a way to change default Ren'Py font to another one more comfortable in another persons completed game?
Well, it totally depend on how the game define the font.

If it's through the gui, you need to override the gui.text_font, gui.name_text_font and gui.interface_text_font values by defining them again, but in a file name processed late (some "z_whatever.rpy" file by example).

If it's done through the character, it's all the Character objects that you'll have to override, in the same way.

If it's done through style, just redefining the font property for the "say_dialogue", once again in a file processed late, should works.

If the change happen directly in the "say" screen, you'll need to have access to the rpy file, because the said screen can have been also altered otherwise. What mean that you can make the change directly in the original screen.

And finally, the last way to do, that is exceptional but exist, is when the dev define the font in every single dialog line... I guess that it may be possible to deal with this with a translation that would get rid of the font declaration, coupled to a change in the gui variables, but it would be a pain in the ass.


There is a fonts.rpa file inside the game folder. I opened it.
Inside it has only 1 font file called NIKEA, but replacing this file with another font while retaining the original name did not helped me.
Hmmm ? I'm tempted to say that, either it's not the incriminated font, or it's not the rpa file where the font is.
Ren'Py isn't magician, it will not create a font content from nowhere.
 
  • Red Heart
Reactions: athreusclouds

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,559
2,175
[Is it] possible to change the default font in a game created by another person?
Yes.

Inside it has only 1 font file called NIKEA, but replacing this file with another font while retaining the original name did not help me.
That's unusual. Normally the RenPy script will have a line that uses the font by name. If you change the font file to another - you should see the replacement font.

My first thought is perhaps there's another font file somewhere else in another .rpa.
Though a variation on that... did you delete the .rpa after you'd unpacked it? (You should).
(If RenPy detects two identically named files, it has a tendency to use the timestamp of the files to figure out which one is newer and then use the newest. It could be that your replacement font's file is older than the one in the .rpa archive?

anne O'nymous has already talked about all the places the font file could already be referenced. So I'll just expand a bit on the two likeliest candidates...

My guess (based on the fact you say it mainly only uses 2 fonts) is that you should be looking at the define gui.text_font = ... within the gui.rpy file. It's pretty much the "default" font for the majority of text within the game and tends to be used by style statements everywhere within the standard screens. My second guess would be the screen say(): within the screens.rpy file. It is the screen used by the majority of dialogue spoken by any character and is an obvious place to change the font without changing the gui.text_font value.
 
  • Red Heart
Reactions: athreusclouds

athreusclouds

Member
Oct 8, 2023
223
3,129
anne O'nymous, 79flavors, so in order for me to change fonts in another person's game, i need to make changes to their script? The same way i do it when i change the font settings in Ren'Py when creating my own novel?

I opened the script of this game in a regular online utility for viewing rpa files and that's what i saw there:

Screenshot - Characters.png Screenshot - Fonts.png

It means i have to change the name of the fonts below to the ones i use.
Then save the changes and use this modified script file in the game.

gui.text_font = "DejaVuSans.ttf"
gui.name_text_font = "DejaVuSans.ttf"
gui.interface_text_font = "DejaVuSans.ttf"
+
scripts.rpa/screens.rpyc - "DejaVuSans.ttf"


At the same time in the game folder i will need to create, for example, a fonts folder in which i will place my fonts.
Specifying the path to my fonts in the game script.

For example, like this:

gui.text_font = "fonts/nice-font.ttf"

Am i right?

How do i do this? I have never made changes to someone else's script.

Is there some kind of simple, easy-to-use program for this or?
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,559
2,175
[...] so in order for me to change fonts in another person's game, i need to make changes to their script?

I'll have to reply with the eternal "it depends(™)".

As Anne said in his post, you can create a brand new .rpy file called something like z_overrides.rpy and put any code you want in there.

RenPy mostly* processes files in alphabetical order. So if you have a statement like define gui.text_font = "DejaVuSans.ttf" in the gui.rpy and an almost identical line with define gui.text_font = "fonts/nice-font.ttf" in the z_overrides.rpy file... they will BOTH be run, but since the z_overrides.rpy file will be run last, it will be the value that is used by the game.

*It depends.

By doing that, you leave the original code alone and still use "your" code.

The "depends" part is that not everything can be overridden in a single line. If it's part of a screen or a style, you might need to copy the whole screen/style into your override code.

Of you can just unpack the game and change it. Whatever you find easier.
 
  • Red Heart
Reactions: athreusclouds

athreusclouds

Member
Oct 8, 2023
223
3,129
I'll have to reply with the eternal "it depends(™)".

As Anne said in his post, you can create a brand new .rpy file called something like z_overrides.rpy and put any code you want in there.

RenPy mostly* processes files in alphabetical order. So if you have a statement like define gui.text_font = "DejaVuSans.ttf" in the gui.rpy and an almost identical line with define gui.text_font = "fonts/nice-font.ttf" in the z_overrides.rpy file... they will BOTH be run, but since the z_overrides.rpy file will be run last, it will be the value that is used by the game.

*It depends.

By doing that, you leave the original code alone and still use "your" code.

The "depends" part is that not everything can be overridden in a single line. If it's part of a screen or a style, you might need to copy the whole screen/style into your override code.

Of you can just unpack the game and change it. Whatever you find easier.
Okay i understood.
But how do i open the script to make changes to it?
After all, i can only read it at the moment. I can't unpack it either to make changes to it.
 

peterppp

Member
Mar 5, 2020
459
867
Make a new text file in the "game" directory. Name the file "zzz-fonts.rpy". In the file you write the new font defines with the path to the font you placed in a folder. If you placed font "myfont.ttf" in "/game/gui/fonts/" then you put this in the file:
define gui.text_font = "gui/fonts/myfont.ttf"
define gui.name_text_font = "gui/fonts/myfont.ttf"
define gui.interface_text_font = "gui/fonts/myfont.ttf"
that should do it
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,559
2,175
But how do i open the script to make changes to it?
After all, i can only read it at the moment. I can't unpack it either to make changes to it.

If you can see the .rpy files, you can edit the script.

If you can't see the .rpy file, you need to use a tool like UnRen to unpack things to look at the original script files.
This post explains some of the underlying concepts.

From that point, it's a case of looking at the source code to figure out what you want to do and then create your own override script (or just edit the original).

Which game are you talking about?
Perhaps I could take a look and create the override file you might need. Then you could either just use it, or check it out to see if it is how you would have chosen to do it.
 
  • Red Heart
Reactions: athreusclouds

athreusclouds

Member
Oct 8, 2023
223
3,129
The game is Ms.Denvers and i managed to change the fonts in it about 15 minutes ago after so many hours of strugle thanks to the help of another fan of this game. In fact now i can change everything at all by making my personal, comfortable build and it's very nice considering that i do a small upscale pack for this game. Even a partial rewrite can now be done if there was a need.

However, only the method of making changes to the main script of the game worked.

The option with a neat, separate, small override script in a regular text file,
without the need to change the main script did not worked. Or at least i wasn't successful in it.

Everything seems to be great and i've achieved my goal, but now of course my game folder looks like it was bombed to shreads because all the script and program files were like un-ziped. Of course, i would like to make changes to the font scripts and pack it all back into one large archive scripts.rpa, but i do not know how to do it.
I will tell you how i managed to succeed later if you interested, because now it's time to go to bed and see some dreams.
 

peterppp

Member
Mar 5, 2020
459
867
However, only the method of making changes to the main script of the game worked.

The option with a neat, separate, small override script in a regular text file,
without the need to change the main script did not worked. Or at least i wasn't successful in it.
it works when i try it for the msdenvers game. make sure you get the right path, like dont include "game" in the path
 

athreusclouds

Member
Oct 8, 2023
223
3,129
it works when i try it for the msdenvers game. make sure you get the right path, like dont include "game" in the path
Ye, but i didn't make a mistake here. Donno why it was not working. Maybe because i didn't have python 3 installed? Anyway, i've done everything right now. Using the crviewer website, i extracted only the gui script from scripts.rpa and made changes to it and now everything works smoothly. I no longer need to unpack all the scripts. Now everything is neat and short in game folder. Everything is perfect now.

Thank you guys for your responsiveness, advice and help. You're great.
 
  • Like
Reactions: peterppp

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,559
2,175
The game is Ms.Denvers [...]

I've downloaded it and see why you are have some issues. The game ships with only .rpyc files and they've tweaked something so that UnRen doesn't correctly convert the .rpyc back into an .rpy files.
Thankfuly does.

Back to your original point about fonts...

From what I can see the font is just fine. It's using the standard DejaVuSans.ttf font every other game uses.

The only place it uses the NIKEA.otf font is for some sort of "memories" gallery.

You don't have permission to view the spoiler content. Log in or register now.

Your problem (based on your previous posts) is the use of italics for the story narrator.

1711457485158.png

For me, I'd probably just edit the script (at least, now I can actually access it).

However, you asked about an "override" script, separate from the main game...

Python:
# file = z_overrides.rpy

init 1:

    define narrator = Character(None)

I'd probably go a little further, because (as you would see in other examples of mine from the past), I like the narrator text to appear in pale yellow rather than white. It's a small change, but offers a little differentiation from the spoken text by characters.

Python:
    define narrator = Character(None, what_color="#FFFF66")

To add a bit of explanation.

init is short for initialization. It's part of the script that is run when the game starts up. Normally, it doesn't need to be specified at all... RenPy recognizes the init level commands and processes them at "level 0" (or init 0).

Zero is the default and is used as a priority. Lower numbers are run first, higher numbers are run later. Normally RenPy games stick to using -999 to 999. But the limits are higher. I've used init 1: because it will run after init level 0.
It isn't strictly necessary - because the filename starts with a "z" and so would be processed after anyway. But by using init 1:, the filename could be anything and it removes all doubt.

Anyway, if you just want to use it... download this attachment and put it in your /game/ folder...
 
Last edited:
  • Red Heart
Reactions: athreusclouds