How to: use a font Image as text in BGE (bitmap font)

I made a soundless tutorial on how to create a texture out of a font ready to be used in the game engine.

Files you need (if you want to create your own images):
create font image.zip (157.1 KB)
(If winzip can’t extract it then download winrar)

3 Likes

That’s really nifty!
Thanks for sharing! : D

1 Like

any chance I could get a textual tutorial?

also any chance I can get a breakdown of the way the text character data locations are saved in the image?

Lastly, many years ago when I did my final project for my masters degree and used this method for text in the game; all was fine on my computer, but when I transferred it to the exhibition computer all the text characters were @'s the fix was manually going in to each text field object in Edit mode and Re-Unwrapping the UV outlines and replacing the vertexes back where they belong. not that they moved, just that I had to reunwrap them to get anything other than @.

such instructions are not something I can really put in a readme and have your random average player be able to understand much less do them. is there any special way to set it up so this does not happen when porting a game to other machines?

otherwise at current I have to use massive images to contain all the words numbers and letters and manually spawn meshplanes with add object. the reason I’m revisiting this like 5+ years later, is because in the case of my current game that will be a 6 MB image lol.

I can do that, we have the memory and graphics memory to store that, and internet speed to download that today, but. I come from the era of scene polycount limits and wise usage of memory (geometry vs image), it’s always a good idea to keep memory and processor usage as small as possible and 6MB breaks that rule lol.

I have no text tutorial but i do have made a video on how to do it:

I have no clue why the forum has removed all videos, all post lots the videos i had added to them.

I also did not create this script, i adjusted it so it would work again in bge 2.79+ the origional script was made back in 2001. all origional info is still present within the code.

As how it works…no clue to be honest, i assume the coords are being saved inside the png file, like all other png to font uses.

ok, one thing I’ll note did you use “snap to pixels” in the UV editor?, I usually do that to get it exactly to the bounds of the glyph. and have you tried copying one of said games to another computer and running it?

I was looking through the sourcecode for this feature today. it’s complicated lol. I hope I don’t have to mess with it.

No, i just losely fit it around the @ symbol.

Yes, simply make sure that the path is correct, so if you use “//blabla/textures” or “…//blabla/textures” make it use “logic.expandPath(‘//textures/’ + file_name)”, With bricks or texture location in materials tab; open the path in the brick then lead it to your textures folder that you use to export your blend, so not your allround texture folder on backup hdd.

//edit

To clarify:
If you have “D:\blender\textures” as an storage location where you have all the textures you normally use, then that path will be used if you export your game to an .exe file.

So to fix it (not loading textures on other pc’s):
Make a structure for your project.

for example a folder:

  • “my_projects”
  • “/game_name/”
    → “/textures/”
    → “/sounds/”
    → “/assets/”
    → .exe file
    → .dll files
    → your projects .blend file (till you have made an .exe. then you can remove that .blend file(unless your .blend has gpl attached then just leave it there))

So now you have a folder called “my_projects/game_name/” in the folder you have the texture folder.

Before you assign a texture to the object, you place/copy the texture to the texture folder located in this directory, then select that texture to be used on the object.

Now when you export your .exe it will use this directory on any pc.