Page 1 of 1

Font Selection Option (For use with OpenDyslexic Font)

Posted: Wed Apr 20, 2016 3:38 pm
by BáiYù
This function allows players to choose which font they would like to use while playing the game. This does not affect the font used for the GUI.

Code is from the All of Cute Demon Crashers! custom code thread, I simply dug it out from all the script files.

Code: Select all

# Insert into the options.rpy
init -1 python hide:

    # Fonts that may be chosen by the user
    renpy.register_style_preference(
        "text", "Default", style.say_dialogue, "font", "gui/default.ttf")
    renpy.register_style_preference(
        "text", "Open Dyslexic", style.say_dialogue, "font", "gui/OpenDyslexic-Regular.otf")

Code: Select all

#insert into screens.rpy in the Preference screen section
            frame:
                style_group "pref"
                has vbox
                
                label _("Font Selection")
                textbutton "Default" action StylePreference("text", "Default")
                textbutton "Open Dyslexic" action StylePreference("text", "Open Dyslexic")
Download the OpenDyslexic font from their official website.

Re: Font Selection Option (For use with OpenDyslexic Font)

Posted: Tue Aug 28, 2018 12:47 pm
by NeuroDolphin
Thanks a lot for posting this here, it's really nice to try and make games that much more accessible for people.
Thanks to you, my game now supports Open Dyslexia!

Re: Font Selection Option (For use with OpenDyslexic Font)

Posted: Thu Aug 30, 2018 6:22 am
by Andredron
Size font in option Renpy

Code: Select all

# screens.rpy
#. ,,
Screen preferences:
     tag menu
     # etc. flat screen
     #. ,,
     # at the very end, add this code:
             frame:
                 style_group "pref"
                 has a vbox
                 label _ ("Text Size% s"% (ts_min + persistent.ts))
                 bar value FieldValue (constant, "ts", ts_max - ts_min)
     on 'hide' action SetTS ()
     on 'replace' action SetTS ()
 
init python:
     # font sizes
     ts_min = 16 # from these
     ts_max = 48 # still
     if they are persistent.ts is not None:
         persistent.ts = 0
     def setts ():
         style. default.size = ts_min + persistent.ts
         style. rebuild ()
     SetTS = renpy. curry
     setts ()
#
https://pastebin.com/PD4XLBAk

https://yadi.sk/d/pnm13XXL35aSWN working example

Re: Font Selection Option (For use with OpenDyslexic Font)

Posted: Fri Jan 24, 2020 3:34 pm
by Ayael
I did a complementary tutorial to change all font for OpenDyslexic (including menu, label and so on).

(You can find it here : viewtopic.php?f=51&t=57895)

Re: Font Selection Option (For use with OpenDyslexic Font)

Posted: Sun Feb 20, 2022 1:29 am
by thetiredone
Hello, I know this is an old thread, but can someone help me with getting this work alongside renpy input. Whenever it gets to the naming screen it shows that an exception has occurred.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 96, in script
    $ mc = renpy.input("Please give her a name. Max 12 characters", default = "Clara", allow=" 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=12)
  File "game/script.rpy", line 96, in <module>
    $ mc = renpy.input("Please give her a name. Max 12 characters", default = "Clara", allow=" 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=12)
Exception: Could not find font u'OpenDyslexic-Regular.otf'.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 96, in script
    $ mc = renpy.input("Please give her a name. Max 12 characters", default = "Clara", allow=" 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=12)
  File "renpy/ast.py", line 928, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "renpy/python.py", line 2245, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "game/script.rpy", line 96, in <module>
    $ mc = renpy.input("Please give her a name. Max 12 characters", default = "Clara", allow=" 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", length=12)
  File "renpy/exports.py", line 935, in input
    rv = renpy.ui.interact(mouse='prompt', type="input", roll_forward=roll_forward)
  File "renpy/ui.py", line 298, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "renpy/display/core.py", line 3325, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
  File "renpy/display/core.py", line 3839, in interact_core
    self.draw_screen(root_widget, fullscreen_video, (not fullscreen_video) or video_frame_drawn)
  File "renpy/display/core.py", line 2565, in draw_screen
    renpy.config.screen_height,
  File "render.pyx", line 492, in renpy.display.render.render_screen
  File "render.pyx", line 263, in renpy.display.render.render
  File "renpy/display/layout.py", line 826, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 263, in renpy.display.render.render
  File "renpy/display/layout.py", line 826, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 263, in renpy.display.render.render
  File "renpy/display/layout.py", line 826, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 263, in renpy.display.render.render
  File "renpy/display/screen.py", line 688, in render
    child = renpy.display.render.render(self.child, w, h, st, at)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 263, in renpy.display.render.render
  File "renpy/display/layout.py", line 826, in render
    surf = render(child, width, height, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 263, in renpy.display.render.render
  File "renpy/display/layout.py", line 1264, in render
    st, at)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 263, in renpy.display.render.render
  File "renpy/display/layout.py", line 1029, in render
    surf = render(d, width - x, rh, cst, cat)
  File "render.pyx", line 170, in renpy.display.render.render
  File "render.pyx", line 263, in renpy.display.render.render
  File "renpy/text/text.py", line 2096, in render
    virtual_layout = Layout(self, width, height, renders, drawable_res=False, size_only=True)
  File "renpy/text/text.py", line 639, in __init__
    glyphs = ts.glyphs(s, self)
  File "renpy/text/text.py", line 248, in glyphs
    fo = font.get_font(self.font, self.size, self.bold, self.italic, 0, self.antialias, self.vertical, self.hinting, layout.oversample)
  File "renpy/text/font.py", line 702, in get_font
    face = load_face(fn)
  File "renpy/text/font.py", line 643, in load_face
    raise Exception("Could not find font {0!r}.".format(orig_fn))
Exception: Could not find font u'OpenDyslexic-Regular.otf'.

Windows-10-10.0.19041
Ren'Py 7.4.11.2266
Memory Ghosts 0.1
Sat Feb 19 21:27:31 2022