[SOLVED] Issue with importing BMFonts

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
User avatar
inkacorn
Newbie
Posts: 6
Joined: Thu Nov 30, 2023 3:44 pm
Projects: Married to a Fool, Mehkrow Meadows
Tumblr: inkacornn
itch: inkacorn
Contact:

[SOLVED] Issue with importing BMFonts

#1 Post by inkacorn »

howdy, ive been having some issues with importing a custom fnt file into renpy.
looking through this document about registering bmfonts, i used the BMFonts tool linked to create my custom font which was exported as an .fnt file. however, renpy seems to have a problem whenever i try to implement my custom font.

at first, i tried to register the font as the document states

Code: Select all

init python:
    renpy.register_bmfont(name="myfont", size=256, bold=False, italics=False, underline=False, filename="gui/fonts/myfont.fnt")
    
label start:
	jade "This text is supposed to be {font=myfont}YELLOW{/font}!"
but this results in an error

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00start.rpy", line 207, in script call
    call _gl_test
  File "renpy/common/00gltest.rpy", line 390, in script
    $ __gl_test()
  File "renpy/common/00gltest.rpy", line 390, in <module>
    $ __gl_test()
  File "renpy/common/00gltest.rpy", line 317, in _m1_00gltest__gl_test
    _gl_performance_test()
  File "renpy/common/00gltest.rpy", line 342, in _gl_performance_test
    ui.interact(suppress_underlay=True, suppress_overlay=True)
OSError: Couldn't find file 'myfont_0.png'.
which is odd because 'myfont_0.png' is in the same folderImage

so then i find this forum post and tried to do what they did

Code: Select all

# init python:
    # renpy.register_bmfont(name="myfont", size=256, bold=False, italics=False, underline=False, filename="gui/fonts/myfont.fnt")
    # this has been commented out
label start:
	jade "This text is supposed to be {font=gui/fonts/myfont.fnt}YELLOW{/font}!"
which results in this error

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/minigames.rpy", line 474, in script
    jade "This text is supposed to be {font=gui/fonts/myfont.fnt}YELLOW{/font}!"
FreetypeError: 2: b'unknown file format'
i looked up the error and this occurs when the file is corrupted. however, when running it through this file reader website to see if its readable, everything seems normal
Image
Image

here is a link to the fnt file in question (lemmasoft doesnt seem to support .fnt attachments): https://drive.google.com/file/d/1bGX0RK ... sp=sharing

im not sure if im doing something wrong with the code or if the file is truly corrupted. any advice would be greatly appreciated!
thank you
Last edited by inkacorn on Thu Jan 25, 2024 2:31 pm, edited 1 time in total.
Also known as the crazy jester lady
ImageImageImage

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Issue with importing BMFonts

#2 Post by PyTom »

You need to set the size that Ren'Py uses - just looking at this, you're setting it to 256, which Ren'Py is unlikely to use.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Google [Bot]