Example of use:
1. Create a fonts folder in your game directory, and put all fonts in there.
2. Add this code to the screen main_menu() like this, or anywhere else you want to preview a font with your game's text.
Code: Select all
# screens.rpy
########## [1/4] ADD THIS BLOCK ###########
init python:
import re
# this gets a dir list of files
def file_list(dir=""):
list = renpy.list_files()
rv = []
for f in list:
if re.match(dir,f):
rv.append(f[(len(dir)):])
return rv
########## /ADD THIS BLOCK ###########
########## [2/4] ADD THIS VARIABLE ###########
default cycleFontIndex = 0
screen main_menu():
################ [3/4] ADD THIS BLOCK ############
# access all fonts in the fonts folder in the game directory
$ files = file_list("fonts")
# hotkeys that you can change if you want that change index value
key "i" action SetVariable('cycleFontIndex', cycleFontIndex+1)
key "u" action SetVariable('cycleFontIndex', cycleFontIndex-1)
vbox:
# debug to verify the index is working and font files are successfully accessed
text str(cycleFontIndex)
text str(files[cycleFontIndex])
##################/ADD THIS BLOCK ##################
if gui.show_name:
vbox:
style "main_menu_vbox"
text "[config.name!t]":
font "fonts" + files[cycleFontIndex] ########## [4/4] ADD THIS FONT STYLE ###########
style "main_menu_title"
Keep in mind, putting this part in a style does not work.
Code: Select all
font "fonts" + files[cycleFontIndex]
Code: Select all
textbutton "Test":
text_font "fonts" + files[cycleFontIndex]
action NullAction()