Change Font Settings

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
ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

Change Font Settings

#1 Post by ArizaLuca »

I do want to change the font in the game, but have an option to change it to something else. Basically you would go to the game settings (in the game) and pick your font. Is there a way to code that?

Kind of like Disaster Log C by Sofdelux Studio-- if you go to the settings, you can find an option to change the font to something easier to read.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Change Font Settings

#2 Post by Per K Grok »

ArizaLuca wrote: Tue Nov 13, 2018 5:23 pm I do want to change the font in the game, but have an option to change it to something else. Basically you would go to the game settings (in the game) and pick your font. Is there a way to code that?

Kind of like Disaster Log C by Sofdelux Studio-- if you go to the settings, you can find an option to change the font to something easier to read.
One, somewhat hacky, way you could get that effect is having a variable for deciding which font to use, you could call the variable ClearFont.

Code: Select all

if ClearFont==False:
    m "This is all I have to say."
elif ClearFont==True:
    m "{font=clear.tff}This is all I have to say.{/font}"
You could put this into a function to make it easier to use.

Kunabee
Newbie
Posts: 6
Joined: Thu Jul 07, 2011 2:33 am
Contact:

Re: Change Font Settings

#3 Post by Kunabee »

This is actually super, super easy if you're looking to change the entire game font!

So if, let's say, you have your default font, ren'py's default, and OpenDyslexic fonts. All you'd have to do is...

In screens.rpy, find the preferences screen. There should be a section that basically says 'add more options here'. Then, put:

Code: Select all

                vbox:
                    style_prefix "radio"
                    label _("Font Choice")
                    textbutton _("Default") action gui.SetPreference("font", "yourfonthere.ttf")
                    textbutton _("DejaVu Sans") action gui.SetPreference("font", "dejavusans.ttf")
                    textbutton _("OpenDyslexic") action gui.SetPreference("font", "OpenDyslexic.otf")
Next, go ahead and comment out define gui.text_font, define gui.name_text_font, and define gui.interface_text_font in the gui.rpy. Then find a spot to add:

Code: Select all

define gui.text_font = gui.preference("font", "yourfonthere.ttf")
define gui.name_text_font = gui.preference("font", "yourfonthere.ttf")
define gui.interface_text_font = gui.preference("font", "yourfonthere.ttf")
Here's the documentation: https://www.renpy.org/doc/html/gui_adva ... ml#example

Of course, there are a few things to keep in mind...
1 - Your fonts should be roughly the same size. Some fonts are unreadable at 12, whereas others look really big. Your fonts should all about line up at each size or this won't work.
2 - If your interface and name are different fonts from the in-game text, then you can take away the 'name' and 'interface' and not comment out the originals.
3 - You have to have font size as a different option; I've seen no way to combine options (maybe someone else knows how to do that?) which would, in that case, take care of #1
4 - You could do this with as many options as you wanted to add, including stuff not involving the gui [take away the 'gui' prefix (SetPreference)] and you could make it toggleable instead of options (TogglePreference).

ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

Re: Change Font Settings

#4 Post by ArizaLuca »

Thank you, Kunabee! That looks very helpful.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]